[ SEA-GHOST MINI SHELL]

Path : /proc/2/cwd/proc/2/cwd/proc/2/cwd/proc/2/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/cwd/proc/2/cwd/proc/2/cwd/proc/2/root/var/lib/zabbix/check_graylognotifications.py

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

TIMEOUT = 5


def get_opts():
    parser = ArgumentParser(
        usage='%(prog)s -u api_url -t token',
        description='This program gets info using Graylog API'
    )
    parser.add_argument(
        "-u", "--url",
        action="store",
        dest="url",
        required=True,
        help=""
    )
    parser.add_argument(
        "-t", "--token",
        action="store",
        dest="token",
        required=True,
        help=""
    )
    args = parser.parse_args()
    return args


def api_call(url, token):
    base64auth = base64.encodestring('%s:%s' % (token, 'token')).replace('\n', '')
    req = urllib2.Request(
        url,
        headers={'Content-Type': 'application/json', 'Authorization': "Basic %s" % base64auth}
    )
    try:
        response = urllib2.urlopen(req, None, TIMEOUT)
        result = response.read()
        return json.loads(result)
    except urllib2.HTTPError, e:
        if e.code == 401:
            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()
    notifications_url = "http://{}/system/notifications".format(args.url)
    notifications = api_call(notifications_url, args.token)
    if notifications:
        for n in notifications['notifications']:
            try:
                streamid = n['details']['stream_id']
                streamtype = n['type']
                streams_url = "http://{0}/streams/{1}".format(args.url, streamid)
                stream = api_call(streams_url, args.token)
                print "ERROR: {0} ({1}) got {2}".format(stream['title'], streamid, streamtype)
            except KeyError:
                pass
    else:
        print "Empty result"

if __name__ == "__main__":
    main()


SEA-GHOST - SHELL CODING BY SEA-GHOST