mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-10 06:16:46 +00:00
Rename encrypt_header to do_encrypt_header. Changed signature. Also
write header.bin since we already received it.
This commit is contained in:
parent
525b2b4256
commit
98daf57086
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/__pycache__/
|
||||||
|
/.nvimlog
|
||||||
|
/header.bin
|
@ -37,4 +37,10 @@ for s in slaves:
|
|||||||
print("http://{}{}".format(s, fileurl))
|
print("http://{}{}".format(s, fileurl))
|
||||||
|
|
||||||
if fc.mode == fc.MODE_FULL:
|
if fc.mode == fc.MODE_FULL:
|
||||||
print(fc.encrypt_header(fileurl, random.choice(encslaves)))
|
header = fc.do_encrypt_header(random.choice(encslaves), fileurl)
|
||||||
|
if len(header) == 4194320:
|
||||||
|
print("Header length check passed. Writing to header.bin.")
|
||||||
|
with open("header.bin", "wb") as f:
|
||||||
|
f.write(header)
|
||||||
|
else:
|
||||||
|
print("Header length invalid ({}).".format(len(header)))
|
||||||
|
@ -188,17 +188,14 @@ class FotaCheck:
|
|||||||
encslaves = [s.text for s in enc_list]
|
encslaves = [s.text for s in enc_list]
|
||||||
return fileid, fileurl, slaves, encslaves
|
return fileid, fileurl, slaves, encslaves
|
||||||
|
|
||||||
def encrypt_header(self, address, encslave):
|
def do_encrypt_header(self, encslave, address):
|
||||||
params = self.get_creds()
|
params = self.get_creds()
|
||||||
params[b"address"] = bytes(address, "utf-8")
|
params[b"address"] = bytes(address, "utf-8")
|
||||||
url = "https://" + encslave + "/encrypt_header.php"
|
url = "https://" + encslave + "/encrypt_header.php"
|
||||||
req = self.sess.post(url, data=params, verify=False)
|
req = self.sess.post(url, data=params, verify=False)
|
||||||
# Expect "HTTP 206 Partial Content" response
|
# Expect "HTTP 206 Partial Content" response
|
||||||
if req.status_code == 206: # partial
|
if req.status_code == 206:
|
||||||
#return req.content
|
return req.content
|
||||||
contentlength = int(req.headers["Content-Length"])
|
|
||||||
sentinel = "\nHEADER FOUND" if contentlength == 4194320 else "\nNO HEADER FOUND"
|
|
||||||
return sentinel
|
|
||||||
else:
|
else:
|
||||||
print("ENCRYPT: " + repr(req))
|
print("ENCRYPT: " + repr(req))
|
||||||
print(repr(req.headers))
|
print(repr(req.headers))
|
||||||
|
Loading…
Reference in New Issue
Block a user