import os import random import requests import sys from datetime import datetime from hashlib import md5 from PIL import Image from string import ascii_lowercase API_KEY = "" def get_api_key(): random_str = "".join(random.choices(ascii_lowercase, k=5)) url = "https://p200wi0b00.execute-api.us-east-2.amazonaws.com/Prod/api/pctt/member/" payload = { "Username": f"{random_str}@{random_str}.com", "Password": md5(random_str.encode()).hexdigest() } headers = { "host": "p200wi0b00.execute-api.us-east-2.amazonaws.com", "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0", "accept": "application/json, text/javascript, */*; q=0.01", "accept-language": "en-US,en;q=0.5", "accept-encoding": "gzip, deflate, br", "content-type": "application/json", "origin": "https://pctattletale.com", "connection": "keep-alive", "referer": "https://pctattletale.com/", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" } response = requests.post(url, json=payload, headers=headers) return response.json()["APIKey"] def get_device_update_token(device_id): m = API_KEY + device_id return md5(m.encode()).hexdigest() def get_last_capture_for_device(device_id): url = f"https://5uw7yeva9g.execute-api.us-east-2.amazonaws.com/Prod/api/pctt/member/{API_KEY}/{device_id}/Live/" payload = { "Token": get_device_update_token(device_id) } headers = { "host": "5uw7yeva9g.execute-api.us-east-2.amazonaws.com", "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0", "accept": "application/json, text/javascript, */*; q=0.01", "accept-language": "en-US,en;q=0.5", "accept-encoding": "gzip, deflate, br", "content-type": "application/json", "referer": "https://pctattletale.com/", "origin": "https://pctattletale.com", "connection": "keep-alive", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" } response = requests.post(url, json=payload, headers=headers) last_ss_url = response.json()["lastScreenShot"] last_ss_ts = response.json()["idleTime"] if last_ss_ts == "Error": return last_ss_date = datetime.fromtimestamp(int(last_ss_ts)).strftime('%Y%m%d') os.mkdir(device_id) with open(device_id + "/" + device_id + "_" + last_ss_date + ".jpg", "wb") as f: f.write(requests.get(last_ss_url).content) i = 0 twenty_straight_failures = False new_ss_ts = int(last_ss_url[-14:][:-4]) while not twenty_straight_failures: new_ss_ts = new_ss_ts - 1 new_ss_url = last_ss_url[:-14] + str(new_ss_ts) + ".jpg" with open(device_id + "/" + device_id + "_" + str(new_ss_ts) + ".jpg", "wb") as f: f.write(requests.get(new_ss_url).content) try: im = Image.open(device_id + "/" + device_id + "_" + str(new_ss_ts) + ".jpg") i = 0 except IOError: # we downloaded the error XML instead of a valid JPG, delete it and increment failure count os.unlink(device_id + "/" + device_id + "_" + str(new_ss_ts) + ".jpg") i += 1 if i == 20: twenty_straight_failures = True API_KEY = get_api_key() if len(sys.argv) == 1: for i in range(60000, 62200): get_last_capture_for_device(str(i)) elif len(sys.argv) > 1: for id in sys.argv[1:]: get_last_capture_for_device(str(id))