FiddleComputers

JSONAPI method caller (Minecraft)

Aug 7th, 2019
223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #exec(open('script.py').read())
  2.  
  3. import urllib, urllib.parse, urllib.request
  4. from pprint import pprint
  5. import hashlib
  6. import json
  7.  
  8. host = "localhost"
  9. port = 65665
  10. usr = "admin"
  11. pwd = "changeme"
  12. salt = "salt"
  13.  
  14. print("Call method: ")
  15. method = input()
  16. methodToCall = urllib.parse.quote(method)
  17. print("Called "+method)
  18. arg = ""
  19. args = []
  20.  
  21. while not arg == "q":
  22.     print('Arg (q for quit): ')
  23.     arg = input()
  24.     if not arg == "q":
  25.         args.append(arg)
  26.  
  27. args = urllib.parse.quote(json.dumps(args))
  28. print("Final args: ")
  29. print(args)
  30.  
  31. key = hashlib.sha256()
  32. key.update(usr.encode('utf-8'))
  33. key.update(method.encode('utf-8'))
  34. key.update(pwd.encode('utf-8'))
  35. key.update(salt.encode('utf-8'))
  36.  
  37. key = key.hexdigest()
  38. print(key)
  39.  
  40. url = "http://{}:{}/api/call?method={}&args={}&key={}".format(host, port, methodToCall, args, key)
  41. print('Tried to access '+url)
  42.  
  43. f = urllib.request.urlopen(url)
  44. response = json.loads(f.read())
  45. pprint(response)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×