Forked from leezu/remarkable_find_update_device_id.py
Last active
December 15, 2020 15:55
-
-
Save Riebart/5e1ca519750d97b161b0f86b4879b272 to your computer and use it in GitHub Desktop.
Python script to rotate the machine IDs and OEM identifiers to find one that is eligible for a software update.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
import uuid | |
import random | |
import re | |
import sys | |
import requests | |
current_version = sys.argv[1] | |
orig_requestid = "f1aa8814-a007-46ad-aede-ae071cacccbe" | |
orig_sessionid = "2019ed24-e518-4a2c-96d2-af660a7bff97" | |
orig_appid = "98DA7DF2-4E3E-4744-9DE6-EC931886ABAB" | |
orig_bootid = "48cfc9fb-e90a-4ace-81aa-2b9eeb928e83" | |
orig_machineid = "" #censored | |
orig_oem = "" #censored | |
req = """<?xml version="1.0" encoding="UTF-8"?> | |
<request protocol="3.0" version="{current_version}" requestid="{{{requestid}}}" sessionid="{{{sessionid}}}" updaterversion="0.4.2" installsource="{installsource}" ismachine="1"> | |
<os version="codex 2.5.2" platform="reMarkable" sp="{current_version}_armv7l" arch="armv7l"></os> | |
<app appid="{{{appid}}}" version="{current_version}" track="Prod" ap="Prod" bootid="{{{bootid}}}" oem="{oem}" oemversion="2.5.2" alephversion="{current_version}" machineid="{machineid}" lang="en-US" board="" hardware_class="" delta_okay="false" nextversion="0.0.0" brand="" client="" > | |
<ping active="1"></ping> | |
<updatecheck></updatecheck> | |
<event eventtype="3" eventresult="2" previousversion=""></event> | |
</app> | |
</request>""" | |
url = "https://get-updates.cloud.remarkable.engineering/service/update2" | |
def get_uuid(): | |
"""Generate a random UUID. | |
update_engine/utils.cc just reads this from /proc/sys/kernel/random/uuid | |
""" | |
return str(uuid.uuid4()) | |
def get_oem(): | |
base = "RM100" | |
middle = "743" | |
# middle = str(random.randint(500, 800)) | |
# end = # Censored | |
end = str(random.randint(50000, 70000)) | |
return "-".join([base, middle, end]) | |
# Support some exponential backoff when we recive a 429 from the server. | |
sleep_time = 10.0 | |
while True: | |
params = { | |
"installsource": "scheduler", # or "ondemandupdate" | |
"requestid": get_uuid(), | |
"sessionid": get_uuid(), | |
# "appid": get_uuid(), | |
# "bootid": get_uuid(), | |
"machineid": get_uuid().replace("-", ""), | |
"oem": get_oem(), | |
# "requestid": orig_requestid, | |
# "sessionid": orig_sessionid, | |
"appid": orig_appid, | |
"bootid": orig_bootid, | |
"current_version": current_version | |
# "machineid": orig_machineid | |
} | |
resp = requests.post(url, req.format(**params)) | |
if "noupdate" in resp.text: | |
print(f"No update.. OEM: {params['oem']}") | |
else: | |
m = re.search("manifest version=[^>]*", resp.text) | |
try: | |
version = m.group(0).split("=")[1].replace('"', '') | |
except: | |
print("Regex failed:") | |
print(resp.status_code) | |
print(resp.text) | |
version = "" | |
if resp.status_code == 429: | |
sleep_time *= 1.2 | |
print("429 received, backoff time set to %f" % sleep_time) | |
if version < "2.3.0.0": | |
print("Found update for version %s, trying again" % version) | |
else: | |
print("Found params to get update: ") | |
print(params) | |
print() | |
print(resp.text) | |
break | |
time.sleep(sleep_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment