Last active
January 5, 2025 18:15
-
-
Save namidairo/bc2533dc99cf580ed9050dcd29591102 to your computer and use it in GitHub Desktop.
Re-implementation of miwifi router update check.
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
import requests | |
import datetime | |
import base64 | |
import hashlib | |
# Dummy values, countryCode required if querying EU servers | |
# Most important here are the hardware and channel | |
params = { | |
#"countryCode": "EU", | |
"deviceID": "", | |
"rom": "0.0.1", | |
"hardware": "RB03", | |
"cfe": "", | |
"linux": "0.0.1", | |
"ramfs": "0.0.1", | |
"sqafs": "0.0.1", | |
"rootfs": "0.0.1", | |
"channel": "release", | |
"serialNumber": "", | |
} | |
# Default server: http://api.miwifi.com, EU servers: http://eu.api.miwifi.com | |
server = "http://api.miwifi.com" | |
recoveryURL = "/rs/grayupgrade/recovery" | |
normalUpgradeUrl = "/rs/grayupgrade" | |
default_token = "8007236f-a2d6-4847-ac83-c49395ad6d65" | |
def main(): | |
# Constuct initial sub url based on params | |
sub_url = recoveryURL + "?" | |
for key, value in params.items(): | |
sub_url += key + "=" + value + "&" | |
# Add time to params formatted as %Y-%m-%d--%X | |
timestr = datetime.datetime.now().strftime("%Y-%m-%d--%X") | |
params["time"] = timestr | |
# Get sorted params list | |
sortedParams = sorted(params.items(), key=lambda x: x[0]) | |
# Loop through sorted params to create params string | |
paramsString = "" | |
for item in sortedParams: | |
paramsString += item[0] + "=" + item[1] + "&" | |
# Append default token to paramsString | |
paramsString += default_token | |
# Create signature of paramsString (md5 with base64 contents) | |
signature = hashlib.md5(base64.b64encode(paramsString.encode('utf-8'))).hexdigest() | |
# Construct url | |
url = server + sub_url + "s=" + signature + "&time=" + timestr + "&token=" + default_token | |
print("URL: " + url) | |
# Set user agent to "miwifi-", similar to their recovery process | |
headers = {'User-Agent': 'miwifi-'} | |
# Make request with url and headers | |
response = requests.get(url, headers=headers) | |
# Print response details | |
print("Status code: " + str(response.status_code)) | |
print("Response: " + response.text) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
For RB01 (AX3200) it worked to simply uncomment
"countryCode": "EU",
changing hardware toRB01
andserver = "http://eu.api.miwifi.com"