[ SEA-GHOST MINI SHELL]

Path : /proc/2/root/proc/self/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/root/proc/self/root/var/lib/zabbix/datacore_snap_check.py

#!/usr/bin/env python

import sys
import urllib2
import json
import re

snapsurl = "http://" + sys.argv[1] + "/RestService/rest.svc/1.0/snapshots"
serverhost = sys.argv[2]
apiuser = sys.argv[3]
apipass = sys.argv[4]
snapname = sys.argv[5]
snaptype = sys.argv[6]
array = []

def datacore(host,user,upass):
    req = urllib2.Request(
        snapsurl,
        headers={'ServerHost': host,'Accept': 'application/json', 'Authorization': 'Basic {} {}'.format(user,upass)}
    )
    try:
        response = urllib2.urlopen(req)
        result = response.read()
        return json.loads(result)
    except urllib2.HTTPError:
        print "Please check URL"
        sys.exit(1)
    except KeyError:
        print "Please check USER/PASS"
        sys.exit(1)

def main():
    dcore_raw = datacore(serverhost,apiuser,apipass)
    for snap in dcore_raw:
        snap_raw = snap['Caption'].split(':')
        if len(snap_raw) == 3:
            snap_name = snap_raw[0]
            snap_type = snap_raw[2]
            if snap_name == snapname and snap_type == snaptype:
                snap_failure = snap['Failure']
                snap_time = re.search('([0-9]{13})\+', snap['TimeStamp'])
#               print snap_name,snap_time.group(1),snap_failure
                array.append([snap_name,snap_time.group(1),snap_failure])
    if not array:
        print 'Not found'
    else:
        snap_result = max(array, key=lambda item: item[1])
        print snap_result[0],snap_result[1],snap_result[2]

if __name__ == "__main__":
    main()

SEA-GHOST - SHELL CODING BY SEA-GHOST