Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import datetime
- import numpy as np
- import requests
- import hashlib
- def time():
- now = datetime.datetime.now().ctime().split()
- now[0] += ','
- now[2], now[1] = now[1], now[2]
- now[4], now[3] = now[3], now[4]
- now.append("GMT")
- return " ".join(now)
- def xor_cipher(b, key):
- encripted = b''
- for letter in b:
- encripted += chr(letter ^ key).encode()
- return encripted
- url = "http://127.0.0.1:8080"
- response = requests.request('get', url + "/hello")
- text = response.text
- status = response.status_code
- last = "requests.request('get', url + '/hello')"
- while ("It works!" not in str(text)) and (status != 202):
- if "What time is it?" in str(text):
- response = requests.request('give', url + "/time", json = time())
- last = "requests.request('give', url + '/time', json = time())"
- elif str(text) == "":
- response = requests.request("post", url + "/tell", data = "Chill down, please!")
- last = 'requests.request("post", url + "/tell", data = "Chill down, please!")'
- elif status == 418:
- response = requests.request("patch", url + "/tea", data = {"type":"mate", "cups":1})
- last = 'requests.request("patch", url + "/tea", data = {"type":"mate", "cups":1})'
- elif response.headers['Content-Type'] == "application/octet-stream":
- if "Crypto-Key" in response.headers:
- key = int(response.headers['Crypto-key'])
- response = requests.post(url+"/push")
- encr_strg = xor_cipher(text, key)
- response = requests.post(url+"/push", data=encr_strg)
- last = 'requests.post(url+"/push", data=encr_strg)'
- else:
- sha = hashlib.sha256(text).hexdigest()
- response = requests.post(url+"/push", data=sha)
- last = 'requests.post(url+"/push", data=sha)'
- elif type(list(response.json().values())[0]) == type([]):
- mean = np.mean(list(response.json().values())[0])
- response = requests.request('put', url+'/mean', json=mean)
- last = "requests.request('put', url+'/mean', json=mean)"
- elif response.json()['json'] == None and "Agent" in response.headers:
- agent = response.headers["Agent"]
- response = requests.request('delete', url + '/' + agent)
- last = "requests.request('delete', url + '/' + agent)"
- elif "type" in list(response.json().values()):
- if response.json()["type"] == "library":
- name = response.json()["name"]
- response = requests.request('post', url+'/push', data=response.text)
- last = "requests.request('post', url+'/push', data=response.text)"
- elif response.json()["type"] == "tell_me":
- name = response.json()["property"]
- response = requests.request('post', url+'/tell', data=response.text)
- last = "requests.request('post', url+'/tell', data=response.text)"
- elif status == 500:
- response = eval(last)
- elif status == 303:
- response = requests.get(url+"/hello")
- last = 'requests.get(url+"/hello")'
- elif status == 202 and ("It works!" not in str(text)):
- response = requests.post(url+"/hello")
- last = 'requests.post(url+"/hello")'
- text = response.text
- status = response.status_code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement