diff --git a/tclcheck.py b/tclcheck.py index 168ec3c..57b8c98 100644 --- a/tclcheck.py +++ b/tclcheck.py @@ -4,6 +4,7 @@ # pylint: disable=C0111,C0326 import tcllib +import random import sys fc = tcllib.FotaCheck() @@ -25,7 +26,7 @@ fc.cltp = 10 #fc.cltp = 2010 check_xml = fc.do_check() -#print(fc.pretty_xml(check_xml)) +print(fc.pretty_xml(check_xml)) curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml) req_xml = fc.do_request(curef, fv, tv, fw_id) diff --git a/tcllib.py b/tcllib.py index 5702bb3..f0ed78d 100644 --- a/tcllib.py +++ b/tcllib.py @@ -116,6 +116,15 @@ class FotaCheck: hexhash = engine.hexdigest() return hexhash + @staticmethod + def get_creds(): + creds = { + b"YWNjb3VudA==": b"emhlbmdodWEuZ2Fv", + b"cGFzc3dvcmQ=": b"cWFydUQ0b2s=", + } + params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} + return params + ''' private HashMap buildDownloadUrisParams(UpdatePackageInfo updatePackageInfo) { FotaLog.m28v(TAG, "doAfterCheck"); @@ -180,10 +189,7 @@ class FotaCheck: return fileid, fileurl, slaves, encslaves def encrypt_header(self, address, encslave): - encs = dict() - encs[b"YWNjb3VudA=="] = b"emhlbmdodWEuZ2Fv" - encs[b"cGFzc3dvcmQ="] = b"cWFydUQ0b2s=" - params = {base64.b64decode(key): base64.b64decode(val) for key, val in encs.items()} + params = self.get_creds() params[b"address"] = bytes(address, "utf-8") url = "https://" + encslave + "/encrypt_header.php" req = self.sess.post(url, data=params, verify=False)