From d7bb7933ca57333dbfb6b5ee63d849716cfeedd2 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 10:11:49 +0200 Subject: [PATCH 01/10] Update init.py --- edlclient/Library/Modules/init.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edlclient/Library/Modules/init.py b/edlclient/Library/Modules/init.py index eb3a4fc..9566a1b 100644 --- a/edlclient/Library/Modules/init.py +++ b/edlclient/Library/Modules/init.py @@ -12,18 +12,21 @@ from edlclient.Library.utils import LogBase try: from edlclient.Library.Modules.generic import generic except ImportError as e: + self.error(e) generic = None pass try: from edlclient.Library.Modules.oneplus import oneplus except ImportError as e: + self.error(e) oneplus = None pass try: from edlclient.Library.Modules.xiaomi import xiaomi except ImportError as e: + self.error(e) xiaomi = None pass @@ -47,17 +50,20 @@ class modules(metaclass=LogBase): try: self.generic = generic(fh=self.fh, serial=self.serial, args=self.args, loglevel=loglevel) except Exception as e: + self.error(e) pass self.ops = None try: self.ops = oneplus(fh=self.fh, projid=self.devicemodel, serial=self.serial, supported_functions=self.supported_functions, args=self.args, loglevel=loglevel) except Exception as e: + self.error(e) pass self.xiaomi = None try: self.xiaomi = xiaomi(fh=self.fh) except Exception as e: + self.error(e) pass def addpatch(self): From e89ae2a50a915983ba4404259d599fcbbfaf846b Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 10:13:17 +0200 Subject: [PATCH 02/10] Update init.py --- edlclient/Library/Modules/init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edlclient/Library/Modules/init.py b/edlclient/Library/Modules/init.py index 9566a1b..a855921 100644 --- a/edlclient/Library/Modules/init.py +++ b/edlclient/Library/Modules/init.py @@ -12,21 +12,21 @@ from edlclient.Library.utils import LogBase try: from edlclient.Library.Modules.generic import generic except ImportError as e: - self.error(e) + print(e) generic = None pass try: from edlclient.Library.Modules.oneplus import oneplus except ImportError as e: - self.error(e) + print(e) oneplus = None pass try: from edlclient.Library.Modules.xiaomi import xiaomi except ImportError as e: - self.error(e) + print(e) xiaomi = None pass From c47e07e7806aac1b51833e81480011b03c642f26 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 10:23:19 +0200 Subject: [PATCH 03/10] Update edl --- edl | 70 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/edl b/edl index bf3fcbf..498411c 100755 --- a/edl +++ b/edl @@ -9,19 +9,19 @@ """ Usage: edl -h | --help - edl [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl [--loader=filename] [--memory=memtype] [--portname=portname] [--serial] - edl [--debugmode] [--portname=portname] [--serial] - edl [--gpt-num-part-entries=number] [--gpt-part-entry-size=number] [--gpt-part-entry-start-lba=number] [--portname=portname] [--serial] - edl [--memory=memtype] [--skipstorageinit] [--maxpayload=bytes] [--sectorsize==bytes] [--portname=portname] [--serial] - edl server [--tcpport=portnumber] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] - edl memorydump [--partitions=partnames] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--serial_number=serial_number] - edl printgpt [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl gpt [--memory=memtype] [--lun=lun] [--genxml] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl r [--memory=memtype] [--sectorsize==bytes] [--lun=lun] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl rl [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--skip=partnames] [--genxml] [--skipresponse] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl rf [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl rs [--lun=lun] [--sectorsize==bytes] [--memory=memtype] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] + edl [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl [--loader=filename] [--memory=memtype] [--portname=portname] [--serial] [--devicemodel=value] + edl [--debugmode] [--portname=portname] [--serial] [--devicemodel=value] + edl [--gpt-num-part-entries=number] [--gpt-part-entry-size=number] [--gpt-part-entry-start-lba=number] [--portname=portname] [--serial] [--devicemodel=value] + edl [--memory=memtype] [--skipstorageinit] [--maxpayload=bytes] [--sectorsize==bytes] [--portname=portname] [--serial] [--devicemodel=value] + edl server [--tcpport=portnumber] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl memorydump [--partitions=partnames] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--serial_number=serial_number] [--devicemodel=value] + edl printgpt [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl gpt [--memory=memtype] [--lun=lun] [--genxml] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl r [--memory=memtype] [--sectorsize==bytes] [--lun=lun] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl rl [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--skip=partnames] [--genxml] [--skipresponse] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl rf [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl rs [--lun=lun] [--sectorsize==bytes] [--memory=memtype] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] edl w [--partitionfilename=filename] [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--skipwrite] [--skipresponse] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] edl wl [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--skip=partnames] [--skipresponse] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] edl wf [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] @@ -29,31 +29,31 @@ Usage: edl e [--memory=memtype] [--skipwrite] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] edl es [--memory=memtype] [--lun=lun] [--sectorsize==bytes] [--skipwrite] [--loader=filename] [--skipresponse] [--debugmode] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] edl ep [--memory=memtype] [--skipwrite] [--lun=lun] [--sectorsize==bytes] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] - edl footer [--memory=memtype] [--lun=lun] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl peek [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl peekhex [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl peekdword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl peekqword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl memtbl [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl poke [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl pokehex [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl pokedword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl pokeqword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl memcpy [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl secureboot [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl pbl [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl qfp [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl getstorageinfo [--loader=filename] [--memory=memtype] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] - edl setbootablestoragedrive [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl setactiveslot [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl send [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] + edl footer [--memory=memtype] [--lun=lun] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl peek [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl peekhex [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl peekdword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl peekqword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl memtbl [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl poke [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl pokehex [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl pokedword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl pokeqword [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl memcpy [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl secureboot [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl pbl [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl qfp [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl getstorageinfo [--loader=filename] [--memory=memtype] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] + edl setbootablestoragedrive [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl setactiveslot [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl send [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] edl xml [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] edl rawxml [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial] - edl reset [--resetmode=mode] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl nop [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] + edl reset [--resetmode=mode] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl nop [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] edl modules [--memory=memtype] [--lun=lun] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--portname=portname] [--serial] - edl provision [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] - edl qfil [--loader=filename] [--memory=memtype] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] + edl provision [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl qfil [--loader=filename] [--memory=memtype] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] Description: server # Run tcp/ip server From 217db8ba5d247777a4231ff36e9ccb3bc9aa191a Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 10:33:55 +0200 Subject: [PATCH 04/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 1 + 1 file changed, 1 insertion(+) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index 52c3438..9367f47 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -204,6 +204,7 @@ class oneplus(metaclass=LogBase): else: assert "Device is not supported" exit(0) + assert "Unknown projid:"+str(projid) return None def run(self): From cd299062e97f6611c7606f061c346d994003e021 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 10:47:54 +0200 Subject: [PATCH 05/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index 9367f47..b6c3bda 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -200,7 +200,7 @@ class oneplus(metaclass=LogBase): exit(0) elif version == 3: if cm is not None: - oneplus2(fh, cm, serial, pk, prodkey, self.ATOBuild, self.Flash_Mode, self.cf) + return oneplus2(fh, cm, serial, pk, prodkey, self.ATOBuild, self.Flash_Mode, self.cf) else: assert "Device is not supported" exit(0) From 64c3ff2b9b16944e3afb71c0184beb617ee7c09a Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 11:28:36 +0200 Subject: [PATCH 06/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index b6c3bda..13e2695 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -493,7 +493,9 @@ class oneplus2(metaclass=LogBase): print(res.decode('utf-8')) return False data = res.decode('utf-8') - device_timestamp = data[data.rfind("device_timestamp"):].split("\"")[1] + device_timestamp = data[ridx:].split("\"")[1] + print(data) + print(device_timestamp) pk, token = self.generatetoken(False, device_timestamp) res = self.fh.cmd_send(f"setswprojmodel token=\"{token}\" pk=\"{pk}\"") if not b"model_check=\"0\"" in res or not b"auth_token_verify=\"0\"" in res: From 457e722893a694c72de3009a5d93ca313101b1a6 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 11:36:31 +0200 Subject: [PATCH 07/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index 13e2695..ae98f78 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -493,7 +493,7 @@ class oneplus2(metaclass=LogBase): print(res.decode('utf-8')) return False data = res.decode('utf-8') - device_timestamp = data[ridx:].split("\"")[1] + device_timestamp = data[data.find("device_timestamp"):].split("\"")[1] print(data) print(device_timestamp) pk, token = self.generatetoken(False, device_timestamp) From 6cd83a632793a62c43cf8d1122bf49971e32a076 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 2 Oct 2023 15:33:59 +0200 Subject: [PATCH 08/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index ae98f78..5bd87ad 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -447,9 +447,11 @@ class oneplus2(metaclass=LogBase): self.__logger.addHandler(fh) def crypt_token(self, data, pk, device_timestamp, decrypt=False): + print(device_timestamp) + print(type(device_timestamp)) aes = cryptutils().aes() aeskey = b"\x46\xA5\x97\x30\xBB\x0D\x41\xE8" + bytes(pk, 'utf-8') + \ - pack(" Date: Mon, 2 Oct 2023 15:39:05 +0200 Subject: [PATCH 09/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index 5bd87ad..d4b4baf 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +v#!/usr/bin/env python3 # -*- coding: utf-8 -*- # (c) B.Kerler 2018-2023 under GPLv3 license # If you use my code, make sure you refer to my name @@ -447,11 +447,10 @@ class oneplus2(metaclass=LogBase): self.__logger.addHandler(fh) def crypt_token(self, data, pk, device_timestamp, decrypt=False): - print(device_timestamp) - print(type(device_timestamp)) + timestamp = str(int(time.time())) aes = cryptutils().aes() aeskey = b"\x46\xA5\x97\x30\xBB\x0D\x41\xE8" + bytes(pk, 'utf-8') + \ - pack(" Date: Mon, 2 Oct 2023 15:59:02 +0200 Subject: [PATCH 10/10] Update oneplus.py --- edlclient/Library/Modules/oneplus.py | 48 +++++++++++++++------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index d4b4baf..c87daa7 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -1,4 +1,4 @@ -v#!/usr/bin/env python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # (c) B.Kerler 2018-2023 under GPLv3 license # If you use my code, make sure you refer to my name @@ -24,7 +24,7 @@ import random from struct import pack import logging from edlclient.Library.utils import LogBase - +from edlclient.Library.Modules.oneplus_param import paramtools try: from edlclient.Library.cryptutils import cryptutils except Exception as e: @@ -128,7 +128,7 @@ deviceconfig = { class oneplus(metaclass=LogBase): - def __init__(self, fh, projid="18825", serial=123456, ATOBuild=0, Flash_Mode=0, cf=0, supported_functions=None, + def __init__(self, fh, projid:str="18825", serial=123456, ATOBuild=0, Flash_Mode=0, cf=0, supported_functions=None, args=None, loglevel=logging.INFO): self.fh = fh self.__logger = self.__logger @@ -160,7 +160,6 @@ class oneplus(metaclass=LogBase): filehandler = logging.FileHandler(logfilename) self.__logger.addHandler(filehandler) try: - from edlclient.Library.Modules.oneplus_param import paramtools if projid in deviceconfig: mode = deviceconfig[projid]["param_mode"] self.ops_parm = paramtools(mode=mode, serial=serial) @@ -226,16 +225,16 @@ class oneplus(metaclass=LogBase): if self.ops.setprojmodel_verify: return self.ops.setprojmodel_verify(pk, token) - def setswprojmodel_verify(self, pk, token, device_timestamp): + def setswprojmodel_verify(self, pk, token): if self.ops.setswprojmodel_verify: - return self.ops.setswprojmodel_verify(pk, token, device_timestamp) + return self.ops.setswprojmodel_verify(pk, token) def program_verify(self, pk, token, tokendata): if self.ops.program_verify: return self.ops.program_verify(pk, token, tokendata) - def generatetoken(self, program=False, device_timestamp="123456789"): - return self.ops.generatetoken(program=program, device_timestamp=device_timestamp) + def generatetoken(self, program=False): + return self.ops.generatetoken(program=program) def demacia(self): if self.ops.demacia(): @@ -311,7 +310,7 @@ class oneplus1: data = "\n\n\n" return data - def generatetoken(self, program=False, device_timestamp=None): + def generatetoken(self, program=False): timestamp = str(int(time.time())) ha = cryptutils().hash() h1 = self.prodkey + self.ModelVerifyPrjName + self.random_postfix @@ -430,6 +429,7 @@ class oneplus1: class oneplus2(metaclass=LogBase): def __init__(self, fh, ModelVerifyPrjName="20889", serial=123456, pk="", prodkey="", ATOBuild=0, Flash_Mode=0, cf=0, loglevel=logging.INFO): + self.device_timestamp = None self.ModelVerifyPrjName = ModelVerifyPrjName self.pk = pk self.fh = fh @@ -446,11 +446,10 @@ class oneplus2(metaclass=LogBase): fh = logging.FileHandler(logfilename) self.__logger.addHandler(fh) - def crypt_token(self, data, pk, device_timestamp, decrypt=False): - timestamp = str(int(time.time())) + def crypt_token(self, data, pk, device_timestamp:int, decrypt=False): aes = cryptutils().aes() aeskey = b"\x46\xA5\x97\x30\xBB\x0D\x41\xE8" + bytes(pk, 'utf-8') + \ - pack("\"") # Response should be : - pk, token = op2.generatetoken(False, device_timestamp) + pk, token = op2.generatetoken(False) print( f"./edl.py rawxml \"\" --debugmode") @@ -607,9 +609,10 @@ def main(): projid = args["--projid"][0] device_timestamp = args["--ts"] op = oneplus(None, projid=projid, serial=123456) + op.ops.device_timestamp = int(device_timestamp) token = args[""] pk = args[""] - op.setswprojmodel_verify(pk, token, device_timestamp) + op.setswprojmodel_verify(pk, token) def test_setswprojmodel_verify(): @@ -619,8 +622,9 @@ def test_setswprojmodel_verify(): op = oneplus(None, projid=projid, serial=123456) data = deviceresp.decode('utf-8') device_timestamp = data[data.rfind("device_timestamp"):].split("\"")[1] - pk, token = op.generatetoken(False, device_timestamp) - if not op.setswprojmodel_verify(pk, token, device_timestamp): + op.ops.device_timestamp = int(device_timestamp) + pk, token = op.generatetoken(False) + if not op.setswprojmodel_verify(pk, token): assert "Setswprojmodel error"