[ SEA-GHOST MINI SHELL]

Path : /proc/2/task/2/root/proc/3/root/proc/self/root/proc/2/cwd/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/task/2/root/proc/3/root/proc/self/root/proc/2/cwd/var/lib/zabbix/check_rundeck_api.py

#!/usr/bin/env python
import json
import ssl
import sys
import urllib2
from argparse import ArgumentParser

# Monkey patch to skip ssl check
ssl._create_default_https_context = ssl._create_unverified_context

TIMEOUT = 5
STATS = ['cpu', 'memory', 'scheduler', 'threads', 'uptime']


def get_opts():
    parser = ArgumentParser(
        usage='%(prog)s -s server_url -t token -k key',
        description='This program gets stats using Rundeck API'
    )
    parser.add_argument(
        "-s", "--server",
        action="store",
        dest="server",
        required=True,
        help=""
    )
    parser.add_argument(
        "-t", "--token",
        action="store",
        dest="token",
        required=True,
        help=""
    )
    parser.add_argument(
        "-k", "--key",
        action="store",
        dest="key",
        required=True,
        help=""
    )
    args = parser.parse_args()
    args.key = args.key.split('.')
    if args.key[0] not in STATS:
        print "Please check the key"
        sys.exit(1)
    return args


def api_call(url):
    req = urllib2.Request(
        url,
        headers={'Content-Type': 'application/json'},
    )
    try:
        response = urllib2.urlopen(req, None, TIMEOUT)
        result = response.read()
        return json.loads(result)['system']['stats']
    except urllib2.HTTPError, e:
        if e.code == 403:
            print "Please check your token"
        elif e.code == 502:
            print "API is not accesable"
        sys.exit(1)
    except urllib2.URLError:
        print "Please check the URL"
        sys.exit(1)


def main():
    args = get_opts()

    api_url = "{0}/api/20/system/info?authtoken={1}&format=json".format(
        args.server,
        args.token)

    stats = api_call(api_url)

    try:
        print stats[args.key[0]][args.key[1]]
    except IndexError:
        print "Please check the key"
        sys.exit(1)


if __name__ == "__main__":
    main()


SEA-GHOST - SHELL CODING BY SEA-GHOST