Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib, urllib.parse, urllib.request
- import hashlib
- import json
- import re
- host = "localhost"
- port = 65665
- usr = "admin"
- pwd = "changeme"
- salt = "salt"
- print("Connecting to "+host+"...")
- method = "getLatestConsoleLogsWithLimit"
- methodToCall = urllib.parse.quote(method)
- firstLimit = urllib.parse.quote(json.dumps(['999999']))
- limit = urllib.parse.quote(json.dumps(['1']))
- key = hashlib.sha256()
- key.update(usr.encode('utf-8'))
- key.update(method.encode('utf-8'))
- key.update(pwd.encode('utf-8'))
- key.update(salt.encode('utf-8'))
- key = key.hexdigest()
- urlAllLogs = "http://{}:{}/api/call?method={}&args={}&key={}".format(host, port, methodToCall, firstLimit, key)
- f = urllib.request.urlopen(urlAllLogs)
- response = json.loads(f.read())
- last_line = ""
- if response['result'] == 'success':
- for line in response['success']:
- line['line'] = re.sub(
- r"\[0;[0-9][0-9];[0-9]([0-9]|m)(m|)",
- "",
- line['line']
- )
- line['line'] = re.sub(
- r"\[[0-9][0-9]m((([0-9]|)\[m)|)",
- "",
- line['line']
- )
- line['line'] = line['line'].replace("", "")
- line['line'] = line['line'].replace("[m", "")
- print(line['line'], end="")
- last_line = line['line']
- while True:
- url = "http://{}:{}/api/call?method={}&args={}&key={}".format(host, port, methodToCall, limit, key)
- f = urllib.request.urlopen(url)
- response = json.loads(f.read())
- if response['result'] == 'success':
- line = response['success'][0]['line']
- line = re.sub(
- r"\[0;[0-9][0-9];[0-9]([0-9]|m)(m|)",
- "",
- line
- )
- line = re.sub(
- r"\[[0-9][0-9]m((([0-9]|)\[m)|)",
- "",
- line
- )
- line = line.replace("", "")
- line = line.replace("[m", "")
- if not line == last_line:
- last_line = line
- print(line, end="")
Add Comment
Please, Sign In to add comment