diff --git a/mtkclient/Library/DA/daconfig.py b/mtkclient/Library/DA/daconfig.py index 9cf2219..d0d6e77 100755 --- a/mtkclient/Library/DA/daconfig.py +++ b/mtkclient/Library/DA/daconfig.py @@ -203,7 +203,7 @@ class DAconfig(metaclass=LogBase): with open(preloader, "rb") as rf: data = rf.read() else: - self.error("Preloader : " + preloader + " doesn't exist. Aborting.") + self.error(f"Preloader : {preloader} doesn't exist. Aborting.") exit(1) try: self.emiver, self.emi = self.m_extract_emi(data) @@ -211,7 +211,7 @@ class DAconfig(metaclass=LogBase): self.emiver = 0 self.emi = None - def parse_da_loader(self, loader:str, dasetup:dict): + def parse_da_loader(self, loader: str, dasetup: dict): try: with open(loader, 'rb') as bootldr: # data = bootldr.read() @@ -245,7 +245,7 @@ class DAconfig(metaclass=LogBase): dasetup[da.hw_code].append(da) return True except Exception as e: - self.error("Couldn't open loader: " + loader + ". Reason: " + str(e)) + self.error(f"Couldn't open loader: {loader}. Reason: {str(e)}") return False def setup(self): diff --git a/mtkclient/Library/DA/legacy/extension/legacy.py b/mtkclient/Library/DA/legacy/extension/legacy.py index eaf9dbb..6610556 100755 --- a/mtkclient/Library/DA/legacy/extension/legacy.py +++ b/mtkclient/Library/DA/legacy/extension/legacy.py @@ -80,7 +80,8 @@ class legacyext(metaclass=LogBase): self.warning("Legacy DA2 CMD F0 not patched.") return da2patched - def fix_hash(self, da1, da2, da2sig_len, hashpos, hashmode): + @staticmethod + def fix_hash(da1, da2, da2sig_len, hashpos, hashmode): da1 = bytearray(da1) dahash = None if hashmode == 1: @@ -245,8 +246,7 @@ class legacyext(metaclass=LogBase): except Exception: return hwc = self.cryptosetup() - retval = {} - retval["hwcode"] = hex(self.config.hwcode) + retval = {"hwcode": hex(self.config.hwcode)} meid = self.config.get_meid() socid = self.config.get_socid() hwcode = self.config.get_hwcode() diff --git a/mtkclient/Library/DA/mtk_da_handler.py b/mtkclient/Library/DA/mtk_da_handler.py index 192cfd0..7353805 100755 --- a/mtkclient/Library/DA/mtk_da_handler.py +++ b/mtkclient/Library/DA/mtk_da_handler.py @@ -91,7 +91,7 @@ class DA_handler(metaclass=LogBase): if mtk.config.target_config["sbc"] and not mtk.config.is_brom and mtk.config.loader is None: mtk = mtk.bypass_security() self.mtk = mtk - if self.mtk.daloader.patch : + if self.mtk.daloader.patch: self.info("Device was protected. Successfully bypassed security.") else: self.info("Device is still protected, trying to boot to brom") @@ -685,7 +685,8 @@ class DA_handler(metaclass=LogBase): print(f"Failed to dump offset {hex(start)} with length {hex(length)} as {filename}.") elif cmd == "fs": print(f'Mounting FUSE fs at: {args.mountpoint}...') - fs = FUSE(MtkDaFS(self, rw=args.rw), mountpoint=args.mountpoint, foreground=True, allow_other=True, nothreads=True) + fs = FUSE(MtkDaFS(self, rw=args.rw), mountpoint=args.mountpoint, foreground=True, allow_other=True, + nothreads=True) elif cmd == "footer": filename = args.filename self.da_footer(filename=filename) diff --git a/mtkclient/Library/DA/mtk_daloader.py b/mtkclient/Library/DA/mtk_daloader.py index 85e6f70..65d896c 100755 --- a/mtkclient/Library/DA/mtk_daloader.py +++ b/mtkclient/Library/DA/mtk_daloader.py @@ -89,7 +89,8 @@ class DAloader(metaclass=LogBase): return idx, hashmode, hashlen return idx, hashmode, hashlen - def find_da_hash_V6(self, da1, siglen): + @staticmethod + def find_da_hash_V6(da1, siglen): pos = len(da1) - siglen - 0x30 hash = da1[pos:pos + 0x30] if hash[-4:] == b"\x00\x00\x00\x00": @@ -110,7 +111,8 @@ class DAloader(metaclass=LogBase): self.debug("Error: No hash found") return -1, -1 - def calc_da_hash(self, da1, da2): + @staticmethod + def calc_da_hash(da1, da2): hashdigest = hashlib.sha1(da2).digest() hashdigest256 = hashlib.sha256(da2).digest() idx = da1.find(hashdigest) @@ -120,7 +122,8 @@ class DAloader(metaclass=LogBase): hashmode = 2 return hashmode, idx - def fix_hash(self, da1, da2, hashpos, hashmode, hashlen): + @staticmethod + def fix_hash(da1, da2, hashpos, hashmode, hashlen): da1 = bytearray(da1) dahash = None if hashmode == 1: diff --git a/mtkclient/Library/DA/xml/xml_cmd.py b/mtkclient/Library/DA/xml/xml_cmd.py index 6c50c16..eb030c1 100755 --- a/mtkclient/Library/DA/xml/xml_cmd.py +++ b/mtkclient/Library/DA/xml/xml_cmd.py @@ -14,7 +14,8 @@ class XMLCmd(metaclass=LogBase): self.mtk = mtk self.MAGIC = 0xFEEEEEEF - def create_cmd(self, cmd: str, content: dict = None, version="1.0"): + @staticmethod + def create_cmd(cmd: str, content: dict = None, version="1.0"): cmd = f"{version}CMD:{cmd}" if content is not None: for item in content: diff --git a/mtkclient/Tools/brom_to_offs b/mtkclient/Tools/brom_to_offs index 982213f..79af0ea 100755 --- a/mtkclient/Tools/brom_to_offs +++ b/mtkclient/Tools/brom_to_offs @@ -104,16 +104,16 @@ def main(): pos -= 1 else: pos2 = find_binary(data, "46FFF7", pos + 8) - if pos2 != None: + if pos2 is not None: if pos2 - pos < 0x20: pos = pos else: pos = pos2 - 1 posr = -1 startpos = 0 - while posr != None: + while posr is not None: posr = find_binary(data, "2DE9F047", startpos) - if posr == None: + if posr is None: break if data[posr + 7] == 0x46 and data[posr + 8] == 0x92: break