diff --git a/tclcheck.py b/tclcheck.py index 74ee4ac..6822715 100755 --- a/tclcheck.py +++ b/tclcheck.py @@ -70,6 +70,9 @@ req_xml = fc.do_request(curef, fv, tv, fw_id) print(fc.pretty_xml(req_xml)) fileid, fileurl, slaves, encslaves, s3_fileurl, s3_slaves = fc.parse_request(req_xml) +chksum_xml = fc.do_checksum(random.choice(encslaves), fileurl, fileurl) +print(fc.pretty_xml(chksum_xml)) + for s in slaves: print("http://{}{}".format(s, fileurl)) diff --git a/tcllib.py b/tcllib.py index 4e9ce1b..576f1ba 100644 --- a/tcllib.py +++ b/tcllib.py @@ -308,6 +308,15 @@ class FotaCheck: params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} return params + @staticmethod + def get_creds2(): + creds = { + b"YWNjb3VudA==": b"VGVsZUV4dFRlc3Q=", + b"cGFzc3dvcmQ=": b"dDA1MjM=", + } + params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} + return params + ''' private HashMap buildDownloadUrisParams(UpdatePackageInfo updatePackageInfo) { FotaLog.m28v(TAG, "doAfterCheck"); @@ -379,7 +388,7 @@ class FotaCheck: def do_encrypt_header(self, encslave, address): params = self.get_creds() params[b"address"] = bytes(address, "utf-8") - url = "https://" + encslave + "/encrypt_header.php" + url = "http://" + encslave + "/encrypt_header.php" req = self.sess.post(url, data=params, verify=False) # Expect "HTTP 206 Partial Content" response if req.status_code == 206: @@ -389,3 +398,20 @@ class FotaCheck: print(repr(req.headers)) print(repr(req.text)) raise SystemExit + + def do_checksum(self, encslave, uri1, uri2): + url = "http://" + encslave + "/checksum.php" + params = self.get_creds2() + params[b"address"] = bytes('{"' + uri1 + '":"' + uri2 + '"}', "utf-8") + + #print(repr(dict(params))) + req = self.sess.post(url, data=params) + if req.status_code == 200: + req.encoding = "utf-8" # Force encoding as server doesn't give one + self.write_dump(req.text) + return req.text + else: + print("CHECKSUM: " + repr(req)) + print(repr(req.headers)) + print(repr(req.text)) + raise SystemExit