diff --git a/mtk.py b/mtk.py index 4a73b39..4aca4c3 100755 --- a/mtk.py +++ b/mtk.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# MTK Flash Client (c) B.Kerler 2018-2023. +# MTK Flash Client (c) B.Kerler 2018-2024. # Licensed under GPLv3 License import argparse from mtkclient.Library.mtk_main import Main, metamodes @@ -47,8 +47,8 @@ if __name__ == '__main__': subparsers = parser.add_subparsers(dest="cmd", help='Valid commands are: \n' + 'printgpt, gpt, r, rl, rf, fs, rs, w, wf, wl, e, es, footer, reset, \n' + - 'dumpbrom, dumpsram, dumppreloader, payload, crash, brute, gettargetconfig, \n' + - 'peek, stage, plstage, da, script\n') + 'dumpbrom, dumpsram, dumppreloader, payload, crash, brute, \n' + + 'gettargetconfig, peek, stage, plstage, da, script\n') parser_script = subparsers.add_parser("script", help="Run text script") parser_printgpt = subparsers.add_parser("printgpt", help="Print GPT Table information") @@ -202,8 +202,8 @@ if __name__ == '__main__': parser_printgpt.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_printgpt.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_printgpt.add_argument('--ptype', - help='Set the payload type ("amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by ' + - 'default)') + help='Set the payload type ("amonet","kamakiri","kamakiri2","carbonara" ' + 'kamakiri2/da used by default)') parser_printgpt.add_argument('--preloader', help='Set the preloader filename for dram config') parser_printgpt.add_argument('--crash', help='Enforce crash if device is in pl mode to enter brom mode') parser_printgpt.add_argument('--socid', help='Read Soc ID') @@ -229,7 +229,8 @@ if __name__ == '__main__': parser_gpt.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_gpt.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_gpt.add_argument('--ptype', - help='Set the payload type ("amonet","kamakiri","kamakiri2","carbonara", kamakiri2/da used by default)') + help='Set the payload type ("amonet","kamakiri","kamakiri2","carbonara", kamakiri2/da ' + + 'used by default)') parser_gpt.add_argument('--preloader', help='Set the preloader filename for dram config') parser_gpt.add_argument('--parttype', help='Partition type\n' + '\t\tEMMC: [user, boot1, boot2, gp1, gp2, gp3, gp4, rpmb]' + @@ -259,7 +260,8 @@ if __name__ == '__main__': parser_r.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_r.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_r.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_r.add_argument('--preloader', help='Set the preloader filename for dram config') parser_r.add_argument('--parttype', help='Partition type\n' + '\t\tEMMC: [user, boot1, boot2, gp1, gp2, gp3, gp4, rpmb]' + @@ -288,7 +290,8 @@ if __name__ == '__main__': parser_rl.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_rl.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_rl.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_rl.add_argument('--preloader', help='Set the preloader filename for dram config') parser_rl.add_argument('--parttype', help='Partition type\n' + '\t\tEMMC: [user, boot1, boot2, gp1, gp2, gp3, gp4, rpmb]' + @@ -318,7 +321,8 @@ if __name__ == '__main__': parser_rf.add_argument('--da_addr', help='Set a specific da payload addr') parser_rf.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_rf.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_rf.add_argument('--preloader', help='Set the preloader filename for dram config') parser_rf.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_rf.add_argument('--parttype', help='Partition type\n' + @@ -328,7 +332,8 @@ if __name__ == '__main__': parser_rf.add_argument('--filename', help='Optional filename') parser_rf.add_argument('--crash', help='Enforce crash if device is in pl mode to enter brom mode') parser_rf.add_argument('--socid', help='Read Soc ID') - parser_rf.add_argument('--iot', help='Use special mode for iot MT6261/2301', action="store_true", default=False) + parser_rf.add_argument('--iot', help='Use special mode for iot MT6261/2301', action="store_true", + default=False) parser_rf.add_argument('--auth', type=str, help="Use auth file (auth_sv5.auth)") parser_rf.add_argument('--cert', type=str, help="Use cert file") @@ -342,7 +347,8 @@ if __name__ == '__main__': parser_rs.add_argument('--debugmode', action='store_true', default=False, help='Enable verbose mode') parser_rs.add_argument('--gpt-num-part-entries', default='0', help='Set GPT entry count') parser_rs.add_argument('--gpt-part-entry-size', default='0', help='Set GPT entry size') - parser_rs.add_argument('--gpt-part-entry-start-lba', default='0', help='Set GPT entry start lba sector') + parser_rs.add_argument('--gpt-part-entry-start-lba', default='0', + help='Set GPT entry start lba sector') parser_rs.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_rs.add_argument('--skip', help='Skip reading partition with names "partname1,partname2,etc."') parser_rs.add_argument('--skipwdt', help='Skip wdt init') @@ -353,7 +359,8 @@ if __name__ == '__main__': parser_rs.add_argument('--da_addr', help='Set a specific da payload addr') parser_rs.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_rs.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_rs.add_argument('--preloader', help='Set the preloader filename for dram config') parser_rs.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_rs.add_argument('--parttype', help='Partition type\n' + @@ -376,7 +383,8 @@ if __name__ == '__main__': parser_ro.add_argument('--debugmode', action='store_true', default=False, help='Enable verbose mode') parser_ro.add_argument('--gpt-num-part-entries', default='0', help='Set GPT entry count') parser_ro.add_argument('--gpt-part-entry-size', default='0', help='Set GPT entry size') - parser_ro.add_argument('--gpt-part-entry-start-lba', default='0', help='Set GPT entry start lba sector') + parser_ro.add_argument('--gpt-part-entry-start-lba', default='0', + help='Set GPT entry start lba sector') parser_ro.add_argument('--gpt_file', help='Use a gpt file instead of trying to read gpt from flash') parser_ro.add_argument('--skip', help='Skip reading partition with names "partname1,partname2,etc."') parser_ro.add_argument('--skipwdt', help='Skip wdt init') @@ -387,7 +395,8 @@ if __name__ == '__main__': parser_ro.add_argument('--da_addr', help='Set a specific da payload addr') parser_ro.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_ro.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_ro.add_argument('--preloader', help='Set the preloader filename for dram config') parser_ro.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_ro.add_argument('--parttype', help='Partition type\n' + @@ -398,10 +407,13 @@ if __name__ == '__main__': parser_ro.add_argument('--cert', type=str, help="Use cert file") parser_fs.add_argument('mountpoint', help='Directory to mount the FUSE filesystem in') - parser_fs.add_argument('--rw', help='Mount the filesystem as writeable', default=False, action='store_true') + parser_fs.add_argument('--rw', help='Mount the filesystem as writeable', default=False, + action='store_true') - parser_w.add_argument('partitionname', help='Partition to write (separate by comma for multiple partitions)') - parser_w.add_argument('filename', help='Filename for writing (separate by comma for multiple filenames)') + parser_w.add_argument('partitionname', + help='Partition to write (separate by comma for multiple partitions)') + parser_w.add_argument('filename', + help='Filename for writing (separate by comma for multiple filenames)') parser_w.add_argument('--loader', type=str, help='Use specific DA loader, disable autodetection') parser_w.add_argument('--vid', type=str, help='Set usb vendor id used for MTK Preloader') parser_w.add_argument('--pid', type=str, help='Set usb product id used for MTK Preloader') @@ -420,7 +432,8 @@ if __name__ == '__main__': parser_w.add_argument('--da_addr', help='Set a specific da payload addr') parser_w.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_w.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_w.add_argument('--preloader', help='Set the preloader filename for dram config') parser_w.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_w.add_argument('--parttype', help='Partition type\n' + @@ -452,7 +465,8 @@ if __name__ == '__main__': parser_wf.add_argument('--da_addr', help='Set a specific da payload addr') parser_wf.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_wf.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_wf.add_argument('--preloader', help='Set the preloader filename for dram config') parser_wf.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_wf.add_argument('--parttype', help='Partition type\n' + @@ -482,7 +496,8 @@ if __name__ == '__main__': parser_wl.add_argument('--da_addr', help='Set a specific da payload addr') parser_wl.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_wl.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ("amonet","kamakiri","kamakiri2",' + + '"carbonara" kamakiri2/da used by default)') parser_wl.add_argument('--preloader', help='Set the preloader filename for dram config') parser_wl.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_wl.add_argument('--parttype', help='Partition type\n' + @@ -515,7 +530,8 @@ if __name__ == '__main__': parser_wo.add_argument('--da_addr', help='Set a specific da payload addr') parser_wo.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_wo.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" ' + + 'kamakiri2/da used by default)') parser_wo.add_argument('--preloader', help='Set the preloader filename for dram config') parser_wo.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_wo.add_argument('--parttype', help='Partition type\n' + @@ -546,7 +562,8 @@ if __name__ == '__main__': parser_e.add_argument('--da_addr', help='Set a specific da payload addr') parser_e.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_e.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" ' + + 'kamakiri2/da used by default)') parser_e.add_argument('--preloader', help='Set the preloader filename for dram config') parser_e.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_e.add_argument('--parttype', help='Partition type\n' + @@ -578,7 +595,8 @@ if __name__ == '__main__': parser_es.add_argument('--da_addr', help='Set a specific da payload addr') parser_es.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_es.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_es.add_argument('--preloader', help='Set the preloader filename for dram config') parser_es.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_es.add_argument('--parttype', help='Partition type\n' + @@ -610,7 +628,8 @@ if __name__ == '__main__': parser_ess.add_argument('--da_addr', help='Set a specific da payload addr') parser_ess.add_argument('--brom_addr', help='Set a specific brom payload addr') parser_ess.add_argument('--ptype', - help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da used by default)') + help='Set the payload type ( "amonet","kamakiri","kamakiri2","carbonara" kamakiri2/da ' + + 'used by default)') parser_ess.add_argument('--preloader', help='Set the preloader filename for dram config') parser_ess.add_argument('--verifystage2', help='Verify if stage2 data has been written correctly') parser_ess.add_argument('--parttype', help='Partition type\n' + @@ -872,21 +891,36 @@ if __name__ == '__main__': parser_gpt.add_argument('--generatekeys', action="store_true", help='Option for deriving hw keys') parser_r.add_argument('--generatekeys', action="store_true", help='Option for deriving hw keys') - parser_printgpt.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_footer.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_e.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_es.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_wl.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_wf.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_w.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_rs.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_rf.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_rl.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_gpt.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_r.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_reset.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_payload.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') - parser_script.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', action='store', type=str, nargs='?') + parser_printgpt.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_footer.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_e.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_es.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_wl.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_wf.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_w.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_rs.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_rf.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_rl.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_gpt.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_r.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_reset.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_payload.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') + parser_script.add_argument('--serialport', help='Use serial port', default=None, const='DETECT', + action='store', type=str, nargs='?') parser_script.add_argument('--noreconnect', action="store_true", help='Disable reconnect') parser_printgpt.add_argument('--noreconnect', action="store_true", help='Disable reconnect') diff --git a/mtk_gui.py b/mtk_gui.py index af29202..a9cab97 100755 --- a/mtk_gui.py +++ b/mtk_gui.py @@ -15,16 +15,17 @@ from PySide6.QtWidgets import QMainWindow, QApplication, QWidget, QCheckBox, QVB QPushButton from mtkclient.Library.mtk_class import Mtk -from mtkclient.Library.DA.mtk_da_handler import DA_handler -from mtkclient.Library.gpt import gpt_settings -from mtkclient.Library.mtk_main import Main, Mtk_Config +from mtkclient.Library.DA.mtk_da_handler import DaHandler +from mtkclient.Library.gpt import GptSettings +from mtkclient.Library.mtk_main import Main +from mtkclient.config.mtk_config import MtkConfig from mtkclient.gui.readFlashPartitions import ReadFlashWindow from mtkclient.gui.writeFlashPartitions import WriteFlashWindow from mtkclient.gui.eraseFlashPartitions import EraseFlashWindow from mtkclient.gui.toolsMenu import generateKeysMenu, UnlockMenu from mtkclient.gui.toolkit import asyncThread, trap_exc_during_debug, convert_size, CheckBox, FDialog, TimeEstim -from mtkclient.config.payloads import pathconfig +from mtkclient.config.payloads import PathConfig from mtkclient.gui.main_gui import Ui_MainWindow import os @@ -39,7 +40,7 @@ sys.excepthook = trap_exc_during_debug variables = mock.Mock() variables.cmd = "stage" variables.debugmode = True -path = pathconfig() +path = PathConfig() # if sys.platform.startswith('darwin'): # config.ptype = "kamakiri" #Temp for Mac testing MtkTool = Main(variables) @@ -56,47 +57,47 @@ class DeviceHandler(QObject): def __init__(self, parent, preloader: str = None, loglevel=logging.INFO, *args, **kwargs): super().__init__(parent, *args, **kwargs) - config = Mtk_Config(loglevel=logging.INFO, gui=self.sendToLogSignal, guiprogress=self.sendToProgressSignal, - update_status_text=self.update_status_text) - config.gpt_settings = gpt_settings(gpt_num_part_entries='0', gpt_part_entry_size='0', - gpt_part_entry_start_lba='0') # This actually sets the right GPT settings.. + config = MtkConfig(loglevel=logging.INFO, gui=self.sendToLogSignal, guiprogress=self.sendToProgressSignal, + update_status_text=self.update_status_text) + config.gpt_settings = GptSettings(gpt_num_part_entries='0', gpt_part_entry_size='0', + gpt_part_entry_start_lba='0') # This actually sets the right GPT settings.. config.reconnect = True config.uartloglevel = 2 self.loglevel = logging.DEBUG - self.da_handler = DA_handler(Mtk(config=config, loglevel=logging.INFO), loglevel) + self.da_handler = DaHandler(Mtk(config=config, loglevel=logging.INFO), loglevel) def getDevInfo(self, parameters): # loglevel = parameters[0] - phoneInfo = parameters[1] - devhandler = parameters[2] + phone_info = parameters[1] + _devhandler = parameters[2] - mtkClass = devhandler.da_handler.mtk - da_handler = devhandler.da_handler + mtk_class = _devhandler.da_handler.mtk + da_handler = _devhandler.da_handler try: - if not mtkClass.port.cdc.connect(): - mtkClass.preloader.init() + if not mtk_class.port.cdc.connect(): + mtk_class.preloader.init() else: - phoneInfo['cdcInit'] = True + phone_info['cdcInit'] = True except Exception: - phoneInfo['cantConnect'] = True - phoneInfo['chipset'] = (str(mtkClass.config.chipconfig.name) + " (" + str(mtkClass.config.chipconfig.description) + - ")") + phone_info['cantConnect'] = True + phone_info['chipset'] = (str(mtk_class.config.chipconfig.name) + + " (" + str(mtk_class.config.chipconfig.description) + ")") self.sendUpdateSignal.emit() - mtkClass = da_handler.configure_da(mtkClass, preloader=None) - if mtkClass: - phoneInfo['daInit'] = True - phoneInfo['chipset'] = (str(mtkClass.config.chipconfig.name) + " (" + - str(mtkClass.config.chipconfig.description) + ")") - if mtkClass.config.is_brom: - phoneInfo['bootMode'] = "Bootrom mode" - elif mtkClass.config.chipconfig.damode: - phoneInfo['bootMode'] = "DA mode" + mtk_class = da_handler.configure_da(mtk_class, preloader=None) + if mtk_class: + phone_info['daInit'] = True + phone_info['chipset'] = (str(mtk_class.config.chipconfig.name) + + " (" + str(mtk_class.config.chipconfig.description) + ")") + if mtk_class.config.is_brom: + phone_info['bootMode'] = "Bootrom mode" + elif mtk_class.config.chipconfig.damode: + phone_info['bootMode'] = "DA mode" else: - phoneInfo['bootMode'] = "Preloader mode" + phone_info['bootMode'] = "Preloader mode" self.sendUpdateSignal.emit() else: - phoneInfo['cantConnect'] = True + phone_info['cantConnect'] = True self.sendUpdateSignal.emit() @@ -124,6 +125,7 @@ def load_translations(application): class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() + self.readpartitionCheckboxes = None self.ui = Ui_MainWindow() self.ui.setupUi(self) self.fdialog = FDialog(self) @@ -153,39 +155,45 @@ class MainWindow(QMainWindow): def updateState(self): global lock lock.acquire() - doneBytes = 0 - curpartBytes = self.Status[f"currentPartitionSize{'Done' if 'currentPartitionSizeDone' in self.Status else ''}"] + done_bytes = 0 + curpart_bytes = ( + self.Status)[f"currentPartitionSize{'Done' if 'currentPartitionSizeDone' in self.Status else ''}"] if "allPartitions" in self.Status: for partition in self.Status["allPartitions"]: if self.Status["allPartitions"][partition]['done'] and partition != self.Status["currentPartition"]: - doneBytes = doneBytes + self.Status["allPartitions"][partition]['size'] - doneBytes = curpartBytes + doneBytes - totalBytes = self.Status["totalsize"] - fullPercentageDone = int((doneBytes / totalBytes) * 100) - self.ui.fullProgress.setValue(fullPercentageDone) - timeinfototal = self.timeEstTotal.update(fullPercentageDone, 100) - self.ui.fullProgressText.setText(f"
Total: {convert_size(doneBytes)} / {convert_size(totalBytes)} | {timeinfototal}{QCoreApplication.translate('main', ' left')} |
Total: " + + f"{convert_size(done_bytes)} / {convert_size(total_bytes)}" + + f" | {timeinfototal}" + + f"{QCoreApplication.translate('main', ' left')}" + + f" |
Total: " + - convert_size(doneBytes) + " / " + convert_size(partBytes) + + convert_size(done_bytes) + " / " + convert_size(part_bytes) + " | " + timeinfototal + QCoreApplication.translate("main", " left") + " |
Current partition: " + self.Status["currentPartition"] + \ - " (" + convert_size(curpartBytes) + " / " + convert_size(partBytes) + ") | " + \ - timeinfo + QCoreApplication.translate("main", " left") + " |
Current partition: " + self.Status["currentPartition"] + + " (" + convert_size(curpart_bytes) + " / " + convert_size(part_bytes) + + ") | " + + timeinfo + QCoreApplication.translate("main", " left") + " |
0xffffffff else "x86"))) -from fuse import Operations, LoggingMixIn + os.environ.setdefault('FUSE_LIBRARY_PATH', + os.path.join(os.path.dirname(__file__), + r"bin\winfsp-%s.dll" % ("x64" if sys.maxsize > 0xffffffff else "x86"))) class MtkDaFS(LoggingMixIn, Operations): diff --git a/mtkclient/Library/Hardware/cqdma.py b/mtkclient/Library/Hardware/cqdma.py index 93884bc..5c6093e 100755 --- a/mtkclient/Library/Hardware/cqdma.py +++ b/mtkclient/Library/Hardware/cqdma.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import logging import os from struct import pack, unpack @@ -21,7 +21,7 @@ regval = { } -class cqdma_reg: +class CqdmaReg: def __init__(self, setup): self.cqdma_base = setup.cqdma_base self.read32 = setup.read32 @@ -29,25 +29,26 @@ class cqdma_reg: def __setattr__(self, key, value): if key in ("cqdma_base", "read32", "write32", "regval"): - return super(cqdma_reg, self).__setattr__(key, value) + return super(CqdmaReg, self).__setattr__(key, value) if key in regval: addr = regval[key] + self.cqdma_base return self.write32(addr, value) else: - return super(cqdma_reg, self).__setattr__(key, value) + return super(CqdmaReg, self).__setattr__(key, value) def __getattribute__(self, item): if item in ("cqdma_base", "read32", "write32", "regval"): - return super(cqdma_reg, self).__getattribute__(item) + return super(CqdmaReg, self).__getattribute__(item) if item in regval: addr = regval[item] + self.cqdma_base return self.read32(addr) else: - return super(cqdma_reg, self).__getattribute__(item) + return super(CqdmaReg, self).__getattribute__(item) -class cqdma(metaclass=LogBase): +class Cqdma(metaclass=LogBase): def __init__(self, setup, loglevel=logging.INFO): + self.chipconfig = None self.setup = setup self.hwcode = setup.hwcode self.__logger = self.__logger @@ -56,7 +57,7 @@ class cqdma(metaclass=LogBase): self.info = self.__logger.info self.cqdma_base = setup.cqdma_base self.ap_dma_mem = setup.ap_dma_mem - self.reg = cqdma_reg(setup) + self.reg = CqdmaReg(setup) if loglevel == logging.DEBUG: logfilename = os.path.join("logs", "log.txt") fh = logging.FileHandler(logfilename, encoding='utf-8') diff --git a/mtkclient/Library/Hardware/hwcrypto.py b/mtkclient/Library/Hardware/hwcrypto.py index 850444c..b6ad2bf 100755 --- a/mtkclient/Library/Hardware/hwcrypto.py +++ b/mtkclient/Library/Hardware/hwcrypto.py @@ -1,17 +1,17 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import logging import sys from mtkclient.Library.utils import LogBase, logsetup from mtkclient.Library.Hardware.hwcrypto_gcpu import GCpu -from mtkclient.Library.Hardware.hwcrypto_dxcc import dxcc -from mtkclient.Library.Hardware.hwcrypto_sej import sej -from mtkclient.Library.Hardware.cqdma import cqdma +from mtkclient.Library.Hardware.hwcrypto_dxcc import Dxcc +from mtkclient.Library.Hardware.hwcrypto_sej import Sej +from mtkclient.Library.Hardware.cqdma import Cqdma -class crypto_setup: +class CryptoSetup: hwcode = None dxcc_base = None gcpu_base = None @@ -29,13 +29,13 @@ class crypto_setup: efuse_base = None -class hwcrypto(metaclass=LogBase): +class HwCrypto(metaclass=LogBase): def __init__(self, setup, loglevel=logging.INFO, gui: bool = False): - self.__logger = logsetup(self, self.__logger, loglevel, gui) - self.dxcc = dxcc(setup, loglevel, gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, loglevel, gui) + self.dxcc = Dxcc(setup, loglevel, gui) self.gcpu = GCpu(setup, loglevel, gui) - self.sej = sej(setup, loglevel) - self.cqdma = cqdma(setup, loglevel) + self.sej = Sej(setup, loglevel) + self.cqdma = Cqdma(setup, loglevel) self.hwcode = setup.hwcode self.setup = setup self.read32 = setup.read32 @@ -62,7 +62,7 @@ class hwcrypto(metaclass=LogBase): elif mode == "sst": self.sej.sej_base = 0xC0016000 data2 = self.sej.generate_hw_meta(encrypt=True, data=data) - data3 = self.sej.SST_Secure_Algo_With_Level(buf=data, encrypt=True) + data3 = self.sej.sst_secure_algo_with_level(buf=data, encrypt=True) print(data2.hex()) print(data3.hex()) sys.stdout.flush() @@ -72,7 +72,7 @@ class hwcrypto(metaclass=LogBase): return self.sej.hw_aes128_cbc_encrypt(buf=data, encrypt=False) elif mode == "sst": self.sej.sej_base = 0xC0016000 - data3 = self.sej.SST_Secure_Algo_With_Level(buf=data[:0x20], encrypt=False, aes_top_legacy=False) + data3 = self.sej.sst_secure_algo_with_level(buf=data[:0x20], encrypt=False, aes_top_legacy=False) print(data3.hex()) sys.stdout.flush() if mode == "rpmb": diff --git a/mtkclient/Library/Hardware/hwcrypto_dxcc.py b/mtkclient/Library/Hardware/hwcrypto_dxcc.py index cc5a3c3..2f1d016 100755 --- a/mtkclient/Library/Hardware/hwcrypto_dxcc.py +++ b/mtkclient/Library/Hardware/hwcrypto_dxcc.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License # DXCC = Discretix CryptoCell @@ -584,7 +584,7 @@ class DescDirection: DESC_DIRECTION_END = INT32_MAX -class sep_engine_type: +class SepEngineType: SEP_ENGINE_NULL = 0 SEP_ENGINE_AES = 1 SEP_ENGINE_DES = 2 @@ -593,7 +593,7 @@ class sep_engine_type: SEP_ENGINE_DOUT = 5 -class sep_crypto_alg: +class SepCryptoAlg: SEP_CRYPTO_ALG_NULL = 0xFFFFFFFF SEP_CRYPTO_ALG_AES = 0 SEP_CRYPTO_ALG_DES = 1 @@ -608,7 +608,7 @@ class sep_crypto_alg: SEP_CRYPTO_ALG_RESERVE32B = INT32_MAX -class sep_crypto_direction: +class SepCryptoDirection: SEP_CRYPTO_DIRECTION_NULL = 0xFFFFFFFF SEP_CRYPTO_DIRECTION_ENCRYPT = 0 SEP_CRYPTO_DIRECTION_DECRYPT = 1 @@ -616,7 +616,7 @@ class sep_crypto_direction: SEP_CRYPTO_DIRECTION_RESERVE32B = INT32_MAX -class sep_cipher_mode: +class SepCipherMode: SEP_CIPHER_NULL_MODE = 0xFFFFFFFF SEP_CIPHER_ECB = 0 SEP_CIPHER_CBC = 1 @@ -632,7 +632,7 @@ class sep_cipher_mode: SEP_CIPHER_RESERVE32B = INT32_MAX -class sep_hash_mode: +class SepHashMode: SEP_HASH_NULL = 0xFFFFFFFF SEP_HASH_SHA1 = 0 SEP_HASH_SHA256 = 1 @@ -647,7 +647,7 @@ class sep_hash_mode: SEP_HASH_RESERVE32B = INT32_MAX -class sep_hash_hw_mode: +class SepHashHwMode: SEP_HASH_HW_MD5 = 0 SEP_HASH_HW_SHA1 = 1 SEP_HASH_HW_SHA256 = 2 @@ -658,14 +658,14 @@ class sep_hash_hw_mode: SEP_HASH_HW_RESERVE32B = INT32_MAX -class sep_c2_mode: +class SepC2Mode: SEP_C2_NULL = 0xFFFFFFFF SEP_C2_ECB = 0 SEP_C2_CBC = 1 SEP_C2_RESERVE32B = INT32_MAX -class sep_multi2_mode: +class SepMulti2Mode: SEP_MULTI2_NULL = 0xFFFFFFFF SEP_MULTI2_ECB = 0 SEP_MULTI2_CBC = 1 @@ -673,7 +673,7 @@ class sep_multi2_mode: SEP_MULTI2_RESERVE32B = INT32_MAX -class sep_crypto_key_type: +class SepCryptoKeyType: SEP_USER_KEY = 0 SEP_ROOT_KEY = 1 SEP_PROVISIONING_KEY = 2 @@ -875,129 +875,129 @@ def tovalue(value, bitsize, shift): return v << shift -def hw_desc_set_cipher_mode(pDesc, cipherMode): +def hw_desc_set_cipher_mode(p_desc, cipher_mode): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["CIPHER_MODE"] - pDesc[4] |= tovalue(cipherMode, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(cipher_mode, bitsize, shift) + return p_desc -def hw_desc_set_cipher_config0(pDesc, cipherConfig): +def hw_desc_set_cipher_config0(p_desc, cipher_config): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["CIPHER_CONF0"] - pDesc[4] |= tovalue(cipherConfig, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(cipher_config, bitsize, shift) + return p_desc -def hw_desc_set_cipher_config1(pDesc, cipherConfig): +def hw_desc_set_cipher_config1(p_desc, cipher_config): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["CIPHER_CONF1"] - pDesc[4] |= tovalue(cipherConfig, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(cipher_config, bitsize, shift) + return p_desc -def hw_desc_set_setup_mode(pDesc, setupMode): +def hw_desc_set_setup_mode(p_desc, setup_mode): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["SETUP_OPERATION"] - pDesc[4] |= tovalue(setupMode, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(setup_mode, bitsize, shift) + return p_desc -def hw_desc_set_flow_mode(pDesc, flowMode): +def hw_desc_set_flow_mode(p_desc, flow_mode): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["DATA_FLOW_MODE"] - pDesc[4] |= tovalue(flowMode, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(flow_mode, bitsize, shift) + return p_desc -def hw_desc_set_dout_sram(pDesc, doutAdr, doutSize): +def hw_desc_set_dout_sram(p_desc, dout_adr, dout_size): v = DSCRPTR["DSCRPTR_QUEUE0_WORD2"] shift, bitsize = v[1], v[2] - pDesc[2] |= tovalue((doutAdr & 0xFFFFFFFF), bitsize, shift) + p_desc[2] |= tovalue((dout_adr & 0xFFFFFFFF), bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["DOUT_DMA_MODE"] - pDesc[3] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) + p_desc[3] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["DOUT_SIZE"] - pDesc[3] |= tovalue(doutSize, bitsize, shift) - return pDesc + p_desc[3] |= tovalue(dout_size, bitsize, shift) + return p_desc -def hw_desc_set_dout_dlli(pDesc, doutAdr, doutSize, axiNs, lastind): +def hw_desc_set_dout_dlli(p_desc, dout_adr, dout_size, axi_ns, lastind): v = DSCRPTR["DSCRPTR_QUEUE0_WORD2"] shift, bitsize = v[1], v[2] - pDesc[2] |= tovalue((doutAdr & 0xFFFFFFFF), bitsize, shift) + p_desc[2] |= tovalue((dout_adr & 0xFFFFFFFF), bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD5"][1]["DOUT_ADDR_HIGH"] - pDesc[5] |= tovalue((doutAdr >> 32 & 0xFFFFFFFF) << 16, bitsize, shift) + p_desc[5] |= tovalue((dout_adr >> 32 & 0xFFFFFFFF) << 16, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["DOUT_DMA_MODE"] - pDesc[3] |= tovalue(DmaMode.DMA_DLLI, bitsize, shift) + p_desc[3] |= tovalue(DmaMode.DMA_DLLI, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["DOUT_SIZE"] - pDesc[3] |= tovalue(doutSize, bitsize, shift) + p_desc[3] |= tovalue(dout_size, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["DOUT_LAST_IND"] - pDesc[3] |= tovalue(lastind, bitsize, shift) + p_desc[3] |= tovalue(lastind, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD3"][1]["NS_BIT"] - pDesc[3] |= tovalue(lastind, bitsize, shift) - return pDesc + p_desc[3] |= tovalue(lastind, bitsize, shift) + return p_desc -def hw_desc_set_key_size_aes(pDesc, keySize): +def hw_desc_set_key_size_aes(p_desc, key_size): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["KEY_SIZE"] - pDesc[4] |= tovalue(((keySize >> 3) - 2), bitsize, shift) - return pDesc + p_desc[4] |= tovalue(((key_size >> 3) - 2), bitsize, shift) + return p_desc -def hw_desc_set_din_sram(pDesc, dinAdr, dinSize): +def hw_desc_set_din_sram(p_desc, din_adr, din_size): v = DSCRPTR["DSCRPTR_QUEUE0_WORD0"] shift, bitsize = v[1], v[2] - pDesc[0] |= tovalue(dinAdr & 0xFFFFFFFF, bitsize, shift) + p_desc[0] |= tovalue(din_adr & 0xFFFFFFFF, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_DMA_MODE"] - pDesc[1] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) + p_desc[1] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_SIZE"] - pDesc[1] |= tovalue(dinSize, bitsize, shift) - return pDesc + p_desc[1] |= tovalue(din_size, bitsize, shift) + return p_desc -def hw_desc_set_din_const(pDesc, val, dinSize): +def hw_desc_set_din_const(p_desc, val, din_size): v = DSCRPTR["DSCRPTR_QUEUE0_WORD0"] shift, bitsize = v[1], v[2] - pDesc[0] |= tovalue(val & 0xFFFFFFFF, bitsize, shift) + p_desc[0] |= tovalue(val & 0xFFFFFFFF, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_CONST_VALUE"] - pDesc[1] |= tovalue(1, bitsize, shift) + p_desc[1] |= tovalue(1, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_DMA_MODE"] - pDesc[1] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) + p_desc[1] |= tovalue(DmaMode.DMA_SRAM, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_SIZE"] - pDesc[1] |= tovalue(dinSize, bitsize, shift) - return pDesc + p_desc[1] |= tovalue(din_size, bitsize, shift) + return p_desc -def hw_desc_set_cipher_do(pDesc, cipherDo): +def hw_desc_set_cipher_do(p_desc, cipher_do): shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD4"][1]["CIPHER_DO"] - pDesc[4] |= tovalue(cipherDo, bitsize, shift) - return pDesc + p_desc[4] |= tovalue(cipher_do, bitsize, shift) + return p_desc -def hw_desc_set_din_nodma(pDesc, dinAdr, dinSize): +def hw_desc_set_din_nodma(p_desc, din_adr, din_size): v = DSCRPTR["DSCRPTR_QUEUE0_WORD0"] shift, bitsize = v[1], v[2] - pDesc[0] |= tovalue(dinAdr & 0xFFFFFFFF, bitsize, shift) + p_desc[0] |= tovalue(din_adr & 0xFFFFFFFF, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_DMA_MODE"] - pDesc[1] |= tovalue(DmaMode.NO_DMA, bitsize, shift) + p_desc[1] |= tovalue(DmaMode.NO_DMA, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_SIZE"] - pDesc[1] |= tovalue(dinSize, bitsize, shift) - return pDesc + p_desc[1] |= tovalue(din_size, bitsize, shift) + return p_desc -def hw_desc_set_din_type(pDesc, dmaMode, dinAdr, dinSize, axiId, axiNs): +def hw_desc_set_din_type(p_desc, dma_mode, din_adr, din_size, axi_id, axi_ns): v = DSCRPTR["DSCRPTR_QUEUE0_WORD0"] shift, bitsize = v[1], v[2] - pDesc[0] |= tovalue(dinAdr & 0xFFFFFFFF, bitsize, shift) + p_desc[0] |= tovalue(din_adr & 0xFFFFFFFF, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD5"][1]["DIN_ADDR_HIGH"] - pDesc[5] |= tovalue(dinAdr >> 32 & 0xFFFF, bitsize, shift) + p_desc[5] |= tovalue(din_adr >> 32 & 0xFFFF, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_DMA_MODE"] - pDesc[1] |= tovalue(dmaMode, bitsize, shift) + p_desc[1] |= tovalue(dma_mode, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_SIZE"] - pDesc[1] |= tovalue(dinSize, bitsize, shift) + p_desc[1] |= tovalue(din_size, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["DIN_VIRTUAL_HOST"] - pDesc[1] |= tovalue(axiId, bitsize, shift) + p_desc[1] |= tovalue(axi_id, bitsize, shift) shift, bitsize = DSCRPTR["DSCRPTR_QUEUE0_WORD1"][1]["NS_BIT"] - pDesc[1] |= tovalue(axiNs, bitsize, shift) - return pDesc + p_desc[1] |= tovalue(axi_ns, bitsize, shift) + return p_desc -class dxcc_reg: +class DxccReg: def __init__(self, setup): self.dxcc_base = setup.dxcc_base self.read32 = setup.read32 @@ -1005,24 +1005,24 @@ class dxcc_reg: def __setattr__(self, key, value): if key in ("sej_base", "read32", "write32", "regval"): - return super(dxcc_reg, self).__setattr__(key, value) + return super(DxccReg, self).__setattr__(key, value) if key in regval: addr = regval[key] + self.sej_base return self.write32(addr, value) else: - return super(dxcc_reg, self).__setattr__(key, value) + return super(DxccReg, self).__setattr__(key, value) def __getattribute__(self, item): if item in ("sej_base", "read32", "write32", "regval"): - return super(dxcc_reg, self).__getattribute__(item) + return super(DxccReg, self).__getattribute__(item) if item in regval: addr = regval[item] + self.sej_base return self.read32(addr) else: - return super(dxcc_reg, self).__getattribute__(item) + return super(DxccReg, self).__getattribute__(item) -class dxcc(metaclass=LogBase): +class Dxcc(metaclass=LogBase): DX_HOST_IRR = 0xA00 DX_HOST_ICR = 0xA08 # DX_CC = (HOST_RGF, HOST_ICR) DX_DSCRPTR_QUEUE0_WORD0 = 0xE80 @@ -1038,10 +1038,10 @@ class dxcc(metaclass=LogBase): DX_HOST_SEP_HOST_GPR3 = 0xA9C DX_HOST_SEP_HOST_GPR4 = 0xAA0 - def SB_HalClearInterruptBit(self): + def sb_hal_clear_interrupt_bit(self): self.write32(self.dxcc_base + self.DX_HOST_ICR, 4) - def SB_CryptoWait(self): + def sb_crypto_wait(self): while True: value = self.read32(self.dxcc_base + self.DX_HOST_IRR) if value != 0: @@ -1067,7 +1067,7 @@ class dxcc(metaclass=LogBase): self.write32(self.dxcc_base + self.DX_DSCRPTR_QUEUE0_WORD5, data[5]) def __init__(self, setup, loglevel=logging.INFO, gui: bool = False): - self.__logger = logsetup(self, self.__logger, loglevel, gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, loglevel, gui) self.hwcode = setup.hwcode self.dxcc_base = setup.dxcc_base self.read32 = setup.read32 @@ -1075,7 +1075,7 @@ class dxcc(metaclass=LogBase): self.writemem = setup.writemem self.da_payload_addr = setup.da_payload_addr - self.reg = dxcc_reg(setup) + self.reg = DxccReg(setup) def tzcc_clk(self, value): if value: @@ -1091,7 +1091,7 @@ class dxcc(metaclass=LogBase): for ctr in range(0, key_sz // 16): itrustee = b"TrustedCorekeymaster" + b"\x07" * 0x10 + appid seed = itrustee + pack(" 4 or (1 << (aeskeytype - 1) & 0x17) == 0: return 0xF2000002 @@ -1192,36 +1192,36 @@ class dxcc(metaclass=LogBase): bufferlen = len(salt) + 3 + len(label) iterlength = (requestedlen + 0xF) >> 4 for i in range(0, iterlength): - buffer = pack("> 32) << 16) # 5 self.sasi_sb_adddescsequence(data) while True: - if self.SB_CryptoWait() & 4 != 0: + if self.sb_crypto_wait() & 4 != 0: break while True: value = self.read32(self.dxcc_base + 0xBA0) if value != 0: break if value == 1: - self.SB_HalClearInterruptBit() + self.sb_hal_clear_interrupt_bit() self.sasi_paldmaunmap(val) return 0 else: return 0xF6000001 - def SBROM_AesCmacDriver(self, aesKeyType, pInternalKey, pDataIn, dmaMode, blockSize, pDataOut): - ivSramAddr = 0 - if aesKeyType == HwCryptoKey.ROOT_KEY: + def sbrom_aes_cmac_driver(self, aes_key_type, p_internal_key, p_data_in, dma_mode, block_size, p_data_out): + iv_sram_addr = 0 + if aes_key_type == HwCryptoKey.ROOT_KEY: if self.read32(self.dxcc_base + self.DX_HOST_SEP_HOST_GPR4) & 2 != 0: - keySizeInBytes = 0x20 # SEP_AES_256_BIT_KEY_SIZE + key_size_in_bytes = 0x20 # SEP_AES_256_BIT_KEY_SIZE else: - keySizeInBytes = 0x10 # SEP_AES_128_BIT_KEY_SIZE + key_size_in_bytes = 0x10 # SEP_AES_128_BIT_KEY_SIZE else: - keySizeInBytes = 0x10 # SEP_AES_128_BIT_KEY_SIZE - self.SB_HalInit() + key_size_in_bytes = 0x10 # SEP_AES_128_BIT_KEY_SIZE + self.sb_hal_init() pdesc = hw_desc_init() - pdesc = hw_desc_set_cipher_mode(pdesc, sep_cipher_mode.SEP_CIPHER_CMAC) # desc[4]=0x1C00 + pdesc = hw_desc_set_cipher_mode(pdesc, SepCipherMode.SEP_CIPHER_CMAC) # desc[4]=0x1C00 pdesc = hw_desc_set_cipher_config0(pdesc, DescDirection.DESC_DIRECTION_ENCRYPT_ENCRYPT) - pdesc = hw_desc_set_key_size_aes(pdesc, keySizeInBytes) # desc[4]=0x801C00 - pdesc = hw_desc_set_din_sram(pdesc, ivSramAddr, AES_IV_COUNTER_SIZE_IN_BYTES) + pdesc = hw_desc_set_key_size_aes(pdesc, key_size_in_bytes) # desc[4]=0x801C00 + pdesc = hw_desc_set_din_sram(pdesc, iv_sram_addr, AES_IV_COUNTER_SIZE_IN_BYTES) pdesc = hw_desc_set_din_const(pdesc, 0, AES_IV_COUNTER_SIZE_IN_BYTES) # desc[1]=0x8000041 pdesc = hw_desc_set_flow_mode(pdesc, FlowMode.S_DIN_to_AES) # desc[4]=0x801C20 pdesc = hw_desc_set_setup_mode(pdesc, SetupOp.SETUP_LOAD_STATE0) # desc[4]=0x1801C20 @@ -1268,43 +1268,43 @@ class dxcc(metaclass=LogBase): # Load key mdesc = hw_desc_init() - if aesKeyType == HwCryptoKey.USER_KEY: - keySramAddr = pInternalKey - mdesc = hw_desc_set_din_sram(mdesc, keySramAddr, AES_Key128Bits_SIZE_IN_BYTES) - mdesc = hw_desc_set_cipher_do(mdesc, aesKeyType) # desc[4]=0x8000 - mdesc = hw_desc_set_cipher_mode(mdesc, sep_cipher_mode.SEP_CIPHER_CMAC) # desc[4]=0x9C00 + if aes_key_type == HwCryptoKey.USER_KEY: + key_sram_addr = p_internal_key + mdesc = hw_desc_set_din_sram(mdesc, key_sram_addr, AES_Key128Bits_SIZE_IN_BYTES) + mdesc = hw_desc_set_cipher_do(mdesc, aes_key_type) # desc[4]=0x8000 + mdesc = hw_desc_set_cipher_mode(mdesc, SepCipherMode.SEP_CIPHER_CMAC) # desc[4]=0x9C00 mdesc = hw_desc_set_cipher_config0(mdesc, DescDirection.DESC_DIRECTION_ENCRYPT_ENCRYPT) - mdesc = hw_desc_set_key_size_aes(mdesc, keySizeInBytes) # desc[4]=0x809C00 + mdesc = hw_desc_set_key_size_aes(mdesc, key_size_in_bytes) # desc[4]=0x809C00 mdesc = hw_desc_set_flow_mode(mdesc, FlowMode.S_DIN_to_AES) # desc[4]=0x809C20 mdesc = hw_desc_set_setup_mode(mdesc, SetupOp.SETUP_LOAD_KEY0) # desc[4]=0x4809C20 - mdesc[4] |= ((aesKeyType >> 2) & 3) << 20 + mdesc[4] |= ((aes_key_type >> 2) & 3) << 20 self.sasi_sb_adddescsequence(mdesc) # Process input data rdesc = hw_desc_init() - if dmaMode == DmaMode.DMA_SRAM: - rdesc = hw_desc_set_din_sram(rdesc, pDataIn, blockSize) + if dma_mode == DmaMode.DMA_SRAM: + rdesc = hw_desc_set_din_sram(rdesc, p_data_in, block_size) else: - rdesc = hw_desc_set_din_type(rdesc, DmaMode.DMA_DLLI, pDataIn, blockSize, SB_AXI_ID, + rdesc = hw_desc_set_din_type(rdesc, DmaMode.DMA_DLLI, p_data_in, block_size, SB_AXI_ID, AXI_SECURE) # desc[1]=0x3E, desc[0]=0x200E18 rdesc = hw_desc_set_flow_mode(rdesc, FlowMode.DIN_AES_DOUT) # desc[4]=1 self.sasi_sb_adddescsequence(rdesc) - if aesKeyType != HwCryptoKey.PROVISIONING_KEY: + if aes_key_type != HwCryptoKey.PROVISIONING_KEY: xdesc = hw_desc_init() - xdesc = hw_desc_set_cipher_mode(xdesc, sep_cipher_mode.SEP_CIPHER_CMAC) # desc[4]=0x1C00 + xdesc = hw_desc_set_cipher_mode(xdesc, SepCipherMode.SEP_CIPHER_CMAC) # desc[4]=0x1C00 xdesc = hw_desc_set_cipher_config0(xdesc, DescDirection.DESC_DIRECTION_ENCRYPT_ENCRYPT) xdesc = hw_desc_set_setup_mode(xdesc, SetupOp.SETUP_WRITE_STATE0) # desc[4]=0x8001C00 xdesc = hw_desc_set_flow_mode(xdesc, FlowMode.S_AES_to_DOUT) # desc[4]=0x8001C26 - if dmaMode == DmaMode.DMA_SRAM: - xdesc = hw_desc_set_dout_sram(xdesc, pDataOut, AES_BLOCK_SIZE_IN_BYTES) + if dma_mode == DmaMode.DMA_SRAM: + xdesc = hw_desc_set_dout_sram(xdesc, p_data_out, AES_BLOCK_SIZE_IN_BYTES) else: - xdesc = hw_desc_set_dout_dlli(xdesc, pDataOut, AES_BLOCK_SIZE_IN_BYTES, SB_AXI_ID, + xdesc = hw_desc_set_dout_dlli(xdesc, p_data_out, AES_BLOCK_SIZE_IN_BYTES, SB_AXI_ID, 0) # desc[2]=0x200E08, desc[3]=0x42 # xdesc = hw_desc_set_din_sram(xdesc, 0, 0) xdesc = hw_desc_set_din_nodma(xdesc, 0, 0) self.sasi_sb_adddescsequence(xdesc) - return self.SB_HalWaitDescCompletion() == 0 + return self.sb_hal_wait_desc_completion() == 0 @staticmethod def mtee_decrypt(data): @@ -1319,16 +1319,16 @@ class dxcc(metaclass=LogBase): ctr = Counter.new(128, initial_value=bytes_to_long(iv)) return AES.new(key=key, counter=ctr, mode=AES.MODE_CTR).decrypt(data) - def sbrom_sha256(self, buffer, destaddr): # TZCC_SHA256_Init + def sbrom_sha256(self, _buffer, destaddr): # TZCC_SHA256_Init dataptr = destaddr + 0x40 ivptr = destaddr + 0x20 outptr = destaddr self.writemem(0x1000108C, pack("= 1: mdesc = hw_desc_init() - mdesc = hw_desc_set_cipher_mode(mdesc, sep_cipher_mode.SEP_CIPHER_CTR) + mdesc = hw_desc_set_cipher_mode(mdesc, SepCipherMode.SEP_CIPHER_CTR) mdesc = hw_desc_set_setup_mode(mdesc, SetupOp.SETUP_LOAD_STATE1) mdesc = hw_desc_set_flow_mode(mdesc, FlowMode.S_DIN_to_AES) mdesc = hw_desc_set_dout_dlli(mdesc, 0, AES_BLOCK_SIZE_IN_BYTES, SB_AXI_ID, @@ -1370,16 +1370,16 @@ class dxcc(metaclass=LogBase): self.sasi_sb_adddescsequence(mdesc) mdesc2 = hw_desc_init() - mdesc2 = hw_desc_set_cipher_mode(mdesc2, sep_cipher_mode.SEP_CIPHER_CTR) + mdesc2 = hw_desc_set_cipher_mode(mdesc2, SepCipherMode.SEP_CIPHER_CTR) mdesc2 = hw_desc_set_setup_mode(mdesc2, SetupOp.SETUP_LOAD_KEY0) mdesc2 = hw_desc_set_flow_mode(mdesc2, FlowMode.S_DIN_to_AES) mdesc2 = hw_desc_set_dout_dlli(mdesc2, 0, AES_BLOCK_SIZE_IN_BYTES, SB_AXI_ID, 0) self.sasi_sb_adddescsequence(mdesc2) - def sbrom_cryptoupdate(self, inputptr, outputptr, blockSize, islastblock, cryptodrivermode, waitforcrypto): + def sbrom_cryptoupdate(self, inputptr, outputptr, block_size, islastblock, cryptodrivermode, waitforcrypto): if waitforcrypto == 2: - if self.SB_HalWaitDescCompletion() == 1: + if self.sb_hal_wait_desc_completion() == 1: return True if islastblock == 1 and (cryptodrivermode & 0xFFFFFFFD) == 0: # 0=0 @@ -1391,17 +1391,17 @@ class dxcc(metaclass=LogBase): ydesc = hw_desc_init() ydesc = hw_desc_set_dout_dlli(ydesc, outputptr, 0x10, SB_AXI_ID, 0) ydesc = hw_desc_set_flow_mode(ydesc, FlowMode.S_HASH_to_DOUT) - ydesc = hw_desc_set_cipher_mode(ydesc, sep_hash_hw_mode.SEP_HASH_HW_SHA256) - ydesc = hw_desc_set_cipher_config1(ydesc, sep_hash_mode.SEP_HASH_SHA256) + ydesc = hw_desc_set_cipher_mode(ydesc, SepHashHwMode.SEP_HASH_HW_SHA256) + ydesc = hw_desc_set_cipher_config1(ydesc, SepHashMode.SEP_HASH_SHA256) ydesc = hw_desc_set_setup_mode(ydesc, SetupOp.SETUP_WRITE_STATE1) self.sasi_sb_adddescsequence(ydesc) udesc = hw_desc_init() - udesc = hw_desc_set_din_type(udesc, DmaMode.DMA_DLLI, inputptr, blockSize, SB_AXI_ID, AXI_SECURE) + udesc = hw_desc_set_din_type(udesc, DmaMode.DMA_DLLI, inputptr, block_size, SB_AXI_ID, AXI_SECURE) if not cryptodrivermode: udesc = hw_desc_set_flow_mode(udesc, FlowMode.DIN_HASH) self.sasi_sb_adddescsequence(udesc) if (waitforcrypto == 2 and not islastblock) or waitforcrypto == 3: - self.SB_HalWaitDescCompletion() + self.sb_hal_wait_desc_completion() elif waitforcrypto == 0: return 0 else: @@ -1411,9 +1411,9 @@ class dxcc(metaclass=LogBase): fdesc = hw_desc_init() fdesc = hw_desc_set_dout_dlli(fdesc, outputptr, 0x20, SB_AXI_ID, 0) fdesc = hw_desc_set_flow_mode(fdesc, FlowMode.S_HASH_to_DOUT) - fdesc = hw_desc_set_cipher_mode(fdesc, sep_hash_hw_mode.SEP_HASH_HW_SHA256) - fdesc = hw_desc_set_cipher_config0(fdesc, sep_hash_hw_mode.SEP_HASH_HW_SHA256) - fdesc = hw_desc_set_cipher_config1(fdesc, sep_hash_mode.SEP_HASH_SHA256) + fdesc = hw_desc_set_cipher_mode(fdesc, SepHashHwMode.SEP_HASH_HW_SHA256) + fdesc = hw_desc_set_cipher_config0(fdesc, SepHashHwMode.SEP_HASH_HW_SHA256) + fdesc = hw_desc_set_cipher_config1(fdesc, SepHashMode.SEP_HASH_SHA256) fdesc = hw_desc_set_setup_mode(fdesc, SetupOp.SETUP_WRITE_STATE0) # 0 = 0 # 1 = 0 @@ -1422,7 +1422,7 @@ class dxcc(metaclass=LogBase): # 4 = 0x80C082B # 5 = outputptr>>32<<16 self.sasi_sb_adddescsequence(fdesc) - return self.SB_HalWaitDescCompletion() + return self.sb_hal_wait_desc_completion() if __name__ == "__main__": @@ -1435,7 +1435,7 @@ if __name__ == "__main__": desc = hw_desc_init() desc = hw_desc_set_dout_dlli(desc, 0, 0x10, SB_AXI_ID, 0) desc = hw_desc_set_flow_mode(desc, FlowMode.S_HASH_to_DOUT) - desc = hw_desc_set_cipher_mode(desc, sep_hash_hw_mode.SEP_HASH_HW_SHA256) - desc = hw_desc_set_cipher_config1(desc, sep_hash_mode.SEP_HASH_SHA256) + desc = hw_desc_set_cipher_mode(desc, SepHashHwMode.SEP_HASH_HW_SHA256) + desc = hw_desc_set_cipher_config1(desc, SepHashMode.SEP_HASH_SHA256) desc = hw_desc_set_setup_mode(desc, SetupOp.SETUP_WRITE_STATE1) print(desc) diff --git a/mtkclient/Library/Hardware/hwcrypto_gcpu.py b/mtkclient/Library/Hardware/hwcrypto_gcpu.py index 76fb082..39515da 100755 --- a/mtkclient/Library/Hardware/hwcrypto_gcpu.py +++ b/mtkclient/Library/Hardware/hwcrypto_gcpu.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2022 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import hmac import hashlib @@ -194,7 +194,8 @@ def xor_data(a: bytearray, b: bytearray, length=None): class GCpu(metaclass=LogBase): def __init__(self, setup, loglevel=logging.INFO, gui: bool = False): - self.__logger = logsetup(self, self.__logger, loglevel, gui) + self.setup = None + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, loglevel, gui) self.read32 = setup.read32 self.write32 = setup.write32 self.reg = GCpuReg(setup) @@ -352,8 +353,8 @@ class GCpu(metaclass=LogBase): self.__logger.info(", ".join(regs[i * 4:(i * 4) + 4])) def cmd(self, cmd, addr=0, args=None): - GCPU_INT_MASK = 3 # todo this might be different - CLR_EN = 3 # todo this might be different + gcpu_int_mask = 3 # todo this might be different + clr_en = 3 # todo this might be different # Setup parameter if args is not None: for i in range(1, 48): @@ -363,8 +364,8 @@ class GCpu(metaclass=LogBase): self.reg.GCPU_REG_INT_CLR = 1 self.reg.GCPU_REG_INT_EN = 0 else: - self.reg.GCPU_REG_INT_CLR = CLR_EN - self.reg.GCPU_REG_INT_EN = GCPU_INT_MASK + self.reg.GCPU_REG_INT_CLR = clr_en + self.reg.GCPU_REG_INT_EN = gcpu_int_mask # GCPU Decryption Mode self.reg.GCPU_REG_MEM_CMD = cmd # GCPU PC @@ -378,13 +379,13 @@ class GCpu(metaclass=LogBase): pass result = -1 # Enable GCPU Interrupt - self.reg.GCPU_REG_INT_CLR = CLR_EN + self.reg.GCPU_REG_INT_CLR = clr_en else: while not self.reg.GCPU_REG_DRAM_MON & 1: pass result = 0 # Enable GCPU Interrupt - self.reg.GCPU_REG_INT_CLR = CLR_EN + self.reg.GCPU_REG_INT_CLR = clr_en return result def set_mode_cmd(self, encrypt=False, mode="cbc", encryptedkey=True): @@ -593,7 +594,8 @@ class GCpu(metaclass=LogBase): self.acquire() if self.load_hw_key(keyslot): self.memptr_set(src, bytearray(bytes.fromhex("4B65796D61737465724D617374657200"))) - # self.memptr_set(src, bytearray(bytes.fromhex("0102030405060708090A0B0C0D0E0F0102030405060708090A0B0C0D0E0F0000"))) + # self.memptr_set(src, + # bytearray(bytes.fromhex("0102030405060708090A0B0C0D0E0F0102030405060708090A0B0C0D0E0F0000"))) if encrypt: if not self.aes_encrypt_ecb(keyslot, src, dst): return self.memptr_get(dst, 16) diff --git a/mtkclient/Library/Hardware/hwcrypto_sej.py b/mtkclient/Library/Hardware/hwcrypto_sej.py index eaff4ff..bb809a6 100755 --- a/mtkclient/Library/Hardware/hwcrypto_sej.py +++ b/mtkclient/Library/Hardware/hwcrypto_sej.py @@ -1,11 +1,11 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import logging import os from struct import pack, unpack -from mtkclient.Library.utils import LogBase -from mtkclient.Library.cryptutils import cryptutils +from mtkclient.Library.utils import LogBase, logsetup +from mtkclient.Library.cryptutils import CryptUtils CustomSeed = bytes.fromhex("00be13bb95e218b53d07a089cb935255294f70d4088f3930350bc636cc49c9025ece7a62c292853ef55b23a6e" + "f7b7464c7f3f2a74ae919416d6b4d9c1d6809655dd82d43d65999cf041a386e1c0f1e58849d8ed09ef07e6a9f" + @@ -24,7 +24,7 @@ def bytes_to_dwords(buf): return res -class symkey: +class SymKey: key = None key_len = 0x10 mode = 1 @@ -79,7 +79,7 @@ regval = { } -class hacc_reg: +class HaccReg: def __init__(self, setup): self.sej_base = setup.sej_base self.read32 = setup.read32 @@ -87,24 +87,24 @@ class hacc_reg: def __setattr__(self, key, value): if key in ("sej_base", "read32", "write32", "regval"): - return super(hacc_reg, self).__setattr__(key, value) + return super(HaccReg, self).__setattr__(key, value) if key in regval: addr = regval[key] + self.sej_base return self.write32(addr, value) else: - return super(hacc_reg, self).__setattr__(key, value) + return super(HaccReg, self).__setattr__(key, value) def __getattribute__(self, item): if item in ("sej_base", "read32", "write32", "regval"): - return super(hacc_reg, self).__getattribute__(item) + return super(HaccReg, self).__getattribute__(item) if item in regval: addr = regval[item] + self.sej_base return self.read32(addr) else: - return super(hacc_reg, self).__getattribute__(item) + return super(HaccReg, self).__getattribute__(item) -class sej(metaclass=LogBase): +class Sej(metaclass=LogBase): encrypt = True HACC_AES_DEC = 0x00000000 @@ -166,12 +166,10 @@ class sej(metaclass=LogBase): ] def __init__(self, setup, loglevel=logging.INFO): - self.__logger = self.__logger - self.info = self.__logger.info - self.error = self.__logger.error - self.warning = self.__logger.warning + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, None) self.hwcode = setup.hwcode - self.reg = hacc_reg(setup) + self.reg = HaccReg(setup) # mediatek,hacc, mediatek,sej self.sej_base = setup.sej_base self.read32 = setup.read32 @@ -220,7 +218,7 @@ class sej(metaclass=LogBase): else: self.write32(0x10216024, 0x0) - def device_APC_dom_setup(self): + def device_apc_dom_setup(self): self.write32(0x10007F00, 0) tv = self.read32(0x10007400) & 0xFFFFFFFF self.write32(0x10007400, tv | (1 << (self.uffs(0xF0000000) - 1))) @@ -277,7 +275,7 @@ class sej(metaclass=LogBase): # self.crypto_secure(1) return - def SEJ_Run(self, data): + def sej_run(self, data): pdst = bytearray() psrc = bytes_to_dwords(data) plen = len(psrc) @@ -302,7 +300,7 @@ class sej(metaclass=LogBase): pos += 4 return pdst - def SEJ_AES_HW_Init(self, attr, key: symkey, sej_param=3): + def sej_aes_hw_init(self, attr, key: SymKey, sej_param=3): # key.mode 0 = ECB # key.mode 1 = CBC if key.key is None: @@ -374,7 +372,7 @@ class sej(metaclass=LogBase): self.reg.HACC_ACFG2 = key.iv[2] self.reg.HACC_ACFG3 = key.iv[3] - def SEJ_AES_HW_Internal(self, data, encrypt, attr, sej_param, legacy=True): + def sej_aes_hw_internal(self, data, encrypt, attr, sej_param, legacy=True): if encrypt: self.reg.HACC_ACON |= 1 if legacy: @@ -412,7 +410,7 @@ class sej(metaclass=LogBase): self.reg.HACC_AKEY0[pos] = pdst[pos] ^ self.reg.HACC_AKEY0[pos] return pdst - def SST_Init(self, attr, iv, keylen=0x10, mparam=5, key=None): + def sst_init(self, attr, iv, keylen=0x10, mparam=5, key=None): self.reg.HACC_SECINIT0 = 1 if keylen == 0x10 or mparam & 1 != 0 or attr & 1 != 0: acon_setting = 0 @@ -470,16 +468,16 @@ class sej(metaclass=LogBase): self.reg.HACC_ACON|=acon_setting """ - def SST_Secure_Algo_With_Level(self, buf, encrypt=True, aes_top_legacy=True): + def sst_secure_algo_with_level(self, buf, encrypt=True, aes_top_legacy=True): seed = (CustomSeed[2] << 16) | (CustomSeed[1] << 8) | CustomSeed[0] | (CustomSeed[3] << 24) - iv = [seed, (~seed) & 0xFFFFFFFF, (((seed >> 16) | (seed << 16)) & 0xFFFFFFFF), - (~((seed >> 16) | (seed << 16)) & 0xFFFFFFFF)] - key = symkey() + _iv = [seed, (~seed) & 0xFFFFFFFF, (((seed >> 16) | (seed << 16)) & 0xFFFFFFFF), + (~((seed >> 16) | (seed << 16)) & 0xFFFFFFFF)] + key = SymKey() key.key = None key.key_len = 0x10 # meta_key_len = 0x10 key.mode = 1 # CBC - key.iv = iv + key.iv = _iv if aes_top_legacy: sej_param = 3 else: @@ -501,17 +499,17 @@ class sej(metaclass=LogBase): if metaflag: # length=0x10 attr = 0x5B - self.SEJ_AES_HW_Init(attr, key, sej_param) + self.sej_aes_hw_init(attr, key, sej_param) for pos in range(3): src = b"".join([int.to_bytes(val, 4, 'little') for val in self.g_CFG_RANDOM_PATTERN]) - buf2 = self.SEJ_AES_HW_Internal(src, encrypt=False, attr=attr, sej_param=sej_param) + buf2 = self.sej_aes_hw_internal(src, encrypt=False, attr=attr, sej_param=sej_param) attr = attr & 0xFFFFFFFA | 4 else: - self.SST_Init(attr=attr, iv=iv, keylen=key.key_len, mparam=sej_param, key=key.key) - buf2 = self.SEJ_AES_HW_Internal(buf, encrypt=encrypt, attr=attr, sej_param=sej_param, legacy=False) + self.sst_init(attr=attr, iv=_iv, keylen=key.key_len, mparam=sej_param, key=key.key) + buf2 = self.sej_aes_hw_internal(buf, encrypt=encrypt, attr=attr, sej_param=sej_param, legacy=False) return buf2 - def SEJ_Terminate(self): + def sej_terminate(self): self.reg.HACC_ACON2 = self.HACC_AES_CLR self.reg.HACC_AKEY0 = 0 self.reg.HACC_AKEY1 = 0 @@ -607,9 +605,9 @@ class sej(metaclass=LogBase): self.info("HACC init") self.SEJ_V3_Init(ben=encrypt, iv=iv) self.info("HACC run") - buf2 = self.SEJ_Run(buf) + buf2 = self.sej_run(buf) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() return buf2 def sej_set_otp(self, data): @@ -680,7 +678,7 @@ class sej(metaclass=LogBase): iv = bytes.fromhex("57325A5A125497661254976657325A5A") res = self.sej_do_aes(encrypt, iv, data, len(data)) """ - ctx = cryptutils.aes() + ctx = CryptUtils.Aes() res = ctx.aes_cbc(key=b"25A1763A21BC854CD569DC23B4782B63", iv=bytes.fromhex("57325A5A125497661254976657325A5A"), data=data, decrypt=not encrypt) @@ -701,9 +699,9 @@ class sej(metaclass=LogBase): self.info("HACC init") self.SEJ_V3_Init(ben=encrypt, iv=self.g_HACC_CFG_1, legacy=True) self.info("HACC run") - dec = self.SEJ_Run(data) + dec = self.sej_run(data) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() if not encrypt: dec = self.xor_data(dec) return dec @@ -723,24 +721,24 @@ class sej(metaclass=LogBase): buf.append(meid[i % len(meid)]) return self.hw_aes128_cbc_encrypt(buf=buf, encrypt=True, iv=self.g_HACC_CFG_1) - def sp_hacc_internal(self, buf: bytes, bAC: bool, user: int, bDoLock: bool, aes_type: int, bEn: bool): + def sp_hacc_internal(self, buf: bytes, b_ac: bool, user: int, b_do_lock: bool, aes_type: int, b_en: bool): dec = None if user == 0: iv = self.g_HACC_CFG_1 self.info("HACC init") - self.SEJ_V3_Init(ben=bEn, iv=iv) + self.SEJ_V3_Init(ben=b_en, iv=iv) self.info("HACC run") - dec = self.SEJ_Run(buf) + dec = self.sej_run(buf) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() elif user == 1: iv = self.g_HACC_CFG_2 self.info("HACC init") - self.SEJ_V3_Init(ben=bEn, iv=iv) + self.SEJ_V3_Init(ben=b_en, iv=iv) self.info("HACC run") - dec = self.SEJ_Run(buf) + dec = self.sej_run(buf) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() elif user == 2: self.sej_set_key(key=2, flag=32) iv = bytes.fromhex("57325A5A125497661254976657325A5A") @@ -748,18 +746,18 @@ class sej(metaclass=LogBase): elif user == 3: iv = self.g_HACC_CFG_3 self.info("HACC init") - self.SEJ_V3_Init(ben=bEn, iv=iv) + self.SEJ_V3_Init(ben=b_en, iv=iv) self.info("HACC run") - dec = self.SEJ_Run(buf) + dec = self.sej_run(buf) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() return dec def dev_kdf(self, buf: bytes, derivelen=16): res = bytearray() for i in range(derivelen // 16): - res.extend(self.sp_hacc_internal(buf=buf[i * 16:(i * 16) + 16], bAC=True, user=0, bDoLock=False, aes_type=1, - bEn=True)) + res.extend(self.sp_hacc_internal(buf=buf[i * 16:(i * 16) + 16], b_ac=True, user=0, b_do_lock=False, + aes_type=1, b_en=True)) return res def generate_mtee(self, otp=None): @@ -779,9 +777,9 @@ class sej(metaclass=LogBase): self.info("HACC init") self.SEJ_V3_Init(ben=True, iv=self.g_HACC_CFG_MTEE) self.info("HACC run") - dec = self.SEJ_Run(bytes.fromhex("7777772E6D6564696174656B2E636F6D30313233343536373839414243444546")) + dec = self.sej_run(bytes.fromhex("7777772E6D6564696174656B2E636F6D30313233343536373839414243444546")) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() return dec def generate_hw_meta(self, otp=None, encrypt=False, data=b""): @@ -804,9 +802,9 @@ class sej(metaclass=LogBase): self.info("HACC init") self.SEJ_V3_Init(ben=encrypt, iv=iv) self.info("HACC run") - dec = self.SEJ_Run(data) + dec = self.sej_run(data) self.info("HACC terminate") - self.SEJ_Terminate() + self.sej_terminate() return dec diff --git a/mtkclient/Library/Hardware/seccfg.py b/mtkclient/Library/Hardware/seccfg.py index 9b57bf5..e524c40 100755 --- a/mtkclient/Library/Hardware/seccfg.py +++ b/mtkclient/Library/Hardware/seccfg.py @@ -3,19 +3,17 @@ import os import hashlib import logging from io import BytesIO -from mtkclient.Library.utils import structhelper_io +from mtkclient.Library.utils import StructhelperIo, logsetup from mtkclient.Library.utils import LogBase -from mtkclient.config.mtk_config import Mtk_Config +from mtkclient.config.mtk_config import MtkConfig -class seccfgV4(metaclass=LogBase): - def __init__(self, hwc, mtk, loglevel=logging.INFO): - self.__logger = self.__logger - self.info = self.__logger.info - self.error = self.__logger.error - self.warning = self.__logger.warning +class SecCfgV4(metaclass=LogBase): + def __init__(self, _hwc, mtk, loglevel=logging.INFO): + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.hwtype = None - self.hwc = hwc + self.hwc = _hwc self.mtk = mtk self.magic = 0x4D4D4D4D self.seccfg_ver = None @@ -33,38 +31,36 @@ class seccfgV4(metaclass=LogBase): else: self.__logger.setLevel(logging.INFO) - def parse(self, data): - rf = structhelper_io(BytesIO(bytearray(data))) - self.magic = rf.dword() - self.seccfg_ver = rf.dword() - self.seccfg_size = rf.dword() - self.lock_state = rf.dword() - self.critical_lock_state = rf.dword() - self.sboot_runtime = rf.dword() - self.endflag = rf.dword() - rf.seek(self.seccfg_size - 0x20) - self.hash = rf.bytes(0x20) + def parse(self, indata): + rrf = StructhelperIo(BytesIO(bytearray(indata))) + self.magic = rrf.dword() + self.seccfg_ver = rrf.dword() + self.seccfg_size = rrf.dword() + self.lock_state = rrf.dword() + self.critical_lock_state = rrf.dword() + self.sboot_runtime = rrf.dword() + self.endflag = rrf.dword() + rrf.seek(self.seccfg_size - 0x20) + self.hash = rrf.bytes(0x20) if self.magic != 0x4D4D4D4D or self.endflag != 0x45454545: self.error("Unknown V4 seccfg structure !") return False seccfg_data = pack("N: - tosign1 = divmod(tosign, N)[1] - signature = pow(tosign1, D, N) - raise OverflowError("The message %i is too long for n=%i" % (tosign, N)) + if tosign > n: + raise OverflowError("The message %i is too long for n=%i" % (tosign, n)) - signature = pow(tosign, D, N) - hexsign = self.i2osp(signature, emBits // 8) + signature = pow(tosign, d, n) + hexsign = self.i2osp(signature, em_bits // 8) return hexsign - def pss_sign(self, D, N, msghash, salt, emBits=1024): - if isinstance(D, str): - D = bytes.fromhex(D) - D = self.os2ip(D) - if isinstance(N, str): - N = bytes.fromhex(N) - N = self.os2ip(N) + def pss_sign(self, d, n, msghash, salt, em_bits=1024): + if isinstance(d, str): + d = bytes.fromhex(d) + d = self.os2ip(d) + if isinstance(n, str): + n = bytes.fromhex(n) + n = self.os2ip(n) slen = len(salt) - emLen = self.ceil_div(emBits, 8) - inBlock = b"\x00" * 8 + msghash + salt - hash = self.hash(inBlock) - PSlen = emLen - self.digestLen - slen - 1 - 1 - DB = (PSlen * b"\x00") + b"\x01" + salt - rlen = emLen - len(hash) - 1 - dbMask = self.mgf1(hash, rlen) - maskedDB = bytearray() - for i in range(0, len(dbMask)): - maskedDB.append(dbMask[i] ^ DB[i]) - maskedDB[0] = maskedDB[0] & 0x7F - EM = maskedDB + hash + b"\xbc" - tosign = self.os2ip(EM) + em_len = self.ceil_div(em_bits, 8) + in_block = b"\x00" * 8 + msghash + salt + _hash = self.hash(in_block) + ps_len = em_len - self.digestLen - slen - 1 - 1 + db = (ps_len * b"\x00") + b"\x01" + salt + rlen = em_len - len(_hash) - 1 + db_mask = self.mgf1(_hash, rlen) + masked_db = bytearray() + for i in range(0, len(db_mask)): + masked_db.append(db_mask[i] ^ db[i]) + masked_db[0] = masked_db[0] & 0x7F + em = masked_db + _hash + b"\xbc" + tosign = self.os2ip(em) # EM=hexlify(EM).decode('utf-8') # tosign = int(EM,16) - return self.sign(tosign, D, N, emBits) + return self.sign(tosign, d, n, em_bits) # 6B1EAA2042A5C8DA8B1B4A8320111A70A0CBA65233D1C6E418EF8156E82A8F96BD843F047FF25AB9702A6582C8387298753E628F23448B4580E09CBD2A483C623B888F47C4BD2C5EFF09013C6DFF67DB59BAB3037F0BEE05D5660264D28CC6251631FE75CE106D931A04FA032FEA31259715CE0FAB1AE0E2F8130807AF4019A61B9C060ECE59104F22156FEE8108F17DC80D7C2F8397AFB9780994F7C5A0652F93D1B48010B0B248AB9711235787D797FBA4D10A29BCF09628585D405640A866B15EE9D7526A2703E72A19811EF447F6E5C43F915B3808EBC79EA4BCF78903DBDE32E47E239CFB5F2B5986D0CBBFBE6BACDC29B2ADE006D23D0B90775B1AE4DD @staticmethod @@ -441,58 +439,57 @@ class cryptutils: else: return q - def pss_verify(self, e, N, msghash, signature, emBits=1024, salt=None): + def pss_verify(self, e, n, msghash, signature, em_bits=1024, salt=None): if salt is None: slen = self.digestLen else: slen = len(salt) sig = self.os2ip(signature) - EM = pow(sig, e, N) + em = pow(sig, e, n) # EM = bytes.fromhex(hex(EM)[2:]) - EM = self.i2osp(EM, emBits // 8) + em = self.i2osp(em, em_bits // 8) - emLen = len(signature) + em_len = len(signature) - valBC = EM[-1] - if valBC != 0xbc: - print("[rsa_pss] : 0xbc check failed, value: 0x%02X" % valBC) + val_bc = em[-1] + if val_bc != 0xbc: + print("[rsa_pss] : 0xbc check failed, value: 0x%02X" % val_bc) return False - hash = EM[emLen - self.digestLen - 1:-1] - maskedDB = EM[:emLen - self.digestLen - 1] + _hash = em[em_len - self.digestLen - 1:-1] + masked_db = em[:em_len - self.digestLen - 1] - lmask = ~(0xFF >> (8 * emLen + 1 - emBits)) - if EM[0] & lmask: + lmask = ~(0xFF >> (8 * em_len + 1 - em_bits)) + if em[0] & lmask: print("[rsa_pss] : lmask check failed") return False - dbMask = self.mgf1(hash, emLen - self.digestLen - 1) + db_mask = self.mgf1(_hash, em_len - self.digestLen - 1) - DB = bytearray() - for i in range(0, len(dbMask)): - DB.append(dbMask[i] ^ maskedDB[i]) + db = bytearray() + for i in range(0, len(db_mask)): + db.append(db_mask[i] ^ masked_db[i]) - TS = bytearray() - TS.append(DB[0] & ~lmask) - TS.extend(DB[1:]) + ts = bytearray() + ts.append(db[0] & ~lmask) + ts.extend(db[1:]) - PS = (b"\x00" * (emLen - self.digestLen - slen - 2)) + b"\x01" - if TS[:len(PS)] != PS: - print(TS[:len(PS)]) - print(PS) + ps = (b"\x00" * (em_len - self.digestLen - slen - 2)) + b"\x01" + if ts[:len(ps)] != ps: + print(ts[:len(ps)]) + print(ps) print("[rsa_pss] : 0x01 check failed") return False if salt is not None: - inBlock = b"\x00" * 8 + msghash + salt - mhash = self.hash(inBlock) - return mhash == hash + in_block = b"\x00" * 8 + msghash + salt + mhash = self.hash(in_block) + return mhash == _hash else: - salt = TS[-self.digestLen:] - inBlock = b"\x00" * 8 + msghash + salt - mhash = self.hash(inBlock) - return mhash == hash - return maskedDB + salt = ts[-self.digestLen:] + in_block = b"\x00" * 8 + msghash + salt + mhash = self.hash(in_block) + return mhash == _hash @staticmethod def sha1(msg): diff --git a/mtkclient/Library/error.py b/mtkclient/Library/error.py index faf36fa..f61f04b 100755 --- a/mtkclient/Library/error.py +++ b/mtkclient/Library/error.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License ErrorCodes = { 0x0: "OK", # COMMON diff --git a/mtkclient/Library/exploit_handler.py b/mtkclient/Library/exploit_handler.py index 0f88642..6b9ef05 100755 --- a/mtkclient/Library/exploit_handler.py +++ b/mtkclient/Library/exploit_handler.py @@ -1,18 +1,19 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import logging import time from struct import pack, unpack -from mtkclient.Library.Hardware.hwcrypto import hwcrypto, crypto_setup +from mtkclient.Library.Hardware.hwcrypto import HwCrypto, CryptoSetup from mtkclient.Library.utils import LogBase, logsetup -from mtkclient.config.payloads import pathconfig +from mtkclient.config.payloads import PathConfig class Exploitation(metaclass=LogBase): def __init__(self, mtk, loglevel=logging.INFO): - self.__logger = logsetup(self, self.__logger, loglevel, mtk.config.gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.lasterror = "" self.mtk = mtk self.chipconfig = self.mtk.config.chipconfig @@ -24,7 +25,7 @@ class Exploitation(metaclass=LogBase): self.hwcode = mtk.config.hwcode # crypto types - setup = crypto_setup() + setup = CryptoSetup() setup.hwcode = self.mtk.config.hwcode setup.dxcc_base = self.mtk.config.chipconfig.dxcc_base setup.read32 = self.mtk.preloader.read32 @@ -38,11 +39,11 @@ class Exploitation(metaclass=LogBase): setup.ap_dma_mem = self.mtk.config.chipconfig.ap_dma_mem setup.meid_addr = self.mtk.config.chipconfig.meid_addr setup.prov_addr = self.mtk.config.chipconfig.prov_addr - self.hwcrypto = hwcrypto(setup, loglevel, self.mtk.config.gui) + self.hwcrypto = HwCrypto(setup, loglevel, self.mtk.config.gui) self.chipconfig = self.mtk.config.chipconfig self.var1 = self.chipconfig.var1 - self.pathconfig = pathconfig() + self.pathconfig = PathConfig() def fix_payload(self, payload, da=True): payload = bytearray(payload) @@ -73,8 +74,8 @@ class Exploitation(metaclass=LogBase): def da_payload(self, payload, addr, forcekamakiri=True, exploittype=1): hassecurity = self.mtk.config.target_config["sla"] or self.mtk.config.target_config["daa"] or \ self.mtk.config.target_config["sbc"] - isV6 = self.mtk.config.chipconfig.damode == 6 - if isV6: + is_v6 = self.mtk.config.chipconfig.damode == 6 + if is_v6: forcekamakiri = False if hassecurity or forcekamakiri: try: @@ -136,6 +137,9 @@ class Exploitation(metaclass=LogBase): self.error("Error on sending payload.") return False + def close(self): + pass + def crash(self, mode=0): self.info("Crashing da...") try: diff --git a/mtkclient/Library/gpt.py b/mtkclient/Library/gpt.py index 4a585fb..4deed86 100755 --- a/mtkclient/Library/gpt.py +++ b/mtkclient/Library/gpt.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 +# (c) B.Kerler 2018-2024 import argparse import os import sys @@ -11,12 +11,12 @@ from struct import unpack from binascii import hexlify try: - from mtkclient.Library.utils import LogBase, structhelper + from mtkclient.Library.utils import LogBase, Structhelper, logsetup except Exception: - from utils import LogBase, structhelper + from utils import LogBase, Structhelper -class gpt_settings: +class GptSettings: gpt_num_part_entries = 0 gpt_part_entry_size = 0 gpt_part_entry_start_lba = 0 @@ -27,10 +27,10 @@ class gpt_settings: self.gpt_part_entry_start_lba = int(gpt_part_entry_start_lba) -class gpt(metaclass=LogBase): - class gpt_header: - def __init__(self, data): - sh = structhelper(data) +class GPT(metaclass=LogBase): + class GptHeader: + def __init__(self, indata): + sh = Structhelper(indata) self.signature = sh.bytes(8) self.revision = sh.dword() self.header_size = sh.dword() @@ -45,9 +45,9 @@ class gpt(metaclass=LogBase): self.num_part_entries = sh.dword() self.part_entry_size = sh.dword() - class gpt_partition: - def __init__(self, data): - sh = structhelper(data) + class GptPartition: + def __init__(self, indata): + sh = Structhelper(indata) self.type = sh.bytes(16) self.unique = sh.bytes(16) self.first_lba = sh.qword() @@ -55,7 +55,7 @@ class gpt(metaclass=LogBase): self.flags = sh.qword() self.name = sh.string(72) - class efi_type(Enum): + class EfiType(Enum): EFI_UNUSED = 0x00000000 EFI_MBR = 0x024DEE41 EFI_SYSTEM = 0xC12A7328 @@ -145,7 +145,8 @@ class gpt(metaclass=LogBase): def __init__(self, num_part_entries=0, part_entry_size=0, part_entry_start_lba=0, loglevel=logging.INFO, *args, **kwargs): self.num_part_entries = num_part_entries - self.__logger = self.__logger + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, None) self.part_entry_size = part_entry_size self.part_entry_start_lba = part_entry_start_lba self.totalsectors = None @@ -153,18 +154,17 @@ class gpt(metaclass=LogBase): self.sectorsize = None self.partentries = [] - self.error = self.__logger.error self.__logger.setLevel(loglevel) if loglevel == logging.DEBUG: logfilename = "log.txt" fh = logging.FileHandler(logfilename, encoding='utf-8') self.__logger.addHandler(fh) - def parseheader(self, gptdata, sectorsize=512): - return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C]) + def parseheader(self, gptdata, sector_size=512): + return self.GptHeader(gptdata[sector_size:sector_size + 0x5C]) def parse_bpi(self, gptdata, pagesize=0x200): - class partf: + class Partf: unique = b"" first_lba = 0 last_lba = 0 @@ -179,33 +179,33 @@ class gpt(metaclass=LogBase): self.totalsectors = 0 self.partentries = [] for pos in range(0x800, len(gptdata), 0x80): - data = gptdata[pos:pos + 0x80] - if int(hexlify(data[16:32]), 16) == 0: + rdata = gptdata[pos:pos + 0x80] + if int(hexlify(rdata[16:32]), 16) == 0: break - rf = BytesIO(bytearray(data)) - pf = partf() - rf.read(16) - guid1 = int.from_bytes(rf.read(4), 'little') - guid2 = int.from_bytes(rf.read(2), 'little') - guid3 = int.from_bytes(rf.read(2), 'little') - guid4 = int.from_bytes(rf.read(2), 'little') - guid5 = bytearray(rf.read(6)).hex() + rrf = BytesIO(bytearray(rdata)) + pf = Partf() + rrf.read(16) + guid1 = int.from_bytes(rrf.read(4), 'little') + guid2 = int.from_bytes(rrf.read(2), 'little') + guid3 = int.from_bytes(rrf.read(2), 'little') + guid4 = int.from_bytes(rrf.read(2), 'little') + guid5 = bytearray(rrf.read(6)).hex() pf.unique = "{:08x}-{:04x}-{:04x}-{:04x}-{}".format(guid1, guid2, guid3, guid4, guid5) - pf.first_lba = int.from_bytes(rf.read(8), 'little') - pf.last_lba = int.from_bytes(rf.read(8), 'little') + pf.first_lba = int.from_bytes(rrf.read(8), 'little') + pf.last_lba = int.from_bytes(rrf.read(8), 'little') pf.sector = pf.first_lba pf.sectors = pf.last_lba - pf.first_lba + 1 - pf.flags = int.from_bytes(rf.read(8), 'little') - pf.name = rf.read(0x48).replace(b"\x00\x00", b"").decode("utf-16") + pf.flags = int.from_bytes(rrf.read(8), 'little') + pf.name = rrf.read(0x48).replace(b"\x00\x00", b"").decode("utf-16") pf.type = 0 if pf.last_lba > self.totalsectors: self.totalsectors = pf.last_lba self.partentries.append(pf) - def parse(self, gptdata, sectorsize=512): - self.header = self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C]) - self.sectorsize = sectorsize + def parse(self, gptdata, sector_size=512): + self.header = self.GptHeader(gptdata[sector_size:sector_size + 0x5C]) + self.sectorsize = sector_size if self.header.signature != b"EFI PART": if gptdata[0:4] == b"BPI\x00": self.parse_bpi(gptdata) @@ -215,14 +215,14 @@ class gpt(metaclass=LogBase): self.error("Unknown GPT revision.") return False if self.part_entry_start_lba != 0: - start = self.part_entry_start_lba + _start = self.part_entry_start_lba else: - start = self.header.part_entry_start_lba * sectorsize + _start = self.header.part_entry_start_lba * sector_size entrysize = self.header.part_entry_size self.partentries = [] - class partf: + class Partf: unique = b"" first_lba = 0 last_lba = 0 @@ -235,11 +235,11 @@ class gpt(metaclass=LogBase): num_part_entries = self.header.num_part_entries for idx in range(0, num_part_entries): - data = gptdata[start + (idx * entrysize):start + (idx * entrysize) + entrysize] - if int(hexlify(data[16:32]), 16) == 0: + indata = gptdata[_start + (idx * entrysize):_start + (idx * entrysize) + entrysize] + if int(hexlify(indata[16:32]), 16) == 0: break - partentry = self.gpt_partition(data) - pa = partf() + partentry = self.GptPartition(indata) + pa = Partf() guid1 = unpack("\n\n" partofsingleimage = "false" readbackverify = "false" sparse = "false" - for partition in self.partentries: - filename = partition.name + ".bin" - mstr += f"\t \n" + f"start_byte_hex=\"{hex(_partition.sector * sector_size)}\" " \ + f"start_sector=\"{_partition.sector}\"/>\n" partofsingleimage = "true" sectors = self.header.first_usable_lba - mstr += f"\t \n" sectors = self.header.first_usable_lba - 1 - mstr += f"\t \n" mstr += "" - wf.write(bytes(mstr, 'utf-8')) - print(f"Wrote partition xml as {fname}") + wwf.write(bytes(mstr, 'utf-8')) + print(f"Wrote _partition xml as {fname}") - def print_gptfile(self, filename): + def print_gptfile(self, gptfilename): try: - with open(filename, "rb") as rf: - size = min(32 * 4096, os.stat(filename).st_size) - data = rf.read(size) - for sectorsize in [512, 4096]: - result = self.parse(data, sectorsize) - if result: + with open(gptfilename, "rb") as rrf: + _sz = min(32 * 4096, os.stat(gptfilename).st_size) + _data = rrf.read(_sz) + for sector_size in [512, 4096]: + res = self.parse(_data, sector_size) + if res: break - if result: + if res: print(self.tostring()) - return result + return res except Exception as e: self.error(str(e)) return "" @@ -365,7 +365,7 @@ if __name__ == "__main__": if args.command not in ["print", "extract", "test"]: parser.error("Command is mandatory") - gp = gpt() + gp = GPT() if args.command == "print": if not os.path.exists(args.image): print(f"File {args.image} does not exist. Aborting.") diff --git a/mtkclient/Library/meta.py b/mtkclient/Library/meta.py index feb05a7..2c1ab95 100755 --- a/mtkclient/Library/meta.py +++ b/mtkclient/Library/meta.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import time import sys import logging @@ -20,7 +20,8 @@ class META(metaclass=LogBase): def __init__(self, mtk, loglevel=logging.INFO): self.mtk = mtk - self.__logger = logsetup(self, self.__logger, loglevel, mtk.config.gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.gcpu = None self.config = mtk.config self.display = True @@ -47,27 +48,26 @@ class META(metaclass=LogBase): cdc.connected = cdc.connect() if cdc.connected and cdc.pid == 0x2000: counter += 1 - EP_OUT = cdc.EP_OUT.write - EP_IN = cdc.EP_IN.read + ep_out = cdc.EP_OUT.write + ep_in = cdc.EP_IN.read maxinsize = cdc.EP_IN.wMaxPacketSize while True: - resp = b"" try: - resp = bytearray(EP_IN(maxinsize)) + resp = bytearray(ep_in(maxinsize)) except Exception: break if resp == b"READY": - EP_OUT(metamode, len(metamode)) + ep_out(metamode, len(metamode)) while resp == b"READY": - resp = bytearray(EP_IN(maxinsize)) + resp = bytearray(ep_in(maxinsize)) if resp in [b"ATEMEVDX", b"TOOBTSAF", b"ATEMATEM", b"TCAFTCAF", b"MYROTCAF"]: if resp == b"ATEMATEM": - EP_OUT(b"\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0") - EP_OUT(b"\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0") - EP_OUT(b"\x06\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0\x00\x80\x00\x00") + ep_out(b"\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0") + ep_out(b"\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0") + ep_out(b"\x06\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\xC0\x00\x80\x00\x00") # INFO = - EP_IN(13) # !READYATEM - EP_OUT(b"DISCONNECT") + ep_in(13) # !READYATEM + ep_out(b"DISCONNECT") return True self.warning(resp) else: diff --git a/mtkclient/Library/mtk_class.py b/mtkclient/Library/mtk_class.py index 37dc63f..ca07224 100755 --- a/mtkclient/Library/mtk_class.py +++ b/mtkclient/Library/mtk_class.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 -# MTK Flash Client (c) B.Kerler 2018-2023. +# MTK Flash Client (c) B.Kerler 2018-2024. # Licensed under GPLv3 License import os import logging from struct import unpack from mtkclient.config.usb_ids import default_ids -from mtkclient.config.payloads import pathconfig +from mtkclient.config.payloads import PathConfig from mtkclient.Library.pltools import PLTools from mtkclient.Library.mtk_preloader import Preloader from mtkclient.Library.DA.mtk_daloader import DAloader @@ -28,8 +28,9 @@ class Mtk(metaclass=LogBase): self.vid = config.vid self.pid = config.pid self.interface = config.interface - self.pathconfig = pathconfig() - self.__logger = logsetup(self, self.__logger, loglevel, config.gui) + self.pathconfig = PathConfig() + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, loglevel, + config.gui) self.eh = ErrorHandler() self.serialportname = serialportname if preinit: diff --git a/mtkclient/Library/mtk_main.py b/mtkclient/Library/mtk_main.py index 731ea51..2dbca06 100755 --- a/mtkclient/Library/mtk_main.py +++ b/mtkclient/Library/mtk_main.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# MTK Flash Client (c) B.Kerler 2018-2023. +# MTK Flash Client (c) B.Kerler 2018-2024. # Licensed under GPLv3 License import os import sys @@ -8,21 +8,23 @@ import time from binascii import hexlify from struct import unpack, pack from mtkclient.Library.mtk_class import Mtk -from mtkclient.config.payloads import pathconfig +from mtkclient.config.payloads import PathConfig from mtkclient.Library.pltools import PLTools from mtkclient.Library.meta import META -from mtkclient.Library.utils import LogBase, getint -from mtkclient.config.mtk_config import Mtk_Config +from mtkclient.Library.utils import LogBase, getint, logsetup +from mtkclient.config.mtk_config import MtkConfig from mtkclient.Library.utils import print_progress from mtkclient.Library.error import ErrorHandler -from mtkclient.Library.DA.mtk_da_handler import DA_handler -from mtkclient.Library.gpt import gpt_settings +from mtkclient.Library.DA.mtk_da_handler import DaHandler +from mtkclient.Library.gpt import GptSettings metamodes = "[FASTBOOT, FACTFACT, METAMETA, FACTORYM, ADVEMETA, AT+NBOOT]" class ArgHandler(metaclass=LogBase): def __init__(self, args, config): + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + config.loglevel, config.gui) try: config.gpt_file = None if args.gpt_file is not None: @@ -151,17 +153,15 @@ class ArgHandler(metaclass=LogBase): except Exception: pass - config.gpt_settings = gpt_settings(gpt_num_part_entries, gpt_part_entry_size, - gpt_part_entry_start_lba) + config.gpt_settings = GptSettings(gpt_num_part_entries, gpt_part_entry_size, + gpt_part_entry_start_lba) class Main(metaclass=LogBase): def __init__(self, args): - self.__logger = self.__logger - self.info = self.__logger.info - self.debug = self.__logger.debug - self.error = self.__logger.error - self.warning = self.__logger.warning + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + logging.INFO, None) + self.eh = None self.args = args if not os.path.exists("logs"): os.mkdir("logs") @@ -172,7 +172,7 @@ class Main(metaclass=LogBase): def cmd_stage(self, mtk, filename, stage2addr, stage2file, verifystage2): if filename is None: - pc = pathconfig() + pc = PathConfig() stage1file = os.path.join(pc.get_payloads_path(), "generic_stage1_payload.bin") else: stage1file = filename @@ -184,7 +184,7 @@ class Main(metaclass=LogBase): self.error(f"Error: {stage2file} doesn't exist !") return False else: - stage2file = os.path.join(mtk.pathconfig.get_payloads_path(), "stage2.bin") + stage2file = os.path.join(mtk.PathConfig.get_payloads_path(), "stage2.bin") if mtk.preloader.init(): mtk = mtk.crasher() if mtk.port.cdc.pid == 0x0003: @@ -269,6 +269,7 @@ class Main(metaclass=LogBase): self.info("Successfully loaded stage2") def cmd_peek(self, mtk, addr, length, preloader, filename): + wwf = None if preloader is not None: if os.path.exists(preloader): daaddr, dadata = mtk.parse_preloader(preloader) @@ -284,8 +285,8 @@ class Main(metaclass=LogBase): if mtk.preloader.jump_da(daaddr): self.info(f"Jumped to pl {hex(daaddr)}.") time.sleep(2) - config = Mtk_Config(loglevel=self.__logger.level, gui=mtk.config.gui, - guiprogress=mtk.config.guiprogress) + config = MtkConfig(loglevel=self.__logger.level, gui=mtk.config.gui, + guiprogress=mtk.config.guiprogress) mtk = Mtk(loglevel=self.__logger.level, config=config, serialportname=mtk.port.serialportname) res = mtk.preloader.init() @@ -304,7 +305,7 @@ class Main(metaclass=LogBase): if length % 4: dwords += 1 if filename is not None: - wf = open(filename, "wb") + wwf = open(filename, "wb") sdata = b"" print_progress(0, 100, prefix='Progress:', suffix='Starting, addr 0x%08X' % addr, bar_length=50) @@ -319,7 +320,7 @@ class Main(metaclass=LogBase): data = b"".join(int.to_bytes(val, 4, 'little') for val in mtk.preloader.read32(addr + pos, size)) sdata += data if filename is not None: - wf.write(data) + wwf.write(data) pos += len(data) prog = pos / length * 100 if round(prog, 1) > old: @@ -332,7 +333,7 @@ class Main(metaclass=LogBase): if filename is None: print(hexlify(sdata).decode('utf-8')) else: - wf.close() + wwf.close() self.info(f"Data from {hex(addr)} with size of {hex(length)} was written to " + filename) def run(self, parser): @@ -347,7 +348,7 @@ class Main(metaclass=LogBase): loglevel = logging.INFO self.__logger.setLevel(logging.INFO) pass - config = Mtk_Config(loglevel=loglevel, gui=None, guiprogress=None) + config = MtkConfig(loglevel=loglevel, gui=None, guiprogress=None) ArgHandler(self.args, config) self.eh = ErrorHandler() serialport = None @@ -393,7 +394,7 @@ class Main(metaclass=LogBase): preloader = self.args.preloader except Exception: preloader = None - da_handler = DA_handler(mtk, loglevel) + da_handler = DaHandler(mtk, loglevel) mtk = da_handler.configure_da(mtk, preloader) if mtk is not None: for rcmd in commands: @@ -525,7 +526,8 @@ class Main(metaclass=LogBase): mtk.port.close() self.close() return - if self.args.startpartition is not None or self.args.offset is not None or self.args.length is not None: + if (self.args.startpartition is not None or self.args.offset is not None or + self.args.length is not None): time.sleep(1) res = mtk.preloader.init() if not res: @@ -649,7 +651,7 @@ class Main(metaclass=LogBase): preloader = self.args.preloader except Exception: preloader = None - da_handler = DA_handler(mtk, loglevel) + da_handler = DaHandler(mtk, loglevel) mtk = da_handler.configure_da(mtk, preloader) if mtk is not None: da_handler.handle_da_cmds(mtk, cmd, self.args) @@ -676,9 +678,9 @@ class Main(metaclass=LogBase): plt = PLTools(mtk, self.__logger.level) if payloadfile is None: if mtk.config.chipconfig.loader is None: - payloadfile = os.path.join(mtk.pathconfig.get_payloads_path(), "generic_patcher_payload.bin") + payloadfile = os.path.join(mtk.PathConfig.get_payloads_path(), "generic_patcher_payload.bin") else: - payloadfile = os.path.join(mtk.pathconfig.get_payloads_path(), mtk.config.chipconfig.loader) + payloadfile = os.path.join(mtk.PathConfig.get_payloads_path(), mtk.config.chipconfig.loader) plt.runpayload(filename=payloadfile) if self.args.metamode: mtk.port.run_handshake() diff --git a/mtkclient/Library/mtk_preloader.py b/mtkclient/Library/mtk_preloader.py index 397f46d..dfffb4e 100755 --- a/mtkclient/Library/mtk_preloader.py +++ b/mtkclient/Library/mtk_preloader.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import os import logging import time @@ -8,13 +8,12 @@ from enum import Enum from struct import unpack, pack from binascii import hexlify -from Cryptodome.Util.number import bytes_to_long, long_to_bytes, ceil_div, size -from Cryptodome.PublicKey import RSA - -import mtkclient.Library.settings +from Cryptodome.Util.number import size +from mtkclient.Library.Auth.sla_keys import brom_sla_keys +from mtkclient.Library.Auth.sla import generate_brom_sla_challenge from mtkclient.Library.utils import LogBase, logsetup from mtkclient.Library.error import ErrorHandler -from mtkclient.config.brom_config import damodes +from mtkclient.config.brom_config import DAmodes USBDL_BIT_EN = 0x00000001 # 1: download bit enabled USBDL_BROM = 0x00000002 # 0: usbdl by brom; 1: usbdl by bootloader @@ -24,29 +23,6 @@ USBDL_MAGIC = 0x444C0000 # Brom will check this magic number MISC_LOCK_KEY_MAGIC = 0xAD98 -def customizedSign(n, e, msg): - modBits = size(n) - k = ceil_div(modBits, 8) - - ps = b'\xFF' * (k - len(msg) - 3) - em = b'\x00\x01' + ps + b'\x00' + msg - - em_int = bytes_to_long(em) - m_int = pow(em_int, e, n) - signature = long_to_bytes(m_int, k) - - return signature - - -def generate_rsa_challenge(n, e, data): - for i in range(0, len(data), 2): - data[i], data[i + 1] = data[i + 1], data[i] - msg = bytearray(customizedSign(n, e, data)) - for i in range(0, len(msg), 2): - msg[i], msg[i + 1] = msg[i + 1], msg[i] - return msg - - def calc_xflash_checksum(data): checksum = 0 pos = 0 @@ -146,7 +122,8 @@ class Preloader(metaclass=LogBase): def __init__(self, mtk, loglevel=logging.INFO): self.mtk = mtk - self.__logger = logsetup(self, self.__logger, loglevel, mtk.config.gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.info = self.__logger.info self.debug = self.__logger.debug self.error = self.__logger.error @@ -269,7 +246,7 @@ class Preloader(metaclass=LogBase): self.send_root_cert(certdata) else: self.error(f"Couldn't find cert file {self.config.cert}") - if self.config.target_config["sla"] and self.config.chipconfig.damode == damodes.XML: + if self.config.target_config["sla"] and self.config.chipconfig.damode == DAmodes.XML: self.handle_sla(func=None, isbrom=self.config.is_brom) return True @@ -367,12 +344,12 @@ class Preloader(metaclass=LogBase): usbdlreg |= USBDL_MAGIC # | 0x444C0000 # set BOOT_MISC0 as watchdog resettable - RST_CON = self.config.chipconfig.misc_lock + 8 - USBDL_FLAG = self.config.chipconfig.misc_lock - 0x20 + rst_con = self.config.chipconfig.misc_lock + 8 + usbdl_flag = self.config.chipconfig.misc_lock - 0x20 self.write32(self.config.chipconfig.misc_lock, MISC_LOCK_KEY_MAGIC) - self.write32(RST_CON, 1) + self.write32(rst_con, 1) self.write32(self.config.chipconfig.misc_lock, 0) - self.write32(USBDL_FLAG, usbdlreg) + self.write32(usbdl_flag, usbdlreg) return def run_ext_cmd(self, cmd: bytes = b"\xB1"): @@ -673,501 +650,9 @@ class Preloader(metaclass=LogBase): return False def handle_sla(self, func=None, isbrom: bool = True): - rsakeys = [ - # libsla_challenge.so, secure_chip_tools/keys/toolauth/sla_prvk.pem V5 - (bytes_to_long(bytes.fromhex("010001")), - bytes_to_long(bytes.fromhex( - "C43469A95B143CDC63CE318FE32BAD35B9554A136244FA74D13947425A32949EE6DC808CDEBF4121687A570B83C51E65" + - "7303C925EC280B420C757E5A63AD3EC6980AAD5B6CA6D1BBDC50DB793D2FDDC0D0361C06163CFF9757C07F96559A2186" + - "322F7ABF1FFC7765F396673A48A4E8E3296427BC5510D0F97F54E5CA1BD7A93ADE3F6A625056426BDFE77B3B502C68A1" + - "8F08B470DA23B0A2FAE13B8D4DB3746255371F43306582C74794D1491E97FDE504F0B1ECAC9DDEF282D674B817B7FFA8" + - "522672CF6281790910378FEBFA7DC6C2B0AF9DA03A58509D60AA1AD6F9BFDC84537CD0959B8735FE0BB9B471104B458A" + - "38DF846366926993097222F90628528F")), - bytes_to_long(bytes.fromhex( - "8E02CDB389BBC52D5383EBB5949C895B0850E633CF7DD3B5F7B5B8911B0DDF2A80387B46FAF67D22BC2748978A0183B5" + - "B420BA579B6D847082EA0BD14AB21B6CCCA175C66586FCE93756C2F426C85D7DF07629A47236265D1963B8354CB229AF" + - "A2E560B7B3641DDB8A0A839ED8F39BA8C7CDB94104650E8C7790305E2FF6D18206F49B7290B1ADB7B4C523E10EBF5363" + - "0D438EF49C877402EA3C1BD6DD903892FD662FBDF1DFF5D7B095712E58E728BD7F6A8B5621175F4C08EBD6143CDACD65" + - "D9284DFFECAB64F70FD63182E4981551522727A2EE9873D0DB78180C26553AD0EE1CAAA21BCEBC5A8C0B331FE7FD8710" + - "F905A7456AF675A04AF1118CE71E36C9"))), - # bootloader/preloader/platform/mt6781/flash/custom/oemkey.h V6 - (bytes_to_long(bytes.fromhex("010001")), - bytes_to_long(bytes.fromhex( - "B243F6694336D527C5B3ED569DDD0386D309C6592841E4C033DCB461EEA7B6F8535FC4939E403060646A970DD81DE367" + - "CF003848146F19D259F50A385015AF6309EAA71BFED6B098C7A24D4871B4B82AAD7DC6E2856C301BE7CDB46DC10795C0" + - "D30A68DD8432B5EE5DA42BA22124796512FCA21D811D50B34C2F672E25BCC2594D9C012B34D473EE222D1E56B90E7D69" + - "7CEA97E8DD4CCC6BED5FDAECE1A43F96495335F322CCE32612DAB462B024281841F553FF7FF33E0103A7904037F8FE5D" + - "9BE293ACD7485CDB50957DB11CA6DB28AF6393C3E78D9FBCD4567DEBCA2601622F0F2EB19DA9192372F9EA3B28B10794" + - "09C0A09E3D51D64A4C4CE026FAD24CD7")), - bytes_to_long(bytes.fromhex( - "607C8892D0DE8CE0CA116914C8BD277B821E784D298D00D3473EDE236399435F8541009525C2786CB3ED3D7530D47C91" + - "63692B0D588209E7E0E8D06F4A69725498B979599DC576303B5D8D96F874687A310D32E8C86E965B844BC2ACE51DC5E0" + - "6859EA087BD536C39DCB8E1262FDEAF6DA20035F14D3592AB2C1B58734C5C62AC86FE44F98C602BABAB60A6C8D09A199" + - "D2170E373D9B9A5D9B6DE852E859DEB1BDF33034DCD91EC4EEBFDDBECA88E29724391BB928F40EFD945299DFFC4595BB" + - "8D45F426AC15EC8B1C68A19EB51BEB2CC6611072AE5637DF0ABA89ED1E9CB8C9AC1EB05B1F01734DB303C23BE1869C90" + - "13561B9F6EA65BD2516DE950F08B2E81"))), - # lk/files/pbp/keys/toolauth/sla_prvk.pem, rowan - (bytes_to_long(bytes.fromhex("010001")), - bytes_to_long(bytes.fromhex( - "D16403466C530EF9BB53C1E8A96A61A4E332E17DC0F55BB46D207AC305BAE9354EAAC2CB3077B33740D275036B822DB2" + - "68200DE17DA3DB7266B27686B8970B85737050F084F8D576904E74CD6C53B31F0BB0CD60686BF67C60DA0EC20F563EEA" + - "715CEBDBF76D1C5C10E982AB2955D833DE553C9CDAFD7EA2388C02823CFE7DD9AC83FA2A8EB0685ABDAB56A92DF1A780" + - "5E8AC0BD10C0F3DCB1770A9E6BBC3418C5F84A48B7CB2316B2C8F64972F391B116A58C9395A9CE9E743569A367086D77" + - "71D39FEC8EBBBA3DD2B519785A76A9F589D36D637AF884543FD65BAC75BE823C0C50AA16D58187B97223625C54C66B5A" + - "5E4DBAEAB7BE89A4E340A2E241B09B2F")), - bytes_to_long(bytes.fromhex( - "09976537029b4362591c5b13873f223de5525d55df52dde283e52afa67f6c9dbf1408d2fb586a624efc93426f5f3be98" + - "1f80e861ddd975a1e5e662db84f5164804a3ae717605d7f15866df9ed1497c38fdd6197243163ef22f958d7b822c5731" + - "7203e9a1e7d18dad01f15054facdbddb9261a1272638da661fe4f9f0714ecf00e6541cc435afb1fd75a27d34b17ad400" + - "e9474ba850dafce266799caff32a058ff71e4c2daacaf8ba709e9ca4dc87584a7ffe8aa9a0a160ed069c3970b7dae398" + - "7ded71bd0bc824356987bd74363d46682c71913c3edbdb2a911f701f23aee3f8dd98180b5a138fd5ad74743682d2d2d1" + - "bb3d92786710248f316dd8391178ea81"))), - # Alcatel/TCL MTK_U91 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "9a97c44b0768424b6bbb0b6aa987a2d373448c6fee1f61fb81f8cf53d70856f0f77e76c06a6901de90ed3b4d9ad4b" + - "9e04eaed42e5657bf2fccf390fe9f5abe1abe8575f07916da69acef95d38874223ec51cb501148a1feea2be2b8ccd" + - "a08672aa423a4099203c6aa4777fed7353c57696b8e0d4020bd6930b828b9846a454cd")), - bytes_to_long(bytes.fromhex( - "8553e31d7a73f6c9294e961815c23f31f2b5ea1116e3c613ae12b26cf285e4c5ca0e2dc8e17d52f96b30cef6ad544" + - "e43205933f20ad17eb8712097aaa23116c68eb6328980b8ba26706105656fa65315688b8232758607b8936d0abc27" + - "dbc97d94e95b4f1957fd1965082e5849c4185ebba8afc7d558d4f5f001ac5363423ac1")) - ), - # Alcatel/TCL MTK_OTMINI - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "bc7b5107bcf46c2cd7758f4bd4d4e9f06b731d9cff383dffe48156d1ad91ff74a7925fa3027669766b3d4c6e28c1c" + - "9310194c34a59e672c8ced38588e998d7b162889dcf06668345f93e4efca34b5fee5bb57dfc38d7623a48f31b382d" + - "e2db656ec1f3b5267a9a8f5e441c61448a283e4717ace6983d01b163e34f959c9972cd")), - bytes_to_long(bytes.fromhex( - "6bc0e84b4f38415bc575dd0d5248c2d182ec55e2ba7a11dfe86815155c709a25bbe34fafa6a9c19344adcfb32eb3d" + - "2eca465c2dc0fd7528a00cc268c6657cdff0b0da1b2ac6a95b94865facb7e1494cedf44358e29ec7e8f091172e4ef" + - "29856d1f45032aa644efc273f141c10cb8281a12cebe202b65f176e1a145c326d75841")) - ), - # Alcatel/TCL ST513 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "df836c16bc8e129dac8e6efcd3f41636981687c29c465b481cbe874ffb14d592de024b70f4fa20ad96c96e4e3eded3" + - "625f314dedb4d8635782f6d668d04ab1167982229e03ede17a7857a22cbf72444a6bee2bba54f32099e0eabe654c3d" + - "a4933926db4d97dcaeb68236df4b3e51bd3c4bfa8b2d47c2534405e4f1c1d43e1069")), - bytes_to_long(bytes.fromhex( - "9ea0f7256bcca9099e5db80757a5f3ddeb3292475c01d2e6eaff8da905d9537a5875e874d26872a8c04b552dd310f1" + - "94ef5a5ea445a50d5c1e6670e5126ef01e5fb1af24a67d07b5a9f72197bc66d5743faab54759fbedcf1fd8ac1aabed" + - "e2c6fb29601b4734334db92a92fc25f7ed8700d307b74a2c435c9ce5b5caba4b3801")) - ), - # Alcatel/TCL MPK_U7 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "db0b6e89fabdc24e6e7379d25b0c402686537ab6375d8b2407beaf44cbbef27e04e90b556801bbce5eee2a7ec636ac" + - "825667dae3578eb7bbb66701bc62ee86f28fc14d57e8637a2ddcee00cc3ab87dff4155250c2dbde9ae62f3d7a9d5e4" + - "a265fb0a8b23c082be263d7788e44d59780b47a31b25dc588f81902be419f917933b")), - bytes_to_long(bytes.fromhex( - "c5829b5bc34253f090db831f5085cd5a6f88da7f6f90e3a3cb6fff6e53218c5a616719971b3f64ef02de526719a7b7" + - "09978bf1ed48c821981b32ea77c9e536bbda206fad74946d02a20d17120f89419b0daee2d8a47275768930ad53c876" + - "afebffb6805483c1ddcf6c19f3566f0de494838afb51b18080beff66364de5294581")) - ), - # Alcatel/TCL MTK_U8 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "9bc517a0dfa87a7e240000c5f42cf31905ab93d4bcb95694dee85282867d5c83270aea0b0948d66eb39d8500aa6c8b" + - "1069b8ee784f75948958f7bbf627d6ed5f286fd3bd4df60a6c9490cb319448b22765aba9329820eec50f62f1ca0b6b" + - "3322aa27747b26855a1f1719cf0c4060c9f5a6a3a60ec60fe6e04e7b044e5da994e9")), - bytes_to_long(bytes.fromhex( - "76ca90a16bcf7552db2b716b8531fe5617bfe86635627647e3d27291fdf47e67ba8f953ac362dbbce2977f05a9f24a" + - "ff4250f8f3a14d3ef09b7b99c9384aad0c53104f87b47d7daea3ca725beb233d127ec342ce0619b16bd3d5e44371cf" + - "fce9f23178ff48dd42fc4450ccdb3e2d63437ef9dfc0296b12840ae85d472cf0135d")) - ), - # Alcatel/TCL MPK_U91 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "9a97c44b0768424b6bbb0b6aa987a2d373448c6fee1f61fb81f8cf53d70856f0f77e76c06a6901de90ed3b4d9ad4b9" + - "e04eaed42e5657bf2fccf390fe9f5abe1abe8575f07916da69acef95d38874223ec51cb501148a1feea2be2b8ccda0" + - "8672aa423a4099203c6aa4777fed7353c57696b8e0d4020bd6930b828b9846a454cd")), - bytes_to_long(bytes.fromhex( - "8553e31d7a73f6c9294e961815c23f31f2b5ea1116e3c613ae12b26cf285e4c5ca0e2dc8e17d52f96b30cef6ad544e" + - "43205933f20ad17eb8712097aaa23116c68eb6328980b8ba26706105656fa65315688b8232758607b8936d0abc27db" + - "c97d94e95b4f1957fd1965082e5849c4185ebba8afc7d558d4f5f001ac5363423ac1")) - ), - # Alcatel/TCL MTK_6577_HUIZHOU - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "ac2a2c19bf4beef4272df8899cb648f90453e53faa1dd8143327978620ec74e6068a8fd051fac856a59ff0a2f3051b" + - "7512f55fcd6eea57262a5a24e141b2a9c105509b79976b952a4cfa0367535aa1db83290f18f62e2f604bfd5fee3fb6" + - "fa863ca5546e359e0348937e5b62e47f645e9552ebd2e7e516c13a192a6075c55351192dd545dd90c34fa28c695d66" + - "43a2449c0c7acc9d003b9bb4f9d249bc19beb8ffdc2d6115260499156461eea896361aac9a24ace3bf6c81db3e8c32" + - "fd6d74d876882382618c7ae920ce63b0c33a3ed6a59642acdcdccd68f2e84f6b1dfe8e4dd33fd78208c750f877a8ed" + - "dbf32b7f6cd28bc7f62a79e1281cad49b29ea1aeeb")), - bytes_to_long(bytes.fromhex( - "3d6ff33ae0ec1d029db4a6fb9ca3e41890f5cb5a53bfc0ab3cb2053d85243c7715a07ebfad719bea67c252a223ad0f" + - "e65074a5d26ea14ba63ff8d92e553e879b6ce51e065f05b23e5d27deed116ec751c9556ea0cec11e80f3bd206da9e9" + - "072fbe1695b19a8a9fcb576f00f7a268df8d6d262127ab3f3246941004f25534ac8d2f418815d15f4a5a663a2f1383" + - "115cb3e8bd263ebcd92c5bd1b92644497e15a1b41e77e648cac179182d83c496728fb52b9a1c600954ad0c3eac5d46" + - "33d519c88daf775fe090c2f2568c7c91a8938a2859245f100fce764033147d84d79075a81331ecdd170d2541832ab9" + - "161dc473cadc1dfbc17df2be89fa6d6c13d9db3611")) - ), - # Alcatel/TCL MTK_S_2019 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "e4607e6cf78f5e4857bdaea441f8ddd35a7576f552b4ad2c8b4ee7f578c0590d747b049bb5014e06f8350dc6b78d5e" + - "0ddff1b4bb8af695e4a338a154596555738cccbe6b58eb43ae221df9babfe9dda6ca770c25ab42ff986f946756b46e" + - "c553daf7616f2843dcd6a48f48d9011c050e7ed11c99f61624f057695d622088f868bf6a3966f25bd8ad58db81623f" + - "d63f2b91f3ded1a5be0efb69a64bb40d8bbfc251d9c32fbf0a1bad516751e9e04439392c59ba6f856b5c0bebe0dcc6" + - "7d7d4f25da5342aba94680583ed76d94823c6f62e5e7484f7e2d2a467d167ad3f5647f958dbba3eb66f756c851a551" + - "38d1ce465333592969470fa8652df2e38bc380ff4f")), - bytes_to_long(bytes.fromhex( - "68d01875ee507057075dd8cf2e3007aebeaf767f350c130684911c483eb918a5e235ab71c2eaec62aa7bbeecdac518" + - "cb8962272e83a2943cb0e486b66da8e244fbf3e3d8e4a065198032fdb045f011784127cdfd63d285f7f20dcc37b0eb" + - "bdc8b49020b9a16333f196e8e3e8246835b1e76615985ba6e221241d096cc5bdd7336d8b22704dc1576ae0ac252fea" + - "8dab129756a609f347d60e25d8d085cf0c8775631d3c0e54e50fc67dff2c55148b4e78cf36987febb23e14ffc1da9c" + - "b0adfc139d509826aa98f6fe0e25ec6ab6442e5a7cebbe6454ff06b897467512cdd8f0460201125d0bc9cc2bae2598" + - "40722ae56d16b06f9e0515a2d128a23b5b0a1896e1")) - ), - # Alcatel/TCL MTK_6577_SHENZHEN - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "a29274e3085c260de63f571646cd2c69737ba5a0bf604ad31cf6a86d6a9e08dc931ecdddb7404f4c9255c72b5debdb" + - "69114146bdd7edf6b38505b19c4d18eb0e71516d4faa871cbe1d2e24e15c1877b33587a8bdd1e7dfe1b17235d1ac43" + - "1c27cae07804014c287fbf2479e6b4b80665898f7cbaa7edcf23daa8dd95f63039fe7eb641ad7c05e221d29adc62cf" + - "84893ffc6acfd44a9d2cd60d5e0f94d1c29d317bbddb3f5a324648069c72857cfc708fc9bd8a3f7a98051fa9835af1" + - "f9c71d80236334ea51cbd52e57e5a7950beb394d9c97bcc32591d9700106b0abfe1dd2db9617fb7dd2eaa3885630c3" + - "ce1dfcf087c814b480f30c411f3071f12aedee4077")), - bytes_to_long(bytes.fromhex( - "6d209285b39ee78c7cfa17a34473855463c8a42d7b494ff0d6885c16d672aed0219193ef388b5aafb3ab10bef394d6" + - "fb7831b122ce47564abb084f68f3f7be113bcfc4e8ad3774fbc8eaa8a6fe030e96a56022cd0891f59eb2564ffa2700" + - "056e50a8cce72357d3f7ac7ef7b4fdaa69e0ceae1ab3d0f5b90e00414a3cd7bd17afc3b6463ef43bfd22788b68fcfc" + - "c2964421b1b622907d8c75e8d83193a579e50c26b0beb93e53e2888cfddafefa03c368c68e6d357087f1bf0800e1bb" + - "4f0fc97c092a7e7098cb60cad71e292b506c0cd1f428aff3192da6818351a780aa1b4cce0dccd15adad815b610f445" + - "a6571d3c65d2c44da9057b5c8970cded0dfc3072c1")) - ), - # Alcatel/TCL MTK_S_2022 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "af823063550d6e5adcca01a1ae1fe357f73d7e5c60cfa25e4beac24304b70623654fd13547de869899be532f45f3c5" + - "ff26b50292dccd112dda1478721c05304445058499bd00f6b104e16fcf2d0af55781be147787227eff54a25dca42b9" + - "d6f1fc8f4b821c099f483c402addd178330167aa9b1021dae121bb2bdcb0127ac47ae866a1579f2399c70e69293ddd" + - "3b0bacec2df9dc518aa0c58c2d7561c5783ac32e57b91d16d6c57764755894963733b85f19f9a3bcbf624199cdd1b3" + - "1cbecc5448b132c3799e2d0e569f0ba61245796db5876820ef125f4a230039c5cd16b2414855bf3a3b565f81787a4e" + - "9b264c9bc855b4fe7ac17caca1bc5f070594a9c175")), - bytes_to_long(bytes.fromhex( - "3be4c4d89124e53d12cdc922c0c6571224e8925fba160186068855c5032de6655be49233899432008faef8ba5037f1" + - "a0b237e169f6f9f05be2694bf53d04b44507fceb1480007d2f49c8191ced7528e6b4fb06070851c85f2025ccb60271" + - "631def9f831822b351ed17ca9a165aae97516a6c3940971d17e927f3befb43432c1b689cc660a896237f090d7b311d" + - "9e39aa1eee5a4e3af00843c965c30ca9aa5dd7767809d27d4f66777661779d2a1fb90b014329a1973e67b8989de924" + - "e8ac98673667e4f734382f87f0dd0300d360142afa772d5beca2ef248e90a7bd32240c4a5b5f41aed3f4b63f90642f" + - "138186fe17afd713a3242eea7b2dd0f32b06b67681")) - ), - # Alcatel/TCL MTK_B3G - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "cf8243d13128ed39fadad9ca97c15585d634f4d9b38dd59e4eec4b0b93e4eb2fd2d96c425855e69706d5c11021a8c2" + - "e08bff87b424bed2dc3efa9360bf1bcf80c96cd4ba9c39eb79bfa2bf9d4efc5a56798ccd9c6599ede595aea6440866" + - "05fbe55b2f7719fccbafe0c95956fcffb0ce77a9637c9ed66e067165cbe901eb041b")), - bytes_to_long(bytes.fromhex( - "12ff6a160cda225ddc898cc6ef7dd3c69d05dc24d23b7a0334568dc85191f3b63d278ab1c8449507dea8533496e04c" + - "77225a12a27b7abcf34d10c3cd67b1b41d7c19c44114e344a74396541d998d7b76ca06d0322bf3333684652528df22" + - "021c190bc38acdac2a3be6e2d0bce7f1e3c77a71750ff17895cff9c6225275a3ce81")) - ), - # Alcatel/TCL MTK_E8 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "bdef438901dfa726cfc2cca59d12f009108b8e1fd7dd9b91a5cc71fa7b1e36c8783f9de5850050e6505fc715c50bdd" + - "d59a3064b05214c4365360cb98d080cc38658a94695184b564e8e8dcc28f70eb0122a4bb7662e3a1f34c057ea52381" + - "9ed02ed46bae0cd9530b0536cbe7a1ba3f33a45feb2f92ff5104dc32ebe94f249eed")), - bytes_to_long(bytes.fromhex( - "95b32d61a10e6c2a54fa4e5e020d590f6bf0f295fa87fa03b3d00dcdc4982dc997ad5c7ff872255141ec1b77f714c1" + - "4587ffb87c985531c937b245062ee03514aa796ad79698c40c49a8b3c54ec66fc20deb874a8bbce87239c414f54136" + - "7a350d525fa6bdea77e4cd3078cf7ddf22a8aefb0c595a6c76285d837008c0a77e29")) - ), - # Alcatel/TCL MTK_C3G - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "c04e6a1be49c5a57accaebc837099b40890180fc046c3dca58745749d0979cadb63b8b4573fafc129c2f89ebb64c4ec" + - "81339e862f5638ae145e2c8bc291097e6b90434ff3f3a1e620fa77dcb6d963f53b79abaf4eefb8a5d4378cdf4ab3060" + - "a9901909fd455cf850ae5adbdf035cb3cbcf572ac4dce4bc1321562273a461ddf1")), - bytes_to_long(bytes.fromhex( - "4375be875664fad432cb6476f1c7aeecaea3166a51eadeaa32e96d0d79dd159b6287f4cd42685330fc15391eb4ee83d" + - "c6fd22a913c5fd5023d8fd6b71af8b530209b5355acf1cc6e6397aa6e5d2dc92b7d37635d391cd22a3aa337d8fc0a27" + - "4cdd7d6630395d13517e32c91daab2f5378ed7a1be86c81c2e775c249201f2c221")) - ), - # Alcatel/TCL MTK_K6 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "a7e3089840bb7a9a7a972e8c88d7c464fe40dc4771a2df0da981079cc800f5d3cd45ed9eb34efac6bf7d2aa6dbc1266" + - "285f50d7e86e6e0e5dc6d062bc8fe871672139904e5ffe64c6ffb4ff00817ffc0ad4c18787a253ba5f7f7bd8412e5f4" + - "6e2c264cedf174ed5163943331a658b434c59ec9e11b269e829ab638c80c4ebe51")), - bytes_to_long(bytes.fromhex( - "4f65cda0c3ac66753c58d748db46bfb8cb8dbd1f849c7444afcf37dc6bb218904c5a2fe08808680d2a6e7587681256a" + - "6ed9751046fa42ce44874bf2061f40dca4953c345c2f156e8ee7e2f497ebc59b3ddccda98584dfc999d213d6782f2b0" + - "faff59a9671cee801defeb5a51178a7b95c487aa735b463e8b1321b6ebe58c7401")) - ), - # Alcatel/TCL OPK_VLE5 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "cb676a5de86e2c7d75a17f10fb2e3f81a473e5d2d088833d8c1928ce78caf1000aaa607c83f55b57dc07fac7a9ecad1" + - "600df5d033986c02c003884620661a9674042a835b99cf8a024c27a10410eb379ac69e72d6f5a9cf72c185262331c98" + - "879cbc225de835d864983d2bd085f1df99341d3cbb0ba3b0a50491c8ee98d691b5")), - bytes_to_long(bytes.fromhex( - "4befe0eb0c424d83cd2dacb59740cddec599ab3c8833dee354717425993d12ba5441056297153bb3d2667c3e9c76caa" + - "bc349a07cfab60efa9e5e7b35e971fe7eedac090a1a5a7d8a2cd59de84762f09cacffecb65bf70ed504243721fd0e09" + - "4c3f216fbb85778ad82829658232a2f472919e992060394e79f2aada9e8a42ce21")) - ), - # Alcatel/TCL OPK_U7_1 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "de15dc10818e30c363bd0a87d5f8d89b832329fa25b8388709d94e9b0ee4efdd3e24eed3d931f01ea1b0e2b76265d7d" + - "c270ea8012545bb7245c286761210bf46c6dd1fadefc257fabebba29bbbd86e8336460e5d21888a319156e8ba529e4b" + - "6a200136ae4aba447fb37a357028142d8b16d79a421d513ecd9b9ec0d908ba8217")), - bytes_to_long(bytes.fromhex( - "18e2fa361f4e7fc86574d9a93f2113a4d99d272710f303e29e07ebf71444335ce789dbf9816d472b27935ad49202379" + - "e44023071706bd0058e2bae45ace0938e75610579240ec87086d27fc0844ba25bba09214ae43037cb902801a58915ce" + - "58c6f805fb3ad6cf7996f25e0cf0a94c13e04eb4370ed6b93c39ba2136f8cfd101")) - ), - # Alcatel/TCL MPK_U7_1 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "b6a33b825b0cf6abd3c9d39d1c8bdce50a41f9bd5ca2de52c4c447afa9943f5c1365d2e9cb7961ffd877fd38696b447" + - "9a8bb7eb8da15bd8d59a1cd7e5ee517d1a20f29bc66974f87796a11f7537529f8f46ac57861484808bfce9ee6cd6527" + - "f7fe3bfd57b4a7fd46f8dc047d6c8370de6507620c2b9a3bf864e8ee4c4d2abda1")), - bytes_to_long(bytes.fromhex( - "88a4477997b57337cb144d0656bd2d5f0ef59d6b574b631a79ac8015a4c20d454e1df85682ad25eccc7fb92be373259" + - "fffe58741b5a85e50caa68b9fe84f6e295d2176b96c20ff819e8bb889702c474effe1a77710ff3b93e896fa488f1717" + - "c75e46a1b0f5898fcacfa35943f1abf80ebb665ba7fde59c4baa61dd2f6c5ec001")) - ), - # Alcatel/TCL MTK_S_AT_META - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "d1eee63f19d148c904076c507aa8d4f6c7e931a65476fe5231c06036fea2ecbcb8c811882c4f70e6e3523be73f5c7a8" + - "3570f3a40bd894399a5ee9f903e8e745ec4e4e034495175b167192535843f06241d6477e3ce1ad5270e590db9cb9054" + - "04c01aa407433fa2c2ca1f8366c1623fa45bd5ee68e3145a57f9af3e6e68fce41b8c682c0e07f3c48f4b377951b23b4" + - "67fea0d4ee0e67c0235d0e83ae27e40ad1c060063ceb966835a0ac1eb68066f8b55775ceb7b444ffaeec19548a42247" + - "ebe687f881a0c8e5277beec22241e2ddae1c21cec8046eb005302812b7ef42ac153cab317bbeaad73f7ccaced38c433" + - "530b7e0ad464150026025a9a3ff5d45e025db")), - bytes_to_long(bytes.fromhex( - "8294e45929b8f95a380c59fe715da5225fd518920a85fdc9a8b2ade6675b7680293c21539fa4466907cb3601b072d8a" + - "debb0481ecf069baaee00d0f5cb4396f4ffea11dfd41f3c62fdeb312ee9b4be2026bc40aacd9ff928130fa7af030522" + - "8dd5e47c551c2a701653dd6841b9566099de99e2731194ae617ca8d9df99a47c49d9f514620ea1e3742da8dc7dec675" + - "6403631a274dc226c6121863e4a571a120b63c38d134853df5b986fac1565e1f3bd8a02d239462967e9c71cedd9ae0c" + - "0eec330018ca553cc7cc2fbc73d6ba37be2fe360644ff69ab7c734264675c057417857df4ca206dfdac9a5621f9d8e4" + - "5dd2e58dc8b4198667de3efd1d5bd7ce007a1")) - ), - # Alcatel/TCL MTK_B7 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "e3e3166f47177de4915e915a9d555d980afad96be22cbb8a02516ac8fe69657bd10bc6d072046dcd33e4476e24f128c" + - "b7ac613df140cefe71abf080a74d27c114635d3954c55299f6f81c2a0aa14c4c678307f4b3bbf0c64f0006051ea7573" + - "b5b0cc290201c76c4d272c981b1bb19bd0a0a0ac046e6e63b0f4cf88d2c98a5c91")), - bytes_to_long(bytes.fromhex( - "776b1deb8c3e943b3dae67cf2b597ba55c439dc1fa10e4e9ea530df96bd0815cc3ec3ef0267f89a699c5cb64bdb91e5" + - "e9ae4c7af03cbcfbfb4755cda55e3a31d510f96a102b5aed90731788a426e371f8ae24f660403377cc0836a06b2a8e1" + - "59bd177f4cf68e36d447e4b52ca63611cd8416c1efcac52143106c272f7474387d")) - ), - # Alcatel/TCL MTK_BACHATA - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "94cc529bb1af0ab8043f09e3ca612d787cc19485d3769546e750f6edb844979ba8f1f9afb8b93b521330b74713831a7" + - "8a584f7b24780f92dd00e5d56ce8defa3cd39d01752e514a4c2ba7499f334729622049491b1aecee6c9e1c867e996c2" + - "94b10f5d62ea4504e333424b280162087296c300c01fdf75f47d874df40dbdb94f")), - bytes_to_long(bytes.fromhex( - "09fe029a23ff7e37c749386fcc9a640450546b95e5127489d364d380393c99f5c10da6d7cf0ed955f4a5f3d8d90d97c" + - "c7c49069d394206f9b59c11568ffe66163eae377447abb103cd5d4256885cf7984b28cff8a096dc479b9196d66cd534" + - "cbdfece7a61de04110bb14a3ba5e0f20ae0bb4d82e18fbff0335904dc09b829e91")) - ), - # Alcatel/TCL MPK_VLE5 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "a62bf756a70657b6b560588e85e662e181b6a61ae466ac3d0d2e971f160e88216792cedfb1979b3d6b665068eee8a86" + - "99888cd74ec9482c61ae7eae3571e50beccdcb336477c26040d09b46dbd93efc0fece4adde2e00c1cbedafd6ad7c43b" + - "d621675a6a46425c5cf6182fc5602be443a372fb4ead4531e64285ce29be913285")), - bytes_to_long(bytes.fromhex( - "7005d1bf5be81db7b17c9b16b1d407b308b42e3490e75a93e9d00fd6c812d1d8db2f1041a342964808a037f315a448e" + - "caf0502a5215c58f0de709c5bd87e3a65e0291a1a23547c76cf437ef1d9b434b70dbb417049a31de9ee7becf218a5bb" + - "63b05fb84ff49d1e6aaa4b9b4376f47417435ecd85ccda63be9070e7892ecd4a41")) - ), - # Alcatel/TCL MTK_C7 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "c1d6c392828f4620e455c138840ab448cfcd4aca821663335dba9c51dec9b8198301ca6b069adefcd1887f1cec31c15" + - "674ab264daeeb82398b419f08b4236904203c48a7db8724f1773d04a6b8c88cb38907a00bc53e86cdb2bbf479a68b82" + - "41382bdc5ac6105270efc2da4cb91a36459ccf6a2a87dd56ec4c331dd419ba5931")), - bytes_to_long(bytes.fromhex( - "31d28ed040a8ace0d56fc94b4a7d29dbb135d62c7905621818d657499fd6ff6fe7417592cececdd3f3d37ec0a361228d" + - "a34d3e7a2724b7832ced00008fb4ae500357fc3d285c64fbf7efd4bd1ee48ed40190296171acc3c2d0c69e89da5a8fde" + - "7e0ba7048aec6bef1bb19646f883fe9d77d8d263545e7c00e8604be38210d065")) - ), - # Alcatel/TCL MTK_MARTELL - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "a800d061e4a42e4c3453a17cc8daa974e23bfaa403b4a60fad6d3516d8ec035c1ebabdcd60009d9b8c639954e616c6c" + - "b6cf821e31e58772ffc366e6ffb7314657567b12279a34dd69e46b8a4a628dc2dfabc68fa1d89388d2058a97d2e3152" + - "0b4fb04bc2f963e110e8541eefd22d90a03eca806b3c6a20c6bd1a7468e61ea1ab283ed1bc462dfae189eb5fb451f80" + - "2fb868cda9a7409aa52e42b18882e79f4f1c2377829fafd9760468bd1db823bd9080378cf46ef405d91636cafc03aca" + - "d9fada6b0446dbaf51e9d533887e4a3a8f62114063e0b8920684c28bfbe256aab26e98751166358c201347ba6c3b36d" + - "49aab6302fc248eea3c254e15a08429fd2149")), - bytes_to_long(bytes.fromhex( - "985e549fd42c0b4955d3db8c3ee601f65e10a3db08f957fab4016dbad0f60c7e09e8b7a782404cb0fc7c805dfd67fed" + - "814765ed58b7a146ed2c1d31b80e3f845a45b6ccda5a0344247be404c23debf027c7b5082373372b49bf78d9058caa6" + - "6c57d3be829088c3610034faf1ea9f24a21110bbb3865182747ca1779e83c6983c189b3f19f3df49e5f9cdfa57f4f69" + - "dfae53e19ee0b1ec30986d59ad11f52bdc022a9499dfa89f8546d266f6026aa307501ca5a619f5413a45ef38f139c3e" + - "a8b52f02fbc8983aa878052d9108668ecfc8605057a298355d2f680c34630e224c57dd4c4f2dc0d51766ef7070daddf" + - "a3c885a3f94d76c943c6c1054d338e2323b99")) - ), - # Alcatel/TCL OPK_U7 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "9f94e8f1171fed4b427629c928e807b2220f109ac70a3d5b1b8cbd295bc3fa3226d3903298cd81319b9b08a6f8e77ef" + - "ad0b04139b686ee0d1586175913ad6f65d6cf21bbc7f769885381ba6d840414b26fe7b9b3e393acacb3453e3a0cb79c" + - "a21cb38a42685a03462244fdb2a5f1d8b9e20745fb3206e799655c47146310911b")), - bytes_to_long(bytes.fromhex( - "61ed86791440c26491b763730f483c18c32fcd77bdb6f9e9e3e11cdfb9716d22c392c68556219e2b6c1ada57649ce2d" + - "e559c239a9ff8f33252480421e4a2649df8e3ee0095c9bec361f25a5ec67d0b4d96c73404ff8a115fecf1173a656884" + - "5480fd4423b5dba2e5111335655f3bc2f3fec65510648571992e010ba0aaf243e1")) - ), - # Alcatel/TCL MTK_S_2020 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "e4cc4967bec817bb348468024c3084b15fd4f7810c8a9d078a4f51cf9974d2e3bae8d5a19a85c0a73befd0675100e64" + - "2a3f425e3192dfb1de56928c37f45fc142adaa65798ada863b84d4b5f22c3f79b95cc201ac7c292c99475453a62b7b7" + - "e06e84833dfca7a0df931084932a80129e543c6d24a13c5f2cba6ef5ffed9efd4dbc20496f5194f0d1aad9d789f3257" + - "7f8846df9a14778504ccb5dd7507114c148c1937fb99da15f9596d4fa052cdaf1f66d7e5e0c0793628752bf9af3c4ac" + - "67e21c21d170ad448160761bddf586a4900fbb7dcc44467f1550d15db774d7cacfe3105b465321a5f95fec22c2011d6" + - "16a5c0e22f0535dd1f969202be56ec015f891")), - bytes_to_long(bytes.fromhex( - "b86887499d157d3b1feb1041b9d2e94065732b41d22feebce317676321d66d1babcc7a53544e35a714c207811e62d13" + - "4291d616417295e5b0c4aa3d65e40b41a352822263c22cbb4041a1883c76b97a8c925cb428a7b2300622ddaec62209d" + - "8dc0c60159f6c7ccfc26768bc469deec22bcd62f49f4c2ca1b2cf0be49d6e5ec563279cdee79c92800c6c965200d316" + - "c79285551a54359b37ec4173eadf4c0506d857ddca4831ade7ea8f13097b4e2b630a2d3eb9c57abcc65f84d693c55e3" + - "61763d8d37bb40cd6e2520684ae05edc62a36cda6747509600f4605b7ed924ee1ad49e66eca1176a20794600173dbb4" + - "2fced2f1fa0cccc0af3b56d58453bee420099")) - ), - # Alcatel/TCL MTK_U82 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "ed2055a7b95db86f7e3101196ae6218015d70d03df6fd5787de150e82927443097a90485757743447e2f4641afcf510" + - "acf585f73e79c45b2908d5de8835221a76d93e48ca465ffbe0dd76cdaa98550ab2e7b84a6470d48595742fb54a20444" + - "2ce67bab989c69adf86457e313eb24c87d80aa7d635449fab0d97b6b08c5f7c86f")), - bytes_to_long(bytes.fromhex( - "3f5d99a61561d70c6c335a30d9a11fa8a3ad70fbecf46c9e233d57aa827cccbb137c060a47e693e234ba1b532851053" + - "e17446d5582b9fee205c0d12c7613378c8b8c8c0184cdba90d56a308014aac0458c5572699d599a15ba36146b6f2e23" + - "0034708cf67d31ab837b7bd8e5967fd9a7bf413b7d9314302b18e48962d01cf6f1")) - ), - # Alcatel/TCL MTK_JADE - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "e8490dcbd3488278442f78ec5634ccdb8befee081ed0d19071480a10c299416ab8d0e9eb19e8975cac260606463c51b" + - "b62875ab24690d07905b9c48fe60086da12899bce3dbed91e0157cff76f27a1c09b37e837e7acb71da3c0e30564223a" + - "e20216fbcb3de5e93c2d7f98827d61441b988e57497c1ddacb87cec1e73139bf67")), - bytes_to_long(bytes.fromhex( - "69fd6b9e25ba604e204ec90e8e0769b28417e6b52dda7ac53deb712c549f398a48ea8ad20bf065a093ac85f336f92f1" + - "221d3413f3793bc8c7c6057a091828c04f6fb695f43747d0d22de100bccce70ac7a8f9d092afaa7d44fcda99b12454f" + - "8c887e383c69e7e21ad15203eaae51d803cf35da09c8d536139c658bebfddccf01")) - ), - # Alcatel/TCL MTK_B82 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "b6a33b825b0cf6abd3c9d39d1c8bdce50a41f9bd5ca2de52c4c447afa9943f5c1365d2e9cb7961ffd877fd38696b447" + - "9a8bb7eb8da15bd8d59a1cd7e5ee517d1a20f29bc66974f87796a11f7537529f8f46ac57861484808bfce9ee6cd6527" + - "f7fe3bfd57b4a7fd46f8dc047d6c8370de6507620c2b9a3bf864e8ee4c4d2abda1")), - bytes_to_long(bytes.fromhex( - "88a4477997b57337cb144d0656bd2d5f0ef59d6b574b631a79ac8015a4c20d454e1df85682ad25eccc7fb92be373259" + - "fffe58741b5a85e50caa68b9fe84f6e295d2176b96c20ff819e8bb889702c474effe1a77710ff3b93e896fa488f1717" + - "c75e46a1b0f5898fcacfa35943f1abf80ebb665ba7fde59c4baa61dd2f6c5ec001")) - ), - # Alcatel/TCL MTK_S_2021 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "df85f4c4ae8c98e78142d403d002276a5bf9edd17870caa848fc45720e8b4be94f6f9a47181417840a5b7d4fc365751" + - "29afd6a848a0de3f62fac5b5f687a2219cab8cdf2e7527d6af3c6be84eb99bf519b0b210960fc8f5223c9bc38e8f20d" + - "0267642153cf370312b955143e10490c6a207868ac7ac314bbe10f6063a1ba606e28d248a1ee3e7000d12e9c4ebd47a" + - "e483b625156b82026fcfdc36118198cac1463aeb56bdfe260efa38ac1d4123c13fe59e0fb0f2f895609c117f7a39fb9" + - "f27c356d4748cf7af41e15ea68c6c7c64c4d0a1acb4632965e0260d9b08de9fd81b82050c9929b79ee865f89272483b" + - "6fed8a409d6a1af2429d24fd358a4b4da4e77")), - bytes_to_long(bytes.fromhex( - "cf553c03ac3cf21fdb4097d4a97f35fc6c305a2e30dfbebb7667ba2adfdec99d3277bccd314281c592ade680b42849f" + - "de6122659a68cd7e525b764520d612c7c6c141bc4b2594bc88732d4ca0a97e464d7c1ecf4fc2788f1920cb030c1b2b3" + - "ea84e8d6191d5e53d56c5fc495051a1d0fdbea947d58a9d773a68152d157d4bf57f2b4fba8182f96ea4c9b798018361" + - "054f95b251089c786be542c7881c49b077ad52af25a359bb26257170706217f66533cf4b8379a1fb7a30c955c8ed4c1" + - "c6dca905ce6e7e5e92ec7e1bda1db44cd187a9e5137fe44a37cfdbee173a49654994926cb2fdd7857dfc8978d9de73e" + - "899e18f5dfe33a64e6414fc5d93738f8c5591")) - ), - # Alcatel/TCL MTK_MINIQ2 - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "ba1d10a245e60471e8d3138611615170f213cae5b895c8af35eb720e2671915f07dd6ccb5384d7580200d18f430c894" + - "05dcb0be6a5e91cff0fda970e292d5f0704720473bc61e19590539b1bb08ce2b306755db1f70cf1193933802ca44281" + - "fe01699f75e56fb7660fce0342ccc284d497a17ad7d3d15eaa20ad4c67bd92de61")), - bytes_to_long(bytes.fromhex( - "a475ba952a9f2f9e58d6ec91b41a03158354ea1e451656d83d15691c07eca3410e7a2401283462f66a0ebf1f91682a8" + - "0ae61168b2260f4368f93e197a9db65f4139523ef5449a6fa77568a9ffe90e0a34a37f99b7c1ec6ed1683a574d90459" + - "93679ef73299991cd43b96fdba6673ae4318f2f635a816f8559d325f9ebe428a01")) - ), - # Alcatel/TCL MTK_HIGHWAY - ( - bytes_to_long(bytes.fromhex("00010001")), - bytes_to_long(bytes.fromhex( - "beca753fd31ef104bbb01b0a7c560c7bc040d30ea18f216b64b7de416b695af2b3350ecc02fa5224b412793f876a7bd" + - "bd8cbe7fecd754aa8214a27bfe7ececd8caa16959df83bdaeed524880a820f8dfe601dc70f164ff1921baaa06efd8c5" + - "84c22269a109d16287356fd30e7eb02a1365ca93fcb8088278f119a2c7298306a9")), - bytes_to_long(bytes.fromhex( - "5407571c851f5b877a2255c6887c5d832369698b481c81db8ac07062dfabc7229d4b00f95956665743f7deeedbf54a1" + - "7c9a404c97433f46d983bd0c5f49fa4b013b9d86e5f1377f563d8299675c0ea2b81f51c33ad74a265184df9389eefb8" + - "e72d2f0585e4a41826b8846b0ee6da5ef8cce471536109fe4c658735247ebbc301")) - ), - # Motorola G13 - ( - bytes_to_long(bytes.fromhex("00010001")), - # N - bytes_to_long(bytes.fromhex("DA61964924F441559A1F8B5264CEB01DACE8E417413BBA4657F4556811D07B85074FD69" + - "87F315A7492E003D03C57FC83D3B889F2D4F136D0989E515A08628A7B16A300217162DC" + - "35C340B1127046AA86649B763AF97F7C9871964483DE6695CDA2E8CCE82E1F6A0F701AF" + - "8BE767BB16927489524F8FC9A2C280F5692E850E4C4E2606436CF2E253147AFAB32E6B9" + - "2A19FA180C43CF480619B71B3D6A7863C7CC376C0A36BCF8BA3DA89CBF3E6DAA4691DCD" + - "769C0AE4535E502A9966AFF3F123C7A0EDA2DF04593B0E1FC60DC688F2BA7617DFE67D3" + - "1854443ED95D2645323728C594CA49DAA9351A572E3182D0A1B3146C92CEF87380CBD2D" + - "EFFEBC4E8F420D3")), - # D - bytes_to_long(bytes.fromhex("AEAC47CD11A5DD6C5EEEC43D8F2C536A2917CEF95AD02F5A7C978E88C35702B590F7A72" + - "A2AF28AEB9B5F5B2D8056D03F916595D189C9B6927AC0874980537178AACE8E1831DD65" + - "4E0B72FF2F44670196A57A43C340355CAF828B331A5715AED4E06D5D18896BCF25B201A" + - "0DC9760B0B2EF1CFB4EAB6940D7F8E2EBD86DC1E678AA69F6B0BBF55C688BF72C2123CF" + - "42E367F789E2592CE281C7C4752E14F6FD00D54610977DEF753E3890F12F704688537E8" + - "60D81142805750B805E7CAE3AACDE1CD7A272D227E9F8CCAADCB4D06489664627BAC46C" + - "AF5DA0F0740CEEDEBC7ED1C1D1EB1E37C6A8A9E6A0454F742B3248448B20C93D5FF6E5C" + - "789907A862C90A1")), - ) - ] if isbrom: # e, n, d - for key in rsakeys: + for key in brom_sla_keys: if self.echo(self.Cmd.SLA.value): status = self.rword() if status == 0x7017: @@ -1175,12 +660,12 @@ class Preloader(metaclass=LogBase): if status > 0xFF: self.error(f"Send auth error:{self.eh.status(status)}") return False - # e = key[0] - n = key[1] - d = key[2] + e = key.e + n = key.n + d = key.d challenge_length = self.rdword() challenge = self.rbyte(challenge_length) - response = generate_rsa_challenge(n, d, challenge) + response = generate_brom_sla_challenge(n, d, challenge) resplen = len(response) # 0x80, 0x100, 0x180 self.usbwrite(int.to_bytes(resplen, 4, 'little')) rlen = self.rdword() @@ -1198,14 +683,6 @@ class Preloader(metaclass=LogBase): continue return False else: # not brom / da - """ - # N=B243F669..... - for key in rsakeys: - rsakey = RSA.construct((n, e, d)) - encryptor = PKCS1_OAEP.new(rsakey) - encrypted = encryptor.encrypt(data) - print(encrypted.hex()) - """ return True def get_brom_log(self): @@ -1351,10 +828,10 @@ class Preloader(metaclass=LogBase): bytestowrite = len(data) pos = 0 while bytestowrite > 0: - size = min(bytestowrite, 64) - self.usbwrite(data[pos:pos + size]) - bytestowrite -= size - pos += size + _sz = min(bytestowrite, 64) + self.usbwrite(data[pos:pos + _sz]) + bytestowrite -= _sz + pos += _sz self.usbwrite(b"") time.sleep(0.035) try: @@ -1377,7 +854,6 @@ class Preloader(metaclass=LogBase): except Exception as e: self.error(f"upload_data resp error : {str(e)}") return False - return True def send_da(self, address, size, sig_len, dadata): self.config.set_gui_status(self.config.tr("Sending DA.")) @@ -1415,52 +891,3 @@ class Preloader(metaclass=LogBase): self.error(f"DA_Send status error:{self.eh.status(status)}") self.config.set_gui_status(self.config.tr("Error on DA_Send")) return False - - -if __name__ == "__main__": - """ - e = bytes_to_long(bytes.fromhex("010001")) - n = bytes_to_long(bytes.fromhex( - "C43469A95B143CDC63CE318FE32BAD35B9554A136244FA74D13947425A32949EE6DC808CDEBF4121687A570B83C51E657303C925EC280B420C757E5A63AD3EC6980AAD5B6CA6D1BBDC50DB793D2FDDC0D0361C06163CFF9757C07F96559A2186322F7ABF1FFC7765F396673A48A4E8E3296427BC5510D0F97F54E5CA1BD7A93ADE3F6A625056426BDFE77B3B502C68A18F08B470DA23B0A2FAE13B8D4DB3746255371F43306582C74794D1491E97FDE504F0B1ECAC9DDEF282D674B817B7FFA8522672CF6281790910378FEBFA7DC6C2B0AF9DA03A58509D60AA1AD6F9BFDC84537CD0959B8735FE0BB9B471104B458A38DF846366926993097222F90628528F")) - d = bytes_to_long(bytes.fromhex( - "8E02CDB389BBC52D5383EBB5949C895B0850E633CF7DD3B5F7B5B8911B0DDF2A80387B46FAF67D22BC2748978A0183B5B420BA579B6D847082EA0BD14AB21B6CCCA175C66586FCE93756C2F426C85D7DF07629A47236265D1963B8354CB229AFA2E560B7B3641DDB8A0A839ED8F39BA8C7CDB94104650E8C7790305E2FF6D18206F49B7290B1ADB7B4C523E10EBF53630D438EF49C877402EA3C1BD6DD903892FD662FBDF1DFF5D7B095712E58E728BD7F6A8B5621175F4C08EBD6143CDACD65D9284DFFECAB64F70FD63182E4981551522727A2EE9873D0DB78180C26553AD0EE1CAAA21BCEBC5A8C0B331FE7FD8710F905A7456AF675A04AF1118CE71E36C9")) - data=bytearray([0xA,0xB,0xC,0xD,0xE,0xF,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9]) - msg = generate_rsa_challenge(n,d,data) - print(msg.hex()) - """ - data = bytearray([0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9]) - # from Cryptodome.PublicKey import RSA - from Cryptodome.Cipher import PKCS1_OAEP - - # E_DA=bytes_to_long(bytes.fromhex("010001")) - # N_DA= bytes_to_long(bytes.fromhex("A243F6694336D527C5B3ED569DDD0386D309C6592841E4C033DCB461EEA7B6F8535FC49" + - # "39E403060646A970DD81DE367CF003848146F19D259F50A385015AF6309EAA71BFED6B098C7A24D4871B4B82AAD7DC6E2856C301BE" + - # "7CDB46DC10795C0D30A68DD8432B5EE5DA42BA22124796512FCA21D811D50B34C2F672E25BCC2594D9C012B34D473EE222D1E56B90" + - # "E7D697CEA97E8DD4CCC6BED5FDAECE1A43F96495335F322CCE32612DAB462B024281841F553FF7FF33E0103A7904037F8FE5D9BE29" + - # "3ACD7485CDB50957DB11CA6DB28AF6393C3E78D9FBCD4567DEBCA2601622F0F2EB19DA9192372F9EA3B28B1079409C0A09E3D51D64" + - # "A4C4CE026FAD24CD7")) - # D_DA= bytes_to_long(bytes.fromhex("707C8892D0DE8CE0CA116914C8BD277B821E784D298D00D3473EDE236399435F85410095" + - # "25C2786CB3ED3D7530D47C9163692B0D588209E7E0E8D06F4A69725498B979599DC576303B5D8D96F874687A310D32E8C86E965B84" + - # "4BC2ACE51DC5E06859EA087BD536C39DCB8E1262FDEAF6DA20035F14D3592AB2C1B58734C5C62AC86FE44F98C602BABAB60A6C8D09" + - # "A199D2170E373D9B9A5D9B6DE852E859DEB1BDF33034DCD91EC4EEBFDDBECA88E29724391BB928F40EFD945299DFFC4595BB8D45F4" + - # "26AC15EC8B1C68A19EB51BEB2CC6611072AE5637DF0ABA89ED1E9CB8C9AC1EB05B1F01734DB303C23BE1869C9013561B9F6EA65BD2" + - # "516DE950F08B2E81")) - e = bytes_to_long(bytes.fromhex("010001")) - n = bytes_to_long(bytes.fromhex( - "C43469A95B143CDC63CE318FE32BAD35B9554A136244FA74D13947425A32949EE6DC808CDEBF4121687A570B83C51E657303C925" + - "EC280B420C757E5A63AD3EC6980AAD5B6CA6D1BBDC50DB793D2FDDC0D0361C06163CFF9757C07F96559A2186322F7ABF1FFC7765" + - "F396673A48A4E8E3296427BC5510D0F97F54E5CA1BD7A93ADE3F6A625056426BDFE77B3B502C68A18F08B470DA23B0A2FAE13B8D" + - "4DB3746255371F43306582C74794D1491E97FDE504F0B1ECAC9DDEF282D674B817B7FFA8522672CF6281790910378FEBFA7DC6C2" + - "B0AF9DA03A58509D60AA1AD6F9BFDC84537CD0959B8735FE0BB9B471104B458A38DF846366926993097222F90628528F")) - d = bytes_to_long(bytes.fromhex( - "8E02CDB389BBC52D5383EBB5949C895B0850E633CF7DD3B5F7B5B8911B0DDF2A80387B46FAF67D22BC2748978A0183B5B420BA57" + - "9B6D847082EA0BD14AB21B6CCCA175C66586FCE93756C2F426C85D7DF07629A47236265D1963B8354CB229AFA2E560B7B3641DDB" + - "8A0A839ED8F39BA8C7CDB94104650E8C7790305E2FF6D18206F49B7290B1ADB7B4C523E10EBF53630D438EF49C877402EA3C1BD6" + - "DD903892FD662FBDF1DFF5D7B095712E58E728BD7F6A8B5621175F4C08EBD6143CDACD65D9284DFFECAB64F70FD63182E4981551" + - "522727A2EE9873D0DB78180C26553AD0EE1CAAA21BCEBC5A8C0B331FE7FD8710F905A7456AF675A04AF1118CE71E36C9")) - rsakey = RSA.construct((n, e, d)) - encryptor = PKCS1_OAEP.new(rsakey) - encrypted = encryptor.encrypt(data) - decrypted = encryptor.decrypt(encrypted) - print(encrypted.hex()) - print(decrypted.hex()) diff --git a/mtkclient/Library/partition.py b/mtkclient/Library/partition.py index 3db0a9c..7830221 100755 --- a/mtkclient/Library/partition.py +++ b/mtkclient/Library/partition.py @@ -1,17 +1,18 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import logging from mtkclient.Library.utils import LogBase, logsetup -from mtkclient.Library.gpt import gpt -from mtkclient.Library.pmt import pmt +from mtkclient.Library.gpt import GPT +from mtkclient.Library.pmt import PMT class Partition(metaclass=LogBase): def __init__(self, mtk, readflash, read_pmt, loglevel=logging.INFO): self.mtk = mtk - self.__logger = logsetup(self, self.__logger, loglevel, mtk.config.gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.config = self.mtk.config self.readflash = readflash self.read_pmt = read_pmt @@ -29,7 +30,7 @@ class Partition(metaclass=LogBase): return b"" def get_pmt(self, backup: bool = False, parttype: str = "user") -> tuple: - pt = pmt() + pt = PMT() blocksize = self.mtk.daloader.daconfig.pagesize if not backup: addr = self.mtk.daloader.daconfig.flashsize - (2 * blocksize) @@ -41,11 +42,11 @@ class Partition(metaclass=LogBase): partdata = data[8:] partitions = [] for partpos in range(128): - partinfo = pt.pt_resident(partdata[partpos * 96:(partpos * 96) + 96]) + partinfo = pt.PtResident(partdata[partpos * 96:(partpos * 96) + 96]) if partinfo[:4] == b"\x00\x00\x00\x00": break - class partf: + class Partf: unique = b"" first_lba = 0 last_lba = 0 @@ -55,7 +56,7 @@ class Partition(metaclass=LogBase): type = b"" name = "" - pm = partf() + pm = Partf() pm.name = partinfo.name.rstrip(b"\x00").decode('utf-8') pm.sector = partinfo.offset // self.config.pagesize pm.sectors = partinfo.size // self.config.pagesize @@ -68,7 +69,7 @@ class Partition(metaclass=LogBase): def get_gpt(self, gpt_settings, parttype: str = "user") -> tuple: data = self.readflash(addr=0, length=2 * self.config.pagesize, filename="", parttype=parttype, display=False) if data[:4] == b"BPI\x00": - guid_gpt = gpt( + guid_gpt = GPT( num_part_entries=gpt_settings.gpt_num_part_entries, part_entry_size=gpt_settings.gpt_part_entry_size, part_entry_start_lba=gpt_settings.gpt_part_entry_start_lba, @@ -93,7 +94,7 @@ class Partition(metaclass=LogBase): return partdata, partentries if data == b"": return None, None - guid_gpt = gpt( + guid_gpt = GPT( num_part_entries=gpt_settings.gpt_num_part_entries, part_entry_size=gpt_settings.gpt_part_entry_size, part_entry_start_lba=gpt_settings.gpt_part_entry_start_lba, @@ -120,7 +121,7 @@ class Partition(metaclass=LogBase): data = self.readflash(addr=0, length=2 * self.config.pagesize, filename="", parttype=parttype, display=False) if data == b"": return data - guid_gpt = gpt( + guid_gpt = GPT( num_part_entries=gpt_num_part_entries, part_entry_size=gpt_part_entry_size, part_entry_start_lba=gpt_part_entry_start_lba, diff --git a/mtkclient/Library/pltools.py b/mtkclient/Library/pltools.py index 1b707bc..5c27bd2 100755 --- a/mtkclient/Library/pltools.py +++ b/mtkclient/Library/pltools.py @@ -1,14 +1,14 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 GPLv3 License +# (c) B.Kerler 2018-2024 GPLv3 License import os import logging from binascii import hexlify from mtkclient.Library.Exploit.amonet import Amonet from mtkclient.Library.Exploit.hashimoto import Hashimoto -from mtkclient.config.payloads import pathconfig +from mtkclient.config.payloads import PathConfig from mtkclient.Library.utils import LogBase, print_progress, logsetup -from mtkclient.Library.Hardware.hwcrypto import crypto_setup, hwcrypto +from mtkclient.Library.Hardware.hwcrypto import CryptoSetup, HwCrypto from mtkclient.Library.Exploit.kamakiri import Kamakiri from mtkclient.Library.Exploit.kamakiri2 import Kamakiri2 from mtkclient.Library.Port import Port @@ -16,7 +16,8 @@ from mtkclient.Library.Port import Port class PLTools(metaclass=LogBase): def __init__(self, mtk, loglevel=logging.INFO): - self.__logger = logsetup(self, self.__logger, loglevel, mtk.config.gui) + self.__logger, self.info, self.debug, self.warning, self.error = logsetup(self, self.__logger, + loglevel, mtk.config.gui) self.mtk = mtk self.chipconfig = self.mtk.config.chipconfig self.config = self.mtk.config @@ -27,7 +28,7 @@ class PLTools(metaclass=LogBase): self.hwcode = mtk.config.hwcode # crypto types - setup = crypto_setup() + setup = CryptoSetup() setup.hwcode = self.mtk.config.hwcode setup.dxcc_base = self.mtk.config.chipconfig.dxcc_base setup.read32 = self.mtk.preloader.read32 @@ -41,7 +42,7 @@ class PLTools(metaclass=LogBase): setup.ap_dma_mem = self.mtk.config.chipconfig.ap_dma_mem setup.meid_addr = self.mtk.config.chipconfig.meid_addr setup.prov_addr = self.mtk.config.chipconfig.prov_addr - self.hwcrypto = hwcrypto(setup, loglevel, self.mtk.config.gui) + self.hwcrypto = HwCrypto(setup, loglevel, self.mtk.config.gui) # exploit types if self.config.ptype == "kamakiri": @@ -55,7 +56,7 @@ class PLTools(metaclass=LogBase): elif self.config.ptype == "carbonara": assert "Carbonara is best served in your local restaurant :P" - self.pathconfig = pathconfig() + self.pathconfig = PathConfig() if loglevel == logging.DEBUG: logfilename = os.path.join("logs", "log.txt") fh = logging.FileHandler(logfilename, encoding='utf-8') diff --git a/mtkclient/Library/pmt.py b/mtkclient/Library/pmt.py index 71cbe8d..ff63a3e 100644 --- a/mtkclient/Library/pmt.py +++ b/mtkclient/Library/pmt.py @@ -1,26 +1,26 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 +# (c) B.Kerler 2018-2024 try: - from mtkclient.Library.utils import LogBase, structhelper + from mtkclient.Library.utils import LogBase, Structhelper except Exception: - from utils import LogBase, structhelper + from utils import LogBase, Structhelper -class pmt(metaclass=LogBase): - class pt_resident: +class PMT(metaclass=LogBase): + class PtResident: def __init__(self, data): - sh = structhelper(data) + sh = Structhelper(data) self.name = sh.bytes(64) self.size = sh.qword() self.part_id = sh.qword() self.offset = sh.qword() self.mask_flags = sh.qword() - class pt_info: + class PtInfo: def __init__(self, data): - sh = structhelper(data) + sh = Structhelper(data) self.sequencenumber = sh.bytes(1) self.tool_or_sd_update = sh.bytes(1) tmp = sh.bytes(1) @@ -30,9 +30,9 @@ class pmt(metaclass=LogBase): self.pt_changed = (tmp >> 4) & 0xF self.pt_has_space = tmp & 0xF - class pmt_header: + class PmtHeader: def __init__(self, data): - sh = structhelper(data) + sh = Structhelper(data) self.signature = sh.bytes(8) self.revision = sh.dword() self.header_size = sh.dword() diff --git a/mtkclient/Library/settings.py b/mtkclient/Library/settings.py index a651d0f..f09ea82 100755 --- a/mtkclient/Library/settings.py +++ b/mtkclient/Library/settings.py @@ -3,7 +3,7 @@ import os.path from binascii import hexlify -class hwparam: +class HwParam: paramsetting = None hwcode = None appid = b"" diff --git a/mtkclient/Library/utils.py b/mtkclient/Library/utils.py index 5e1dce4..6d60edb 100755 --- a/mtkclient/Library/utils.py +++ b/mtkclient/Library/utils.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2023 +# (c) B.Kerler 2018-2024 import codecs import copy import datetime as dt @@ -31,7 +31,7 @@ sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8') -class mtktee: +class MTKTee: magic = None hdrlen = None flag1 = None @@ -46,7 +46,7 @@ class mtktee: data = None def parse(self, data): - sh = structhelper_io(BytesIO(data)) + sh = StructhelperIo(BytesIO(data)) self.magic = sh.qword() self.hdrlen = sh.dword() self.flag1 = sh.bytes() @@ -62,7 +62,7 @@ class mtktee: self.data = bytearray(sh.bytes(self.datalen)) -class structhelper_io: +class StructhelperIo: pos = 0 def __init__(self, data: BytesIO = None, direction='little'): @@ -143,7 +143,7 @@ def find_binary(data, strf, pos=0): return None -class progress: +class Progress: def __init__(self, pagesize, guiprogress=None): self.progtime = 0 self.prog = 0 @@ -230,7 +230,7 @@ class progress: self.progtime = t0 -class structhelper: +class Structhelper: pos = 0 def __init__(self, data, pos=0): @@ -475,7 +475,7 @@ def logsetup(self, logger, loglevel, signal=None): else: logger.setLevel(logging.INFO) self.loglevel = loglevel - return logger + return logger, self.info, self.debug, self.warning, self.error class LogBase(type): @@ -531,8 +531,8 @@ def rmrf(path): shutil.rmtree(path, onerror=del_rw) -class elf: - class memorysegment: +class ELF: + class MemorySegment: phy_addr = 0 virt_start_addr = 0 virt_end_addr = 0 @@ -545,7 +545,7 @@ class elf: self.header, self.pentry = self.parse() self.memorylayout = [] for entry in self.pentry: - ms = self.memorysegment() + ms = self.MemorySegment() ms.phy_addr = entry.phy_addr ms.virt_start_addr = entry.virt_addr ms.virt_end_addr = entry.virt_addr + entry.seg_mem_len @@ -571,7 +571,7 @@ class elf: return memsegment.virt_start_addr return None - class programentry: + class ProgramEntry: p_type = 0 from_file = 0 virt_addr = 0 @@ -582,7 +582,7 @@ class elf: p_align = 0 def parse_programentry(self, dat): - pe = self.programentry() + pe = self.ProgramEntry() if self.elfclass == 1: (pe.p_type, pe.from_file, pe.virt_addr, pe.phy_addr, pe.seg_file_len, pe.seg_mem_len, pe.p_flags, pe.p_align) = struct.unpack(" > 8) & 7 + rt = (instr >> 8) & 7 pc = curpc // 4 * 4 - return (pc + (imm8 * 4) + 4), Rt + return (pc + (imm8 * 4) + 4), rt def ldr_imm(instr): simm5 = (instr >> 6) & 0x1F - sRt = instr & 0x7 - sRn = (instr >> 3) & 0x7 - return simm5, sRt, sRn + s_rt = instr & 0x7 + s_rn = (instr >> 3) & 0x7 + return simm5, s_rt, s_rn def main(): @@ -80,7 +80,7 @@ def main(): usbdl_ptr = None if usbdl_put_word: mpos = (usbdl_put_word & 0xFFFFF) + 7 - offset, Rn = ldr_lit(mpos, + offset, rn = ldr_lit(mpos, unpack(" 1: + pc = PathConfig() + if len(sys.argv) > 1: loaders.append(sys.argv[1]) else: for root, dirs, files in os.walk(pc.get_loader_path(), topdown=False): @@ -72,9 +72,9 @@ def main(): print("sw_version: 0x%04X" % da[0]["sw_version"]) print("Reserved1: 0x%04X" % da[0]["reserved1"]) print("Reserved3: 0x%04X" % da[0]["reserved3"]) - for i in range(da[0]["entry_region_count"]): - entry = da[i + 1] - print(f"\t{i}: {hex(entry['m_start_addr'])}") + for x in range(da[0]["entry_region_count"]): + entry = da[x + 1] + print(f"\t{x}: {hex(entry['m_start_addr'])}") mbuf = da[3]["m_buf"] m_len = da[3]["m_len"] startaddr = da[3]["m_start_addr"] @@ -104,7 +104,11 @@ def main(): if hashidx is not None: print("Hash check 3 found.") else: - print("HASH ERROR !!!!") + hashidx = find_binary(data, b"\x04\x50\x00\xE3\x07\x50\x4C\xE3") + if hashidx is not None: + print("Hash check 4 (V6) found.") + else: + print("HASH ERROR !!!!") fname = os.path.join("loaders", hex(da[0]["hw_code"])[2:] + "_" + hex(startaddr)[2:] + os.path.basename( @@ -116,7 +120,7 @@ def main(): bootldr.seek(da[2]["m_buf"]) tt = bootldr.read(da[2]["m_len"]) idx = tt.find(bytes.fromhex("70BB442D27D244A7")) - #idx = tt.find(bytes.fromhex("01279360D36013615361")) + # idx = tt.find(bytes.fromhex("01279360D36013615361")) if idx != -1: print("V3 Enabled") bootldr.seek(da[3]["m_buf"]) diff --git a/mtkclient/Tools/emulate_preloader.py b/mtkclient/Tools/emulate_preloader.py index e722860..5c9afaf 100755 --- a/mtkclient/Tools/emulate_preloader.py +++ b/mtkclient/Tools/emulate_preloader.py @@ -167,6 +167,7 @@ def hook_code(uc, access, address, size): def hook_mem_invalid(uc, access, address, size, value, user_data): + info = "" pc = uc.reg_read(UC_ARM_REG_PC) if access == UC_MEM_WRITE: info = ("invalid WRITE of 0x%x at 0x%X, data size = %u, data value = 0x%x" % (address, pc, size, value)) diff --git a/mtkclient/Tools/enc_test.py b/mtkclient/Tools/enc_test.py index 09ca2d6..0eb9cd1 100755 --- a/mtkclient/Tools/enc_test.py +++ b/mtkclient/Tools/enc_test.py @@ -1,4 +1,4 @@ -from Crypto.Cipher import AES +from Cryptodome.Cipher import AES from struct import unpack, pack from binascii import hexlify diff --git a/mtkclient/Tools/preloader_emu_mmc.py b/mtkclient/Tools/preloader_emu_mmc.py index f9378f2..5138d80 100755 --- a/mtkclient/Tools/preloader_emu_mmc.py +++ b/mtkclient/Tools/preloader_emu_mmc.py @@ -5,7 +5,7 @@ import os import logging from binascii import hexlify from struct import pack, unpack -from mtkclient.Library.Connection.usblib import usb_class +from mtkclient.Library.Connection.usblib import UsbClass from mtkclient.Library.utils import LogBase from mtkclient.Library.utils import print_progress from unicorn import (Uc, UC_MEM_WRITE, UC_MEM_READ, UC_MEM_FETCH, UC_MEM_READ_UNMAPPED, @@ -40,7 +40,7 @@ class Stage2(metaclass=LogBase): else: self.__logger.setLevel(logging.INFO) portconfig = [[0x0E8D, 0x0003, -1], [0x0E8D, 0x2000, -1]] - self.cdc = usb_class(portconfig=portconfig, loglevel=loglevel, devclass=10) + self.cdc = UsbClass(portconfig=portconfig, loglevel=loglevel, devclass=10) def connect(self): self.cdc.connected = self.cdc.connect() diff --git a/mtkclient/Tools/stage2.py b/mtkclient/Tools/stage2.py index f42ee15..6a7f2d3 100755 --- a/mtkclient/Tools/stage2.py +++ b/mtkclient/Tools/stage2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# MTK Stage2 Client (c) B.Kerler 2018-2023. +# MTK Stage2 Client (c) B.Kerler 2018-2024. # Licensed under GPLv3 License import os @@ -10,16 +10,18 @@ import argparse import hashlib from binascii import hexlify from struct import pack, unpack -from mtkclient.Library.Connection.usblib import usb_class +from mtkclient.Library.Connection.usblib import UsbClass from mtkclient.Library.utils import LogBase -from mtkclient.Library.utils import progress -from mtkclient.Library.Hardware.hwcrypto import crypto_setup, hwcrypto -from mtkclient.config.mtk_config import Mtk_Config +from mtkclient.Library.utils import Progress +from mtkclient.Library.Hardware.hwcrypto import CryptoSetup, HwCrypto +from mtkclient.config.mtk_config import MtkConfig from mtkclient.config.usb_ids import default_ids class Stage2(metaclass=LogBase): def __init__(self, args, loglevel=logging.INFO): + self.hwcrypto = None + self.config = None self.__logger = self.__logger self.args = args self.loglevel = loglevel @@ -28,7 +30,7 @@ class Stage2(metaclass=LogBase): self.warning = self.__logger.warning self.emmc_inited = False # Setup HW Crypto chip variables - self.setup = crypto_setup() + self.setup = CryptoSetup() if loglevel == logging.DEBUG: logfilename = os.path.join("logs", "log.txt") @@ -40,7 +42,7 @@ class Stage2(metaclass=LogBase): else: self.__logger.setLevel(logging.INFO) - self.cdc = usb_class(portconfig=default_ids, loglevel=loglevel, devclass=10) + self.cdc = UsbClass(portconfig=default_ids, loglevel=loglevel, devclass=10) self.usbread = self.cdc.usbread self.usbwrite = self.cdc.usbwrite @@ -50,7 +52,7 @@ class Stage2(metaclass=LogBase): except: print("Error reading hwcode...aborting.") return False - self.config = Mtk_Config(self.loglevel) + self.config = MtkConfig(self.loglevel) self.config.init_hwcode(hwcode) self.setup.blacklist = self.config.chipconfig.blacklist self.setup.gcpu_base = self.config.chipconfig.gcpu_base @@ -62,7 +64,7 @@ class Stage2(metaclass=LogBase): self.setup.writemem = self.memwrite self.setup.meid_addr = self.config.chipconfig.meid_addr self.setup.socid_addr = self.config.chipconfig.socid_addr - self.hwcrypto = hwcrypto(self.setup, self.loglevel, self.config.gui) + self.hwcrypto = HwCrypto(self.setup, self.loglevel, self.config.gui) return True def init_emmc(self): @@ -133,7 +135,7 @@ class Stage2(metaclass=LogBase): if not self.emmc_inited: self.init_emmc() wf = None - pg = progress(pagesize=0x200) + pg = Progress(pagesize=0x200) buffer = bytearray() if filename is not None: wf = open(filename, "wb") @@ -253,6 +255,7 @@ class Stage2(metaclass=LogBase): addr = start data = b"" pos = 0 + wf = None if filename is not None: wf = open(filename, "wb") while bytestoread > 0: @@ -273,6 +276,7 @@ class Stage2(metaclass=LogBase): return data def memwrite(self, start, data, filename=None): + rf = None if filename is not None: rf = open(filename, "rb") bytestowrite = os.stat(filename).st_size @@ -306,7 +310,7 @@ class Stage2(metaclass=LogBase): return ack == b"\xD0\xD0\xD0\xD0" def rpmb(self, start, length, filename, reverse=False): - pg = progress(pagesize=0x100) + pg = Progress(pagesize=0x100) if not self.emmc_inited: self.init_emmc() if start == 0: @@ -333,7 +337,7 @@ class Stage2(metaclass=LogBase): old = 0 bytestoread = sectors * 0x100 count = sectors - pg = progress(pagesize=0x200) + pg = Progress(pagesize=0x200) if sectors > 0xFFFF: count = 0xFFFF with open(filename, "wb") as wf: @@ -582,7 +586,8 @@ def main(): parser_keys.add_argument('--otp', dest='otp', type=str, help='OTP for keys (dxcc,sej,gcpu)') parser_keys.add_argument('--mode', dest='mode', default=None, type=str, - help='keymode (dxcc,sej,gcpu,sej_aes_decrypt,sej_aes_decrypt,sej_sst_decrypt,sej_sst_encrypt') + help='keymode (dxcc,sej,gcpu,sej_aes_decrypt,sej_aes_decrypt,' + + 'sej_sst_decrypt,sej_sst_encrypt') parser_keys.add_argument('--data', dest='data', default=None, type=str, help='data') args = parser.parse_args() @@ -677,17 +682,17 @@ def main(): elif cmd == "reboot": st2.reboot() elif cmd == "seccfg": + critical_lock_state = 0 if args.flag not in ["unlock", "lock"]: print("Valid flags are: unlock, lock") - sys.exit(1) - """ - LKS_DEFAULT = 0x01 - LKS_MP_DEFAULT = 0x02 - LKS_UNLOCK = 0x03 - LKS_LOCK = 0x04 - LKS_VERIFIED = 0x05 - LKS_CUSTOM = 0x06 """ + LKS_DEFAULT = 0x01 + LKS_MP_DEFAULT = 0x02 + LKS_UNLOCK = 0x03 + LKS_LOCK = 0x04 + LKS_VERIFIED = 0x05 + LKS_CUSTOM = 0x06 + """ """ LKCS_UNLOCK = 0x01 LKCS_LOCK = 0x02 @@ -696,6 +701,8 @@ def main(): SBOOT_RUNTIME_OFF = 0 SBOOT_RUNTIME_ON = 1 """ + sys.exit(1) + if args.flag == "unlock": lock_state = 3 critical_lock_state = 1 diff --git a/mtkclient/Tools/whitelist_parser.py b/mtkclient/Tools/whitelist_parser.py index e733e96..de23bd5 100755 --- a/mtkclient/Tools/whitelist_parser.py +++ b/mtkclient/Tools/whitelist_parser.py @@ -46,7 +46,8 @@ def main(): if (flag & 0x16F) != 0: info += "B" print( - f"Offset {hex(checklist_generic[0] + (i * 3))} -> Flag {hex(flag)}+[{info}] Ptr {hex(ptr)} Count {hex(count)}") + f"Offset {hex(checklist_generic[0] + (i * 3))} -> Flag {hex(flag)}+" + + f"[{info}] Ptr {hex(ptr)} Count {hex(count)}") print("----------------------------------------------------------------------------------------------") for field in range(count): start, end = dword(data, ptr + (field * 8), 2) diff --git a/mtkclient/config/brom_config.py b/mtkclient/config/brom_config.py index 9881139..af208b1 100755 --- a/mtkclient/config/brom_config.py +++ b/mtkclient/config/brom_config.py @@ -1,10 +1,10 @@ -class damodes: +class DAmodes: LEGACY = 3 XFLASH = 5 XML = 6 -class efuse: +class Efuse: def __init__(self, base, hwcode): if hwcode in [0x6570, 0x6580, 0x321, 0x335]: self.efuses = [base + 0x20, base + 0x30, base + 0x38, base + 0x40, base + 0x44, @@ -221,13 +221,13 @@ class efuse: base + 0xA4, base + 0xA8, base + 0xAC] -class chipconfig: +class Chipconfig: def __init__(self, var1=None, watchdog=None, uart=None, brom_payload_addr=None, da_payload_addr=None, pl_payload_addr=None, cqdma_base=None, sej_base=None, dxcc_base=None, gcpu_base=None, ap_dma_mem=None, name="", description="", dacode=None, meid_addr=None, socid_addr=None, blacklist=(), blacklist_count=None, send_ptr=None, ctrl_buffer=(), cmd_handler=None, brom_register_access=None, - damode=damodes.LEGACY, loader=None, prov_addr=None, misc_lock=None, + damode=DAmodes.LEGACY, loader=None, prov_addr=None, misc_lock=None, efuse_addr=None): self.var1 = var1 self.watchdog = watchdog @@ -319,7 +319,7 @@ class chipconfig: """ hwconfig = { - 0x571: chipconfig( # var1 + 0x571: Chipconfig( # var1 watchdog=0x10007000, # uart # brom_payload_addr @@ -329,10 +329,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x0571, name="MT0571"), - 0x598: chipconfig( # var1 + 0x598: Chipconfig( # var1 watchdog=0x10211000, uart=0x11020000, brom_payload_addr=0x100A00, # todo:check @@ -342,10 +342,10 @@ hwconfig = { cqdma_base=0x10212c00, ap_dma_mem=0x11000000 + 0x1A0, # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x0598, name="ELBRUS/MT0598"), - 0x992: chipconfig( # var1 + 0x992: Chipconfig( # var1 # watchdog # uart # brom_payload_addr @@ -355,10 +355,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x0992, name="MT0992"), - 0x2601: chipconfig( + 0x2601: Chipconfig( var1=0xA, # Smartwatch, confirmed watchdog=0x10007000, uart=0x11005000, @@ -378,10 +378,10 @@ hwconfig = { brom_register_access=(0x40bd48, 0x40befc), meid_addr=0x11142C34, dacode=0x2601, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # name="MT2601", loader="mt2601_payload.bin"), - 0x3967: chipconfig( # var1 + 0x3967: Chipconfig( # var1 # watchdog # uart brom_payload_addr=0x100A00, @@ -394,9 +394,9 @@ hwconfig = { # ap_dma_mem # blacklist dacode=0x3967, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, name="MT3967"), - 0x6255: chipconfig( # var1 + 0x6255: Chipconfig( # var1 # watchdog # uart # brom_payload_addr @@ -407,10 +407,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, # dacode name="MT6255"), - 0x6261: chipconfig( + 0x6261: Chipconfig( var1=0x28, # Smartwatch, confirmed watchdog=0xA0030000, uart=0xA0080000, @@ -425,12 +425,12 @@ hwconfig = { send_ptr=(0x700044b0, 0x700058EC), ctrl_buffer=0x700041A8, cmd_handler=0x700061F6, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6261, name="MT6261", loader="mt6261_payload.bin" ), - 0x6280: chipconfig( # var1 + 0x6280: Chipconfig( # var1 # watchdog # uart # brom_payload_addr @@ -441,10 +441,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, name="MT6280" ), - 0x6516: chipconfig( # var1 + 0x6516: Chipconfig( # var1 watchdog=0x10003000, uart=0x10023000, da_payload_addr=0x201000, # todo: check @@ -454,10 +454,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6516, name="MT6516"), - 0x633: chipconfig( # var1 + 0x633: Chipconfig( # var1 watchdog=0x10007000, uart=0x11002000, brom_payload_addr=0x100A00, # todo: check @@ -469,10 +469,10 @@ hwconfig = { cqdma_base=0x1020ac00, ap_dma_mem=0x11000000 + 0x1A0, # AP_P_DMA_I2C_RX_MEM_ADDR efuse_addr=0x10009000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6570, name="MT6570/MT8321"), - 0x6571: chipconfig( # var1 + 0x6571: Chipconfig( # var1 watchdog=0x10007400, # uart da_payload_addr=0x2009000, @@ -484,10 +484,10 @@ hwconfig = { # ap_dma_mem # blacklist misc_lock=0x1000141C, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6571, name="MT6571"), - 0x6572: chipconfig( + 0x6572: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11005000, @@ -508,11 +508,11 @@ hwconfig = { meid_addr=0x11142C34, misc_lock=0x1000141C, efuse_addr=0x10009000, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6572, name="MT6572", loader="mt6572_payload.bin"), - 0x6573: chipconfig( # var1 + 0x6573: Chipconfig( # var1 watchdog=0x70025000, # uart da_payload_addr=0x90006000, @@ -523,10 +523,10 @@ hwconfig = { # cqdma_base # ap_dma_mem # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6573, name="MT6573/MT6260"), - 0x6575: chipconfig( # var1 + 0x6575: Chipconfig( # var1 watchdog=0xC0000000, uart=0xC1009000, da_payload_addr=0xc2001000, @@ -537,10 +537,10 @@ hwconfig = { # cqdma_base ap_dma_mem=0xC100119C, # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6572, name="MT6575/77"), - 0x6577: chipconfig( # var1 + 0x6577: Chipconfig( # var1 watchdog=0xC0000000, uart=0xC1009000, da_payload_addr=0xc2001000, @@ -551,10 +551,10 @@ hwconfig = { # cqdma_base ap_dma_mem=0xC100119C, # blacklist - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6577, name="MT6577"), - 0x6580: chipconfig(var1=0xAC, + 0x6580: Chipconfig(var1=0xAC, watchdog=0x10007000, uart=0x11005000, brom_payload_addr=0x100A00, @@ -574,11 +574,11 @@ hwconfig = { efuse_addr=0x10206000, misc_lock=0x10001838, meid_addr=0x1030B4, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6580, name="MT6580", loader="mt6580_payload.bin"), - 0x6582: chipconfig( + 0x6582: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -599,11 +599,11 @@ hwconfig = { efuse_addr=0x10206000, meid_addr=0x1030CC, misc_lock=0x10002050, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6582, name="MT6582/MT6574/MT8382", loader="mt6582_payload.bin"), - 0x6583: chipconfig( # var1 + 0x6583: Chipconfig( # var1 watchdog=0x10000000, # fixme uart=0x11006000, brom_payload_addr=0x100A00, @@ -616,10 +616,10 @@ hwconfig = { cqdma_base=0x10212000, # This chip might not support cqdma ap_dma_mem=0x11000000 + 0x320, # AP_DMA_I2C_0_RX_MEM_ADDR misc_lock=0x10002050, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6589, name="MT6583/6589"), - 0x6592: chipconfig( + 0x6592: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -641,10 +641,10 @@ hwconfig = { misc_lock=0x10002050, efuse_addr=0x10206000, dacode=0x6592, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # name="MT6592/MT8392", loader="mt6592_payload.bin"), - 0x6595: chipconfig(var1=0xA, + 0x6595: Chipconfig(var1=0xA, watchdog=0x10007000, uart=0x11002000, brom_payload_addr=0x100A00, @@ -663,11 +663,11 @@ hwconfig = { meid_addr=0x1030A4, efuse_addr=0x10206000, dacode=0x6595, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # name="MT6595", loader="mt6595_payload.bin"), # 6725 - 0x321: chipconfig( + 0x321: Chipconfig( var1=0x28, watchdog=0x10212000, uart=0x11002000, @@ -688,11 +688,11 @@ hwconfig = { meid_addr=0x1030B0, misc_lock=0x10001838, efuse_addr=0x11c50000, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6735, name="MT6735/T,MT8735A", loader="mt6735_payload.bin"), - 0x335: chipconfig( + 0x335: Chipconfig( var1=0x28, # confirmed watchdog=0x10212000, uart=0x11002000, @@ -712,12 +712,12 @@ hwconfig = { brom_register_access=(0x98dc, 0x9aa4), meid_addr=0x1030B0, efuse_addr=0x10206000, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6735, name="MT6737M/MT6735G", loader="mt6737_payload.bin"), # MT6738 - 0x699: chipconfig( + 0x699: Chipconfig( var1=0xB4, watchdog=0x10007000, uart=0x11002000, @@ -740,11 +740,11 @@ hwconfig = { prov_addr=0x10720C, misc_lock=0x1001a100, efuse_addr=0x11c00000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6739, name="MT6739/MT6731/MT8765", loader="mt6739_payload.bin"), - 0x601: chipconfig( + 0x601: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -758,10 +758,10 @@ hwconfig = { # blacklist efuse_addr=0x10206000, misc_lock=0x10001838, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6755, name="MT6750"), - 0x6752: chipconfig( + 0x6752: Chipconfig( var1=0x28, watchdog=0x10007000, uart=0x11002000, @@ -782,12 +782,12 @@ hwconfig = { efuse_addr=0x10206000, meid_addr=0x1030B4, # no socid - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6752, # misc_lock=0x10001838, name="MT6752", loader="mt6752_payload.bin"), - 0x337: chipconfig( + 0x337: Chipconfig( var1=0x28, # confirmed watchdog=0x10212000, uart=0x11002000, @@ -806,12 +806,12 @@ hwconfig = { cmd_handler=0x0000A1EF, brom_register_access=(0x993c, 0x9b04), meid_addr=0x1030B0, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6735, misc_lock=0x10001838, name="MT6753", loader="mt6753_payload.bin"), - 0x326: chipconfig( + 0x326: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -832,12 +832,12 @@ hwconfig = { meid_addr=0x1030AC, misc_lock=0x10001838, efuse_addr=0x10206000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6755, name="MT6755/MT6750/M/T/S", description="Helio P10/P15/P18", loader="mt6755_payload.bin"), - 0x551: chipconfig( + 0x551: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -858,12 +858,12 @@ hwconfig = { meid_addr=0x1030B4, misc_lock=0x10001838, efuse_addr=0x10206000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6757, name="MT6757/MT6757D", description="Helio P20", loader="mt6757_payload.bin"), - 0x688: chipconfig( + 0x688: Chipconfig( var1=0xA, watchdog=0x10211000, # uart=0x11020000, @@ -884,13 +884,13 @@ hwconfig = { meid_addr=0x102bf8, socid_addr=0x102c08, efuse_addr=0x10450000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6758, name="MT6758", description="Helio P30", loader="mt6758_payload.bin" ), - 0x507: chipconfig( # var1 + 0x507: Chipconfig( # var1 watchdog=0x10210000, uart=0x11020000, brom_payload_addr=0x100A00, # todo @@ -908,14 +908,14 @@ hwconfig = { # cmd_handler # brom_Register_access # meid_addr - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, dacode=0x6758, name="MT6759", description="Helio P30" # loader ), - 0x717: chipconfig( + 0x717: Chipconfig( var1=0x25, watchdog=0x10007000, uart=0x11002000, @@ -938,12 +938,12 @@ hwconfig = { prov_addr=0x1054F4, misc_lock=0x1001a100, efuse_addr=0x11c50000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6761, name="MT6761/MT6762/MT3369/MT8766B", description="Helio A20/P22/A22/A25/G25", loader="mt6761_payload.bin"), - 0x690: chipconfig( + 0x690: Chipconfig( var1=0x7F, watchdog=0x10007000, uart=0x11002000, @@ -966,12 +966,12 @@ hwconfig = { prov_addr=0x106804, misc_lock=0x1001a100, efuse_addr=0x11f10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6763, name="MT6763", description="Helio P23", loader="mt6763_payload.bin"), - 0x766: chipconfig( + 0x766: Chipconfig( var1=0x25, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -994,12 +994,12 @@ hwconfig = { prov_addr=0x1054F4, misc_lock=0x1001a100, efuse_addr=0x11c50000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6765, name="MT6765/MT8768t", description="Helio P35/G35", loader="mt6765_payload.bin"), - 0x707: chipconfig( + 0x707: Chipconfig( var1=0x25, watchdog=0x10007000, uart=0x11002000, @@ -1022,12 +1022,12 @@ hwconfig = { prov_addr=0x1054F4, misc_lock=0x1001a100, efuse_addr=0x11ce0000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6768, name="MT6768/MT6769", description="Helio P65/G85 k68v1", loader="mt6768_payload.bin"), - 0x788: chipconfig( + 0x788: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1050,7 +1050,7 @@ hwconfig = { prov_addr=0x1065C0, misc_lock=0x1001a100, efuse_addr=0x11f10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6771, name="MT6771/MT8385/MT8183/MT8666", description="Helio P60/P70/G80", @@ -1066,7 +1066,7 @@ hwconfig = { # (0x00200018, 0x00200000), # Memory region array pointer # (0x0020001c, 0x00000001), # Memory region array length # (0x00106A60, 0)], # Dynamic permission table entry count? - 0x725: chipconfig(var1=0xA, # confirmed + 0x725: Chipconfig(var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, brom_payload_addr=0x100A00, @@ -1088,12 +1088,12 @@ hwconfig = { prov_addr=0x1065C0, misc_lock=0x1001a100, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6779, name="MT6779", description="Helio P90 k79v1", loader="mt6779_payload.bin"), - 0x1066: chipconfig( + 0x1066: Chipconfig( var1=0x73, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1114,13 +1114,13 @@ hwconfig = { meid_addr=0x102B98, socid_addr=0x102BA8, efuse_addr=0x11cb0000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6781, name="MT6781", description="Helio G96", loader="mt6781_payload.bin" ), - 0x813: chipconfig(var1=0xA, # confirmed + 0x813: Chipconfig(var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, brom_payload_addr=0x100A00, @@ -1142,12 +1142,12 @@ hwconfig = { prov_addr=0x1065C0, misc_lock=0x1001a100, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6785, name="MT6785", description="Helio G90", loader="mt6785_payload.bin"), - 0x6795: chipconfig( + 0x6795: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1167,12 +1167,12 @@ hwconfig = { brom_register_access=(0x9a60, 0x9c28), meid_addr=0x1030A0, efuse_addr=0x10206000, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x6795, name="MT6795", description="Helio X10", loader="mt6795_payload.bin"), - 0x279: chipconfig( + 0x279: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1193,12 +1193,12 @@ hwconfig = { meid_addr=0x1030AC, misc_lock=0x10002050, efuse_addr=0x10206000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6797, name="MT6797/MT6767", description="Helio X23/X25/X27", loader="mt6797_payload.bin"), - 0x562: chipconfig( + 0x562: Chipconfig( var1=0xA, # confirmed watchdog=0x10211000, uart=0x11020000, @@ -1219,12 +1219,12 @@ hwconfig = { meid_addr=0x1033B8, socid_addr=0x1033C8, efuse_addr=0x11F10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6799, name="MT6799", description="Helio X30/X35", loader="mt6799_payload.bin"), - 0x989: chipconfig( + 0x989: Chipconfig( var1=0x73, watchdog=0x10007000, uart=0x11002000, @@ -1246,12 +1246,12 @@ hwconfig = { socid_addr=0x102ba8, prov_addr=0x1066B4, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6833, name="MT6833", description="Dimensity 700 5G k6833", loader="mt6833_payload.bin"), - 0x996: chipconfig(var1=0xA, + 0x996: Chipconfig(var1=0xA, watchdog=0x10007000, uart=0x11002000, brom_payload_addr=0x100A00, @@ -1273,12 +1273,12 @@ hwconfig = { prov_addr=0x1066C0, misc_lock=0x1001A100, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6853, name="MT6853", description="Dimensity 720 5G", loader="mt6853_payload.bin"), - 0x886: chipconfig( + 0x886: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1301,12 +1301,12 @@ hwconfig = { prov_addr=0x1066C0, misc_lock=0x1001A100, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6873, name="MT6873", description="Dimensity 800/820 5G", loader="mt6873_payload.bin"), - 0x959: chipconfig( + 0x959: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1328,13 +1328,13 @@ hwconfig = { socid_addr=0x102ba8, prov_addr=0x1066C0, efuse_addr=0x11f10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6877, # todo name="MT6877/MT6877V", description="Dimensity 900/1080", loader="mt6877_payload.bin" ), - 0x816: chipconfig( + 0x816: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1357,13 +1357,13 @@ hwconfig = { prov_addr=0x1066C0, misc_lock=0x1001A100, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6885, name="MT6885/MT6883/MT6889/MT6880/MT6890", description="Dimensity 1000L/1000", loader="mt6885_payload.bin"), # Dimensity 1100 - MT6891 Realme Q3 Pro - 0x950: chipconfig( + 0x950: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1385,13 +1385,13 @@ hwconfig = { socid_addr=0x102BA8, prov_addr=0x1066C0, efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x6893, name="MT6893", description="Dimensity 1200", loader="mt6893_payload.bin"), # - 0x907: chipconfig( + 0x907: Chipconfig( var1=0xA, watchdog=0x1c007000, uart=0x11001000, @@ -1412,14 +1412,14 @@ hwconfig = { meid_addr=0x1008EC, socid_addr=0x100934, # prov_addr=0x1066C0, - damode=damodes.XML, + damode=DAmodes.XML, dacode=0x6983, name="MT6983", description="Dimensity 9000/9000+" # loader="mt6983_payload.bin" ), # Dimensity 1100 - MT6895 Dimensity 8200 - Vivo V27 Pro - 0x1172: chipconfig( + 0x1172: Chipconfig( var1=0xA, watchdog=0x1c007000, uart=0x11001000, @@ -1440,14 +1440,14 @@ hwconfig = { meid_addr=0x1008EC, socid_addr=0x100934, # prov_addr=0x1066C0, - damode=damodes.XML, + damode=DAmodes.XML, dacode=0x6895, name="MT6895", description="Dimensity 8100" # loader="mt6893_payload.bin" ), # MT6789 Oppo Realme 10 / Gigaset GX4 - 0x1208: chipconfig( + 0x1208: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1469,13 +1469,13 @@ hwconfig = { socid_addr=0x100934, # prov_addr=0x1066C0, efuse_addr=0x11C10000, - damode=damodes.XML, + damode=DAmodes.XML, dacode=0x1208, name="MT6789", description="MTK Helio G99" # loader="mt6789_payload.bin" ), - 0x1229: chipconfig( + 0x1229: Chipconfig( var1=0xA, watchdog=0x1c007000, uart=0x11002000, @@ -1484,7 +1484,7 @@ hwconfig = { pl_payload_addr=0x40200000, # gcpu_base=0x10050000, dxcc_base=0x10210000, - #sej_base=0x1000a000, + # sej_base=0x1000a000, cqdma_base=0x10212000, # ap_dma_mem=0x11300800 + 0x1a0, # blacklist=[(0x102d5c, 0x0)], @@ -1493,17 +1493,17 @@ hwconfig = { # ctrl_buffer=0x00103024, # cmd_handler=0x000101E8, # brom_register_access=(0xf99a, 0xfa0c), - #meid_addr=0x1008EC, - #socid_addr=0x100934, + # meid_addr=0x1008EC, + # socid_addr=0x100934, # prov_addr=0x1066C0, # efuse_addr=0x11C10000, - damode=damodes.XML, + damode=DAmodes.XML, dacode=0x1229, name="MT6886", description="Dimensity 7200 Ultra" # loader="mt7200_payload.bin" ), - 0x1296: chipconfig( + 0x1296: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1525,13 +1525,13 @@ hwconfig = { socid_addr=0x100934, # prov_addr=0x1066C0, # efuse_addr=0x11C10000, - damode=damodes.XML, + damode=DAmodes.XML, dacode=0x1296, name="MT6985", description="Dimensity 9200/9200+" # loader="mt6985_payload.bin" ), - 0x8127: chipconfig( + 0x8127: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1550,11 +1550,11 @@ hwconfig = { brom_register_access=(0xb58c, 0xb740), meid_addr=0x1031CC, misc_lock=0x10002050, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x8127, name="MT8127/MT3367", loader="mt8127_payload.bin"), # ford,austin,tank #mhmm wdt, nochmal checken - 0x8135: chipconfig( # var1 + 0x8135: Chipconfig( # var1 watchdog=0x10000000, uart=0x11002000, # brom_payload_addr @@ -1572,13 +1572,13 @@ hwconfig = { # brom_register_access # meid_addr # socid_addr - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x8135, name="MT8135" # description # loader ), - 0x8163: chipconfig( + 0x8163: Chipconfig( var1=0xB1, watchdog=0x10007000, uart=0x11002000, @@ -1599,11 +1599,11 @@ hwconfig = { meid_addr=0x1031C0, misc_lock=0x10002050, efuse_addr=0x10206000, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x8163, name="MT8163", loader="mt8163_payload.bin"), # douglas, karnak - 0x8167: chipconfig(var1=0xCC, + 0x8167: Chipconfig(var1=0xCC, watchdog=0x10007000, uart=0x11005000, brom_payload_addr=0x100A00, @@ -1623,12 +1623,12 @@ hwconfig = { meid_addr=0x103478, socid_addr=0x103488, efuse_addr=0x10009000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x8167, name="MT8167/MT8516/MT8362", # description loader="mt8167_payload.bin"), - 0x8168: chipconfig( + 0x8168: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1648,12 +1648,12 @@ hwconfig = { meid_addr=0x106438, socid_addr=0x106448, efuse_addr=0x10009000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x8168, name="MT8168/MT6357", # description, device is patched against kamakiri loader="mt8168_payload.bin"), - 0x8172: chipconfig( + 0x8172: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1673,12 +1673,12 @@ hwconfig = { brom_register_access=(0xa3b8, 0xa580), meid_addr=0x1230B0, misc_lock=0x1202050, - damode=damodes.LEGACY, # + damode=DAmodes.LEGACY, # dacode=0x8173, name="MT8173", # description loader="mt8173_payload.bin"), # sloane, suez - 0x8176: chipconfig( + 0x8176: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1701,11 +1701,11 @@ hwconfig = { # socid_addr efuse_addr=0x10206000, dacode=0x8173, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, # description name="MT8176", loader="mt8176_payload.bin"), - 0x930: chipconfig( + 0x930: Chipconfig( # var1 watchdog=0x10007000, uart=0x11001200, @@ -1727,12 +1727,12 @@ hwconfig = { efuse_addr=0x11c10000, misc_lock=0x1001A100, dacode=0x8195, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, # description name="MT8195 Chromebook" # loader ), - 0x8512: chipconfig( + 0x8512: Chipconfig( var1=0xA, watchdog=0x10007000, uart=0x11002000, @@ -1753,12 +1753,12 @@ hwconfig = { socid_addr=0x104648, efuse_addr=0x11c50000, dacode=0x8512, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, # description name="MT8512", loader="mt8512_payload.bin" ), - 0x8518: chipconfig( # var1 + 0x8518: Chipconfig( # var1 # watchdog # uart # brom_payload_addr @@ -1777,11 +1777,11 @@ hwconfig = { # socid_addr efuse_addr=0x10009000, dacode=0x8518, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, name="MT8518 VoiceAssistant" # loader ), - 0x8590: chipconfig( + 0x8590: Chipconfig( var1=0xA, # confirmed, router watchdog=0x10007000, uart=0x11002000, @@ -1800,11 +1800,11 @@ hwconfig = { brom_register_access=(0xbeb8, 0xc06c), meid_addr=0x1031D8, dacode=0x8590, - damode=damodes.LEGACY, + damode=DAmodes.LEGACY, name="MT8590/MT7683/MT8521/MT7623", # description= loader="mt8590_payload.bin"), - 0x8695: chipconfig( + 0x8695: Chipconfig( var1=0xA, # confirmed watchdog=0x10007000, uart=0x11002000, @@ -1823,12 +1823,12 @@ hwconfig = { brom_register_access=(0xc298, 0xc3f8), meid_addr=0x1032B8, efuse_addr=0x10206000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x8695, name="MT8695", # mantis # description loader="mt8695_payload.bin"), - 0x908: chipconfig( + 0x908: Chipconfig( # var1 watchdog=0x10007000, # uart @@ -1847,7 +1847,7 @@ hwconfig = { # meid_addr # socid_addr efuse_addr=0x11c10000, - damode=damodes.XFLASH, + damode=DAmodes.XFLASH, dacode=0x8696, # description name="MT8696" diff --git a/mtkclient/config/mtk_config.py b/mtkclient/config/mtk_config.py index 43ff008..954dcf1 100755 --- a/mtkclient/config/mtk_config.py +++ b/mtkclient/config/mtk_config.py @@ -3,8 +3,8 @@ import sys import logging from binascii import hexlify from mtkclient.Library.utils import LogBase -from mtkclient.Library.settings import hwparam -from mtkclient.config.brom_config import chipconfig, damodes, hwconfig +from mtkclient.Library.settings import HwParam +from mtkclient.config.brom_config import Chipconfig, DAmodes, hwconfig try: from PySide6.QtCore import QObject @@ -15,10 +15,11 @@ except ImportError: pass -class Mtk_Config(metaclass=LogBase): +class MtkConfig(metaclass=LogBase): def __init__(self, loglevel=logging.INFO, gui=None, guiprogress=None, update_status_text=None): self.peek = None self.gui = gui + self.loglevel = loglevel self.guiprogress = guiprogress self.update_status_text = update_status_text self.pid = -1 @@ -64,7 +65,7 @@ class Mtk_Config(metaclass=LogBase): self.meid = None self.socid = None self.target_config = None - self.chipconfig = chipconfig() + self.chipconfig = Chipconfig() self.gpt_settings = None self.hwparam = None self.hwparam_path = "." @@ -113,7 +114,7 @@ class Mtk_Config(metaclass=LogBase): self.hwparam.writesetting("hwcode", hex(hwcode)) def set_meid(self, meid): - self.hwparam = hwparam(self, meid, self.hwparam_path) + self.hwparam = HwParam(self, meid, self.hwparam_path) self.meid = meid self.hwparam.writesetting("meid", hexlify(meid).decode('utf-8')) @@ -180,7 +181,7 @@ class Mtk_Config(metaclass=LogBase): if self.chipconfig.ap_dma_mem is None: self.chipconfig.ap_dma_mem = 0x11000000 + 0x1A0 if self.chipconfig.damode is None: - self.chipconfig.damode = damodes.LEGACY + self.chipconfig.damode = DAmodes.LEGACY if self.chipconfig.dxcc_base is None: self.chipconfig.dxcc_base = None if self.chipconfig.meid_addr is None: @@ -195,7 +196,7 @@ class Mtk_Config(metaclass=LogBase): if hwcode in hwconfig: self.chipconfig = hwconfig[hwcode] else: - self.chipconfig = chipconfig() + self.chipconfig = Chipconfig() self.default_values(hwcode) def get_watchdog_addr(self): diff --git a/mtkclient/config/payloads.py b/mtkclient/config/payloads.py index 2ef0bb3..ee7777d 100755 --- a/mtkclient/config/payloads.py +++ b/mtkclient/config/payloads.py @@ -2,7 +2,7 @@ import os -class pathconfig: +class PathConfig: def __init__(self): curscript = os.path.realpath(__file__) self.scriptpath = os.path.dirname(curscript) diff --git a/mtkclient/gui/main_gui.py b/mtkclient/gui/main_gui.py index 58e756e..c026949 100755 --- a/mtkclient/gui/main_gui.py +++ b/mtkclient/gui/main_gui.py @@ -1,15 +1,27 @@ # -*- coding: utf-8 -*- -from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect, - QSize, Qt) -from PySide6.QtGui import QAction, QPixmap -from PySide6.QtWidgets import (QAbstractScrollArea, QCheckBox, QFrame, - QGridLayout, QHBoxLayout, QLabel, - QLayout, QMenu, QMenuBar, - QPlainTextEdit, QProgressBar, QPushButton, QScrollArea, - QSizePolicy, QSpacerItem, QTabWidget, QTableWidget, - QTableWidgetItem, QVBoxLayout, QWidget) +################################################################################ +## Form generated from reading UI file 'main_gui.ui' +## +## Created by: Qt User Interface Compiler version 6.6.3 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient, + QCursor, QFont, QFontDatabase, QGradient, + QIcon, QImage, QKeySequence, QLinearGradient, + QPainter, QPalette, QPixmap, QRadialGradient, + QTransform) +from PySide6.QtWidgets import (QAbstractScrollArea, QApplication, QCheckBox, QFrame, + QGridLayout, QHBoxLayout, QHeaderView, QLabel, + QLayout, QMainWindow, QMenu, QMenuBar, + QPlainTextEdit, QProgressBar, QPushButton, QScrollArea, + QSizePolicy, QSpacerItem, QTabWidget, QTableWidget, + QTableWidgetItem, QVBoxLayout, QWidget) class Ui_MainWindow(object): def setupUi(self, MainWindow): @@ -17,7 +29,7 @@ class Ui_MainWindow(object): MainWindow.setObjectName(u"MainWindow") MainWindow.setWindowModality(Qt.NonModal) MainWindow.resize(746, 720) - sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) + sizePolicy = QSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) @@ -79,33 +91,51 @@ class Ui_MainWindow(object): self.tabWidget.setAutoFillBackground(False) self.readtab = QWidget() self.readtab.setObjectName(u"readtab") - self.gridLayout_7 = QGridLayout(self.readtab) - self.gridLayout_7.setObjectName(u"gridLayout_7") + self.gridLayout_5 = QGridLayout(self.readtab) + self.gridLayout_5.setObjectName(u"gridLayout_5") + self.verticalLayout_8 = QVBoxLayout() + self.verticalLayout_8.setObjectName(u"verticalLayout_8") + self.horizontalLayout_6 = QHBoxLayout() + self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") + self.readselectallcheckbox = QCheckBox(self.readtab) + self.readselectallcheckbox.setObjectName(u"readselectallcheckbox") + + self.horizontalLayout_6.addWidget(self.readselectallcheckbox) + self.readDumpGPTCheckbox = QCheckBox(self.readtab) self.readDumpGPTCheckbox.setObjectName(u"readDumpGPTCheckbox") + sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.readDumpGPTCheckbox.sizePolicy().hasHeightForWidth()) + self.readDumpGPTCheckbox.setSizePolicy(sizePolicy1) - self.gridLayout_7.addWidget(self.readDumpGPTCheckbox, 4, 1, 1, 1) + self.horizontalLayout_6.addWidget(self.readDumpGPTCheckbox) + + self.horizontalSpacer_14 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_6.addItem(self.horizontalSpacer_14) self.readtitle = QLabel(self.readtab) self.readtitle.setObjectName(u"readtitle") - sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.readtitle.sizePolicy().hasHeightForWidth()) - self.readtitle.setSizePolicy(sizePolicy1) - self.readtitle.setMinimumSize(QSize(0, 20)) - self.readtitle.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) - self.gridLayout_7.addWidget(self.readtitle, 0, 0, 1, 1) + self.horizontalLayout_6.addWidget(self.readtitle) + + self.horizontalSpacer_9 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_6.addItem(self.horizontalSpacer_9) self.readpartitionsbtn = QPushButton(self.readtab) self.readpartitionsbtn.setObjectName(u"readpartitionsbtn") - self.gridLayout_7.addWidget(self.readpartitionsbtn, 0, 1, 1, 1) + self.horizontalLayout_6.addWidget(self.readpartitionsbtn) + + + self.verticalLayout_8.addLayout(self.horizontalLayout_6) self.readpartitionList = QScrollArea(self.readtab) self.readpartitionList.setObjectName(u"readpartitionList") - sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) + sizePolicy2 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.MinimumExpanding) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth(self.readpartitionList.sizePolicy().hasHeightForWidth()) @@ -117,37 +147,63 @@ class Ui_MainWindow(object): self.readpartitionList.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") - self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 600, 278)) + self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 700, 311)) self.readpartitionList.setWidget(self.scrollAreaWidgetContents) - self.gridLayout_7.addWidget(self.readpartitionList, 2, 0, 1, 1) + self.verticalLayout_8.addWidget(self.readpartitionList) - self.readselectallcheckbox = QCheckBox(self.readtab) - self.readselectallcheckbox.setObjectName(u"readselectallcheckbox") - self.gridLayout_7.addWidget(self.readselectallcheckbox, 1, 0, 1, 1) + self.gridLayout_5.addLayout(self.verticalLayout_8, 0, 0, 1, 1) self.tabWidget.addTab(self.readtab, "") self.writetab = QWidget() self.writetab.setObjectName(u"writetab") self.gridLayout_6 = QGridLayout(self.writetab) self.gridLayout_6.setObjectName(u"gridLayout_6") + self.verticalLayout_9 = QVBoxLayout() + self.verticalLayout_9.setObjectName(u"verticalLayout_9") + self.horizontalLayout_8 = QHBoxLayout() + self.horizontalLayout_8.setObjectName(u"horizontalLayout_8") self.writetitle = QLabel(self.writetab) self.writetitle.setObjectName(u"writetitle") - sizePolicy1.setHeightForWidth(self.writetitle.sizePolicy().hasHeightForWidth()) - self.writetitle.setSizePolicy(sizePolicy1) + sizePolicy3 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed) + sizePolicy3.setHorizontalStretch(0) + sizePolicy3.setVerticalStretch(0) + sizePolicy3.setHeightForWidth(self.writetitle.sizePolicy().hasHeightForWidth()) + self.writetitle.setSizePolicy(sizePolicy3) self.writetitle.setMinimumSize(QSize(0, 20)) - self.writetitle.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) + self.writetitle.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) - self.gridLayout_6.addWidget(self.writetitle, 0, 0, 1, 1) + self.horizontalLayout_8.addWidget(self.writetitle) + + self.horizontalSpacer_10 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_8.addItem(self.horizontalSpacer_10) + + self.writeselectfromdir = QPushButton(self.writetab) + self.writeselectfromdir.setObjectName(u"writeselectfromdir") + + self.horizontalLayout_8.addWidget(self.writeselectfromdir) + + self.horizontalSpacer_11 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_8.addItem(self.horizontalSpacer_11) + + self.writepartbtn = QPushButton(self.writetab) + self.writepartbtn.setObjectName(u"writepartbtn") + + self.horizontalLayout_8.addWidget(self.writepartbtn) + + + self.verticalLayout_9.addLayout(self.horizontalLayout_8) self.writepartitionList = QScrollArea(self.writetab) self.writepartitionList.setObjectName(u"writepartitionList") - sizePolicy3 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) - sizePolicy3.setHorizontalStretch(0) - sizePolicy3.setVerticalStretch(0) - sizePolicy3.setHeightForWidth(self.writepartitionList.sizePolicy().hasHeightForWidth()) - self.writepartitionList.setSizePolicy(sizePolicy3) + sizePolicy4 = QSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.Expanding) + sizePolicy4.setHorizontalStretch(0) + sizePolicy4.setVerticalStretch(0) + sizePolicy4.setHeightForWidth(self.writepartitionList.sizePolicy().hasHeightForWidth()) + self.writepartitionList.setSizePolicy(sizePolicy4) self.writepartitionList.setMinimumSize(QSize(0, 280)) self.writepartitionList.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.writepartitionList.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) @@ -155,30 +211,57 @@ class Ui_MainWindow(object): self.writepartitionList.setWidgetResizable(True) self.scrollAreaWidgetContents_2 = QWidget() self.scrollAreaWidgetContents_2.setObjectName(u"scrollAreaWidgetContents_2") - self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 577, 327)) + self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 700, 311)) self.writepartitionList.setWidget(self.scrollAreaWidgetContents_2) - self.gridLayout_6.addWidget(self.writepartitionList, 1, 0, 2, 1) + self.verticalLayout_9.addWidget(self.writepartitionList) - self.writepartbtn = QPushButton(self.writetab) - self.writepartbtn.setObjectName(u"writepartbtn") - self.gridLayout_6.addWidget(self.writepartbtn, 0, 1, 1, 1) - - self.writeselectfromdir = QPushButton(self.writetab) - self.writeselectfromdir.setObjectName(u"writeselectfromdir") - - self.gridLayout_6.addWidget(self.writeselectfromdir, 2, 1, 1, 1) + self.gridLayout_6.addLayout(self.verticalLayout_9, 0, 0, 1, 1) self.tabWidget.addTab(self.writetab, "") self.erasetab = QWidget() self.erasetab.setObjectName(u"erasetab") - self.gridLayout_5 = QGridLayout(self.erasetab) - self.gridLayout_5.setObjectName(u"gridLayout_5") + self.horizontalLayout_10 = QHBoxLayout(self.erasetab) + self.horizontalLayout_10.setObjectName(u"horizontalLayout_10") + self.verticalLayout_10 = QVBoxLayout() + self.verticalLayout_10.setObjectName(u"verticalLayout_10") + self.horizontalLayout_9 = QHBoxLayout() + self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") + self.erasetitle = QLabel(self.erasetab) + self.erasetitle.setObjectName(u"erasetitle") + sizePolicy3.setHeightForWidth(self.erasetitle.sizePolicy().hasHeightForWidth()) + self.erasetitle.setSizePolicy(sizePolicy3) + self.erasetitle.setMinimumSize(QSize(0, 20)) + self.erasetitle.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) + + self.horizontalLayout_9.addWidget(self.erasetitle) + + self.horizontalSpacer_13 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_9.addItem(self.horizontalSpacer_13) + + self.eraseselectallpartitionscheckbox = QCheckBox(self.erasetab) + self.eraseselectallpartitionscheckbox.setObjectName(u"eraseselectallpartitionscheckbox") + + self.horizontalLayout_9.addWidget(self.eraseselectallpartitionscheckbox) + + self.horizontalSpacer_12 = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + + self.horizontalLayout_9.addItem(self.horizontalSpacer_12) + + self.erasepartitionsbtn = QPushButton(self.erasetab) + self.erasepartitionsbtn.setObjectName(u"erasepartitionsbtn") + + self.horizontalLayout_9.addWidget(self.erasepartitionsbtn) + + + self.verticalLayout_10.addLayout(self.horizontalLayout_9) + self.erasepartitionList = QScrollArea(self.erasetab) self.erasepartitionList.setObjectName(u"erasepartitionList") - sizePolicy3.setHeightForWidth(self.erasepartitionList.sizePolicy().hasHeightForWidth()) - self.erasepartitionList.setSizePolicy(sizePolicy3) + sizePolicy4.setHeightForWidth(self.erasepartitionList.sizePolicy().hasHeightForWidth()) + self.erasepartitionList.setSizePolicy(sizePolicy4) self.erasepartitionList.setMinimumSize(QSize(0, 280)) self.erasepartitionList.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.erasepartitionList.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) @@ -186,29 +269,13 @@ class Ui_MainWindow(object): self.erasepartitionList.setWidgetResizable(True) self.scrollAreaWidgetContents_3 = QWidget() self.scrollAreaWidgetContents_3.setObjectName(u"scrollAreaWidgetContents_3") - self.scrollAreaWidgetContents_3.setGeometry(QRect(0, 0, 598, 298)) + self.scrollAreaWidgetContents_3.setGeometry(QRect(0, 0, 700, 311)) self.erasepartitionList.setWidget(self.scrollAreaWidgetContents_3) - self.gridLayout_5.addWidget(self.erasepartitionList, 2, 0, 2, 1) + self.verticalLayout_10.addWidget(self.erasepartitionList) - self.erasetitle = QLabel(self.erasetab) - self.erasetitle.setObjectName(u"erasetitle") - sizePolicy1.setHeightForWidth(self.erasetitle.sizePolicy().hasHeightForWidth()) - self.erasetitle.setSizePolicy(sizePolicy1) - self.erasetitle.setMinimumSize(QSize(0, 20)) - self.erasetitle.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) - self.gridLayout_5.addWidget(self.erasetitle, 0, 0, 1, 1) - - self.erasepartitionsbtn = QPushButton(self.erasetab) - self.erasepartitionsbtn.setObjectName(u"erasepartitionsbtn") - - self.gridLayout_5.addWidget(self.erasepartitionsbtn, 0, 1, 1, 1) - - self.eraseselectallpartitionscheckbox = QCheckBox(self.erasetab) - self.eraseselectallpartitionscheckbox.setObjectName(u"eraseselectallpartitionscheckbox") - - self.gridLayout_5.addWidget(self.eraseselectallpartitionscheckbox, 1, 0, 1, 1) + self.horizontalLayout_10.addLayout(self.verticalLayout_10) self.tabWidget.addTab(self.erasetab, "") self.tab = QWidget() @@ -237,10 +304,11 @@ class Ui_MainWindow(object): self.verticalLayout_2.addWidget(self.readrpmbbtn) - self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) self.verticalLayout_2.addItem(self.verticalSpacer) + self.gridLayout_4.addLayout(self.verticalLayout_2, 0, 0, 2, 1) self.verticalLayout_3 = QVBoxLayout() @@ -265,10 +333,11 @@ class Ui_MainWindow(object): self.verticalLayout_3.addWidget(self.writerpmbbtn) - self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(self.verticalSpacer_2) + self.gridLayout_4.addLayout(self.verticalLayout_3, 0, 1, 2, 1) self.verticalLayout_4 = QVBoxLayout() @@ -288,10 +357,11 @@ class Ui_MainWindow(object): self.verticalLayout_4.addWidget(self.eraserpmbbtn) - self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) self.verticalLayout_4.addItem(self.verticalSpacer_3) + self.gridLayout_4.addLayout(self.verticalLayout_4, 0, 2, 1, 1) self.verticalLayout_5 = QVBoxLayout() @@ -306,6 +376,7 @@ class Ui_MainWindow(object): self.verticalLayout_5.addWidget(self.unlockbutton) + self.gridLayout_4.addLayout(self.verticalLayout_5, 1, 2, 1, 1) self.tabWidget.addTab(self.tab, "") @@ -314,13 +385,13 @@ class Ui_MainWindow(object): self.gridLayout_2 = QGridLayout(self.keytab) self.gridLayout_2.setObjectName(u"gridLayout_2") self.keytable = QTableWidget(self.keytab) - if self.keytable.columnCount() < 2: + if (self.keytable.columnCount() < 2): self.keytable.setColumnCount(2) __qtablewidgetitem = QTableWidgetItem() self.keytable.setHorizontalHeaderItem(0, __qtablewidgetitem) __qtablewidgetitem1 = QTableWidgetItem() self.keytable.setHorizontalHeaderItem(1, __qtablewidgetitem1) - if self.keytable.rowCount() < 7: + if (self.keytable.rowCount() < 7): self.keytable.setRowCount(7) __qtablewidgetitem2 = QTableWidgetItem() self.keytable.setVerticalHeaderItem(0, __qtablewidgetitem2) @@ -356,7 +427,7 @@ class Ui_MainWindow(object): self.generatekeybtn = QPushButton(self.keytab) self.generatekeybtn.setObjectName(u"generatekeybtn") - self.gridLayout_2.addWidget(self.generatekeybtn, 3, 0, 1, 1) + self.gridLayout_2.addWidget(self.generatekeybtn, 0, 0, 1, 1) self.tabWidget.addTab(self.keytab, "") self.debugtab = QWidget() @@ -372,11 +443,11 @@ class Ui_MainWindow(object): self.logBox = QPlainTextEdit(self.debugtab) self.logBox.setObjectName(u"logBox") - sizePolicy4 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - sizePolicy4.setHorizontalStretch(0) - sizePolicy4.setVerticalStretch(0) - sizePolicy4.setHeightForWidth(self.logBox.sizePolicy().hasHeightForWidth()) - self.logBox.setSizePolicy(sizePolicy4) + sizePolicy5 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) + sizePolicy5.setHorizontalStretch(0) + sizePolicy5.setVerticalStretch(0) + sizePolicy5.setHeightForWidth(self.logBox.sizePolicy().hasHeightForWidth()) + self.logBox.setSizePolicy(sizePolicy5) self.logBox.setMinimumSize(QSize(700, 0)) self.logBox.setStyleSheet(u"") self.logBox.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) @@ -385,6 +456,7 @@ class Ui_MainWindow(object): self.gridLayout.addWidget(self.logBox, 0, 0, 1, 2) + self.gridLayout_3.addLayout(self.gridLayout, 0, 0, 1, 1) self.tabWidget.addTab(self.debugtab, "") @@ -413,13 +485,14 @@ class Ui_MainWindow(object): self.Main.addWidget(self.fullProgress) + self.gridLayout_8.addLayout(self.Main, 3, 0, 1, 1) self.connectInfo = QWidget(self.centralwidget) self.connectInfo.setObjectName(u"connectInfo") self.connectInfo.setEnabled(True) - sizePolicy1.setHeightForWidth(self.connectInfo.sizePolicy().hasHeightForWidth()) - self.connectInfo.setSizePolicy(sizePolicy1) + sizePolicy3.setHeightForWidth(self.connectInfo.sizePolicy().hasHeightForWidth()) + self.connectInfo.setSizePolicy(sizePolicy3) self.connectInfo.setMinimumSize(QSize(0, 0)) self.connectInfo.setMaximumSize(QSize(16777215, 0)) self.verticalLayout_6 = QVBoxLayout(self.connectInfo) @@ -430,11 +503,11 @@ class Ui_MainWindow(object): self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setSpacing(0) self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") - self.horizontalSpacer_2 = QSpacerItem(5, 20, QSizePolicy.Minimum, QSizePolicy.Minimum) + self.horizontalSpacer_2 = QSpacerItem(5, 20, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) self.horizontalLayout_4.addItem(self.horizontalSpacer_2) - self.horizontalSpacer_7 = QSpacerItem(9, 20, QSizePolicy.Fixed, QSizePolicy.Minimum) + self.horizontalSpacer_7 = QSpacerItem(9, 20, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) self.horizontalLayout_4.addItem(self.horizontalSpacer_7) @@ -445,81 +518,83 @@ class Ui_MainWindow(object): self.initStepsImage.setFrameShape(QFrame.NoFrame) self.initStepsImage.setPixmap(QPixmap(u"images/initsteps.png")) self.initStepsImage.setScaledContents(True) - self.initStepsImage.setAlignment(Qt.AlignHCenter | Qt.AlignTop) + self.initStepsImage.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.initStepsImage.setWordWrap(False) self.initStepsImage.setMargin(0) self.horizontalLayout_4.addWidget(self.initStepsImage) - self.horizontalSpacer = QSpacerItem(5, 18, QSizePolicy.Minimum, QSizePolicy.Minimum) + self.horizontalSpacer = QSpacerItem(5, 18, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) self.horizontalLayout_4.addItem(self.horizontalSpacer) + self.verticalLayout_6.addLayout(self.horizontalLayout_4) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") - self.horizontalSpacer_6 = QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalSpacer_6 = QSpacerItem(10, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer_6) self.label_2 = QLabel(self.connectInfo) self.label_2.setObjectName(u"label_2") - sizePolicy5 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) - sizePolicy5.setHorizontalStretch(0) - sizePolicy5.setVerticalStretch(0) - sizePolicy5.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) - self.label_2.setSizePolicy(sizePolicy5) + sizePolicy6 = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred) + sizePolicy6.setHorizontalStretch(0) + sizePolicy6.setVerticalStretch(0) + sizePolicy6.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) + self.label_2.setSizePolicy(sizePolicy6) self.label_2.setMinimumSize(QSize(195, 0)) self.label_2.setMaximumSize(QSize(195, 16777215)) - self.label_2.setAlignment(Qt.AlignHCenter | Qt.AlignTop) + self.label_2.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.label_2.setWordWrap(True) self.label_2.setMargin(5) self.horizontalLayout_3.addWidget(self.label_2) - self.horizontalSpacer_3 = QSpacerItem(50, 0, QSizePolicy.Fixed, QSizePolicy.Minimum) + self.horizontalSpacer_3 = QSpacerItem(50, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer_3) self.label_3 = QLabel(self.connectInfo) self.label_3.setObjectName(u"label_3") - sizePolicy5.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) - self.label_3.setSizePolicy(sizePolicy5) + sizePolicy6.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) + self.label_3.setSizePolicy(sizePolicy6) self.label_3.setMinimumSize(QSize(195, 10)) self.label_3.setMaximumSize(QSize(195, 16777215)) - self.label_3.setAlignment(Qt.AlignHCenter | Qt.AlignTop) + self.label_3.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.label_3.setWordWrap(True) self.label_3.setMargin(5) self.horizontalLayout_3.addWidget(self.label_3) - self.horizontalSpacer_4 = QSpacerItem(50, 0, QSizePolicy.Fixed, QSizePolicy.Minimum) + self.horizontalSpacer_4 = QSpacerItem(50, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer_4) self.label_4 = QLabel(self.connectInfo) self.label_4.setObjectName(u"label_4") - sizePolicy5.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) - self.label_4.setSizePolicy(sizePolicy5) + sizePolicy6.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) + self.label_4.setSizePolicy(sizePolicy6) self.label_4.setMinimumSize(QSize(195, 0)) self.label_4.setMaximumSize(QSize(195, 16777215)) self.label_4.setScaledContents(False) - self.label_4.setAlignment(Qt.AlignHCenter | Qt.AlignTop) + self.label_4.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.label_4.setWordWrap(True) self.label_4.setMargin(5) self.horizontalLayout_3.addWidget(self.label_4) - self.horizontalSpacer_5 = QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalSpacer_5 = QSpacerItem(10, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(self.horizontalSpacer_5) + self.verticalLayout_6.addLayout(self.horizontalLayout_3) self.horizontalLayout_5 = QHBoxLayout() self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") - self.horizontalSpacer_showdebug = QSpacerItem(50, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalSpacer_showdebug = QSpacerItem(50, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) self.horizontalLayout_5.addItem(self.horizontalSpacer_showdebug) @@ -528,8 +603,10 @@ class Ui_MainWindow(object): self.horizontalLayout_5.addWidget(self.showdebugbtn) + self.verticalLayout_6.addLayout(self.horizontalLayout_5) + self.gridLayout_8.addWidget(self.connectInfo, 2, 0, 1, 1) self.line_2 = QFrame(self.centralwidget) @@ -552,28 +629,30 @@ class Ui_MainWindow(object): self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) self.logoPic = QLabel(self.centralwidget) self.logoPic.setObjectName(u"logoPic") - sizePolicy6 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - sizePolicy6.setHorizontalStretch(0) - sizePolicy6.setVerticalStretch(0) - sizePolicy6.setHeightForWidth(self.logoPic.sizePolicy().hasHeightForWidth()) - self.logoPic.setSizePolicy(sizePolicy6) + sizePolicy7 = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) + sizePolicy7.setHorizontalStretch(0) + sizePolicy7.setVerticalStretch(0) + sizePolicy7.setHeightForWidth(self.logoPic.sizePolicy().hasHeightForWidth()) + self.logoPic.setSizePolicy(sizePolicy7) self.logoPic.setMinimumSize(QSize(158, 158)) self.logoPic.setMaximumSize(QSize(158, 158)) self.logoPic.setPixmap(QPixmap(u"images/logo_256.png")) self.logoPic.setScaledContents(True) - self.logoPic.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignTop) + self.logoPic.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) self.horizontalLayout.addWidget(self.logoPic) self.copyrightInfo = QLabel(self.centralwidget) self.copyrightInfo.setObjectName(u"copyrightInfo") - sizePolicy6.setHeightForWidth(self.copyrightInfo.sizePolicy().hasHeightForWidth()) - self.copyrightInfo.setSizePolicy(sizePolicy6) + sizePolicy7.setHeightForWidth(self.copyrightInfo.sizePolicy().hasHeightForWidth()) + self.copyrightInfo.setSizePolicy(sizePolicy7) self.horizontalLayout.addWidget(self.copyrightInfo) + self.verticalLayout.addLayout(self.horizontalLayout) + self.topInfo.addLayout(self.verticalLayout) self.verticalLayout_7 = QVBoxLayout() @@ -581,19 +660,16 @@ class Ui_MainWindow(object): self.verticalLayout_7.setObjectName(u"verticalLayout_7") self.phoneInfoTextbox = QLabel(self.centralwidget) self.phoneInfoTextbox.setObjectName(u"phoneInfoTextbox") - sizePolicy7 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) - sizePolicy7.setHorizontalStretch(0) - sizePolicy7.setVerticalStretch(0) - sizePolicy7.setHeightForWidth(self.phoneInfoTextbox.sizePolicy().hasHeightForWidth()) - self.phoneInfoTextbox.setSizePolicy(sizePolicy7) - self.phoneInfoTextbox.setAlignment(Qt.AlignRight | Qt.AlignTop | Qt.AlignTrailing) + sizePolicy1.setHeightForWidth(self.phoneInfoTextbox.sizePolicy().hasHeightForWidth()) + self.phoneInfoTextbox.setSizePolicy(sizePolicy1) + self.phoneInfoTextbox.setAlignment(Qt.AlignRight|Qt.AlignTop|Qt.AlignTrailing) self.phoneInfoTextbox.setWordWrap(True) self.verticalLayout_7.addWidget(self.phoneInfoTextbox) self.phoneDebugInfoTextbox = QLabel(self.centralwidget) self.phoneDebugInfoTextbox.setObjectName(u"phoneDebugInfoTextbox") - sizePolicy8 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) + sizePolicy8 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) sizePolicy8.setHorizontalStretch(0) sizePolicy8.setVerticalStretch(0) sizePolicy8.setHeightForWidth(self.phoneDebugInfoTextbox.sizePolicy().hasHeightForWidth()) @@ -602,7 +678,7 @@ class Ui_MainWindow(object): self.phoneDebugInfoTextbox.setMaximumSize(QSize(16777215, 110)) self.phoneDebugInfoTextbox.setStyleSheet(u"color:#888;") self.phoneDebugInfoTextbox.setTextFormat(Qt.PlainText) - self.phoneDebugInfoTextbox.setAlignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignTrailing) + self.phoneDebugInfoTextbox.setAlignment(Qt.AlignBottom|Qt.AlignRight|Qt.AlignTrailing) self.verticalLayout_7.addWidget(self.phoneDebugInfoTextbox) @@ -611,36 +687,38 @@ class Ui_MainWindow(object): self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.horizontalLayout_2.setSizeConstraint(QLayout.SetDefaultConstraint) self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1) - self.horizontalSpacer_8 = QSpacerItem(20, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalSpacer_8 = QSpacerItem(20, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(self.horizontalSpacer_8) self.consettingsbtn = QPushButton(self.centralwidget) self.consettingsbtn.setObjectName(u"consettingsbtn") - sizePolicy6.setHeightForWidth(self.consettingsbtn.sizePolicy().hasHeightForWidth()) - self.consettingsbtn.setSizePolicy(sizePolicy6) - self.consettingsbtn.setMaximumSize(QSize(120, 16777215)) + sizePolicy7.setHeightForWidth(self.consettingsbtn.sizePolicy().hasHeightForWidth()) + self.consettingsbtn.setSizePolicy(sizePolicy7) + self.consettingsbtn.setMaximumSize(QSize(140, 16777215)) self.horizontalLayout_2.addWidget(self.consettingsbtn) + self.verticalLayout_7.addLayout(self.horizontalLayout_2) - self.verticalSpacer_5 = QSpacerItem(20, 2, QSizePolicy.Minimum, QSizePolicy.Maximum) + self.verticalSpacer_5 = QSpacerItem(20, 2, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Maximum) self.verticalLayout_7.addItem(self.verticalSpacer_5) + self.topInfo.addLayout(self.verticalLayout_7) self.widget_3 = QWidget(self.centralwidget) self.widget_3.setObjectName(u"widget_3") - sizePolicy6.setHeightForWidth(self.widget_3.sizePolicy().hasHeightForWidth()) - self.widget_3.setSizePolicy(sizePolicy6) + sizePolicy7.setHeightForWidth(self.widget_3.sizePolicy().hasHeightForWidth()) + self.widget_3.setSizePolicy(sizePolicy7) self.widget_3.setMinimumSize(QSize(90, 158)) self.pic = QLabel(self.widget_3) self.pic.setObjectName(u"pic") self.pic.setGeometry(QRect(0, 0, 90, 158)) - sizePolicy6.setHeightForWidth(self.pic.sizePolicy().hasHeightForWidth()) - self.pic.setSizePolicy(sizePolicy6) + sizePolicy7.setHeightForWidth(self.pic.sizePolicy().hasHeightForWidth()) + self.pic.setSizePolicy(sizePolicy7) self.pic.setMinimumSize(QSize(90, 158)) self.pic.setMaximumSize(QSize(90, 158)) self.pic.setPixmap(QPixmap(u"images/phone_notfound.png")) @@ -650,14 +728,15 @@ class Ui_MainWindow(object): self.spinner_pic = QLabel(self.widget_3) self.spinner_pic.setObjectName(u"spinner_pic") self.spinner_pic.setGeometry(QRect(20, 55, 51, 51)) - sizePolicy6.setHeightForWidth(self.spinner_pic.sizePolicy().hasHeightForWidth()) - self.spinner_pic.setSizePolicy(sizePolicy6) + sizePolicy7.setHeightForWidth(self.spinner_pic.sizePolicy().hasHeightForWidth()) + self.spinner_pic.setSizePolicy(sizePolicy7) self.spinner_pic.setPixmap(QPixmap(u"images/phone_loading.png")) self.spinner_pic.setScaledContents(True) self.spinner_pic.setAlignment(Qt.AlignCenter) self.topInfo.addWidget(self.widget_3) + self.gridLayout_8.addLayout(self.topInfo, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) @@ -665,27 +744,27 @@ class Ui_MainWindow(object): self.connectInfo.raise_() self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") - self.menubar.setGeometry(QRect(0, 0, 746, 22)) + self.menubar.setGeometry(QRect(0, 0, 746, 24)) self.menuFile = QMenu(self.menubar) self.menuFile.setObjectName(u"menuFile") MainWindow.setMenuBar(self.menubar) - # if QT_CONFIG(shortcut) +#if QT_CONFIG(shortcut) self.logoPic.setBuddy(self.logoPic) - # endif // QT_CONFIG(shortcut) +#endif // QT_CONFIG(shortcut) self.menubar.addAction(self.menuFile.menuAction()) self.menuFile.addAction(self.action_Quit) self.retranslateUi(MainWindow) - self.tabWidget.setCurrentIndex(5) + self.tabWidget.setCurrentIndex(0) + QMetaObject.connectSlotsByName(MainWindow) - # setupUi def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MTKClient v2.0", None)) + MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MTKClient v2.01", None)) self.actionRead_partition_s.setText(QCoreApplication.translate("MainWindow", u"Quit", None)) self.actionRead_full_flash.setText(QCoreApplication.translate("MainWindow", u"Read full flash", None)) self.actionRead_offset.setText(QCoreApplication.translate("MainWindow", u"Read at offset", None)) @@ -704,23 +783,19 @@ class Ui_MainWindow(object): self.actionUnlock_device.setText(QCoreApplication.translate("MainWindow", u"Unlock / Lock", None)) self.actionLock_device.setText(QCoreApplication.translate("MainWindow", u"Lock device", None)) self.action_Quit.setText(QCoreApplication.translate("MainWindow", u"&Quit", None)) - self.readDumpGPTCheckbox.setText(QCoreApplication.translate("MainWindow", u"Dump GPT", None)) - self.readtitle.setText(QCoreApplication.translate("MainWindow", u"Select partitions to read", None)) - self.readpartitionsbtn.setText(QCoreApplication.translate("MainWindow", u"Read partition(s)", None)) self.readselectallcheckbox.setText(QCoreApplication.translate("MainWindow", u"Select all partitions", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.readtab), - QCoreApplication.translate("MainWindow", u"Read partition(s)", None)) + self.readDumpGPTCheckbox.setText(QCoreApplication.translate("MainWindow", u"Dump GPT", None)) + self.readtitle.setText("") + self.readpartitionsbtn.setText(QCoreApplication.translate("MainWindow", u"Read partition(s)", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.readtab), QCoreApplication.translate("MainWindow", u"Read partition(s)", None)) self.writetitle.setText(QCoreApplication.translate("MainWindow", u"Select partitions to write", None)) - self.writepartbtn.setText(QCoreApplication.translate("MainWindow", u"Write partition(s)", None)) self.writeselectfromdir.setText(QCoreApplication.translate("MainWindow", u"Select from directory", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.writetab), - QCoreApplication.translate("MainWindow", u"Write partition(s)", None)) + self.writepartbtn.setText(QCoreApplication.translate("MainWindow", u"Write partition(s)", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.writetab), QCoreApplication.translate("MainWindow", u"Write partition(s)", None)) self.erasetitle.setText(QCoreApplication.translate("MainWindow", u"Select partitions to erase", None)) + self.eraseselectallpartitionscheckbox.setText(QCoreApplication.translate("MainWindow", u"Select all partitions", None)) self.erasepartitionsbtn.setText(QCoreApplication.translate("MainWindow", u"Erase partition(s)", None)) - self.eraseselectallpartitionscheckbox.setText( - QCoreApplication.translate("MainWindow", u"Select all partitions", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.erasetab), - QCoreApplication.translate("MainWindow", u"Erase partition(s)", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.erasetab), QCoreApplication.translate("MainWindow", u"Erase partition(s)", None)) self.readflashbtn.setText(QCoreApplication.translate("MainWindow", u"Read flash", None)) self.readpreloaderbtn.setText(QCoreApplication.translate("MainWindow", u"Read preloader", None)) self.readboot2btn.setText(QCoreApplication.translate("MainWindow", u"Read boot2", None)) @@ -734,49 +809,38 @@ class Ui_MainWindow(object): self.eraserpmbbtn.setText(QCoreApplication.translate("MainWindow", u"Erase RPMB", None)) self.lockbutton.setText(QCoreApplication.translate("MainWindow", u"Lock bootloader", None)) self.unlockbutton.setText(QCoreApplication.translate("MainWindow", u"Unlock bootloader", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), - QCoreApplication.translate("MainWindow", u"Flash Tools", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QCoreApplication.translate("MainWindow", u"Flash Tools", None)) ___qtablewidgetitem = self.keytable.horizontalHeaderItem(0) - ___qtablewidgetitem.setText(QCoreApplication.translate("MainWindow", u"Type", None)) + ___qtablewidgetitem.setText(QCoreApplication.translate("MainWindow", u"Type", None)); ___qtablewidgetitem1 = self.keytable.horizontalHeaderItem(1) - ___qtablewidgetitem1.setText(QCoreApplication.translate("MainWindow", u"Value", None)) + ___qtablewidgetitem1.setText(QCoreApplication.translate("MainWindow", u"Value", None)); ___qtablewidgetitem2 = self.keytable.verticalHeaderItem(0) - ___qtablewidgetitem2.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem2.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem3 = self.keytable.verticalHeaderItem(1) - ___qtablewidgetitem3.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem3.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem4 = self.keytable.verticalHeaderItem(2) - ___qtablewidgetitem4.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem4.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem5 = self.keytable.verticalHeaderItem(3) - ___qtablewidgetitem5.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem5.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem6 = self.keytable.verticalHeaderItem(4) - ___qtablewidgetitem6.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem6.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem7 = self.keytable.verticalHeaderItem(5) - ___qtablewidgetitem7.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem7.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); ___qtablewidgetitem8 = self.keytable.verticalHeaderItem(6) - ___qtablewidgetitem8.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)) + ___qtablewidgetitem8.setText(QCoreApplication.translate("MainWindow", u"Neue Zeile", None)); self.keystatuslabel.setText(QCoreApplication.translate("MainWindow", u"Ready.", None)) self.generatekeybtn.setText(QCoreApplication.translate("MainWindow", u"Generate Keys", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.keytab), - QCoreApplication.translate("MainWindow", u"Keys", None)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.debugtab), - QCoreApplication.translate("MainWindow", u"Debug Log", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.keytab), QCoreApplication.translate("MainWindow", u"Keys", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.debugtab), QCoreApplication.translate("MainWindow", u"Debug Log", None)) self.partProgressText.setText("") self.fullProgressText.setText("") self.initStepsImage.setText("") - self.label_2.setText(QCoreApplication.translate("MainWindow", - u" Step 1:
Power off the phone
", - None)) - self.label_3.setText(QCoreApplication.translate("MainWindow", - u"Step 2:
Connect the USB cable, hold both volume buttons if needed
", - None)) - self.label_4.setText(QCoreApplication.translate("MainWindow", - u"No connection? Try shorting the test point to ground
", - None)) + self.label_2.setText(QCoreApplication.translate("MainWindow", u"
Step 1:
Power off the phone
", None)) + self.label_3.setText(QCoreApplication.translate("MainWindow", u"Step 2:
Connect the USB cable, hold both volume buttons if needed
", None)) + self.label_4.setText(QCoreApplication.translate("MainWindow", u"No connection? Try shorting the test point to ground
", None)) self.showdebugbtn.setText(QCoreApplication.translate("MainWindow", u"Show Debug Log", None)) self.logoPic.setText("") - self.copyrightInfo.setText(QCoreApplication.translate("MainWindow", - u"Made by: Bjoern Kerler