mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 03:04:54 -05:00
Restructure and fix incorrect MTK_DA_V6
This commit is contained in:
parent
bb28c35f00
commit
d394dbd1db
21 changed files with 62 additions and 40 deletions
2
mtk.bat
2
mtk.bat
|
@ -1,3 +1,3 @@
|
|||
@echo off
|
||||
title MTKClient
|
||||
python "%~dp0mtk" %*
|
||||
python "%~dp0mtk.py" %*
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import argparse
|
||||
from mtkclient.Library.mtk_main import Main, metamodes
|
||||
|
||||
info = "MTK Flash/Exploit Client Public V2.0.0 (c) B.Kerler 2018-2024"
|
||||
info = "MTK Flash/Exploit Client Public V2.0.1 (c) B.Kerler 2018-2024"
|
||||
|
||||
cmds = {
|
||||
"printgpt": "Print GPT Table information",
|
|
@ -5,7 +5,7 @@ today = date.today()
|
|||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['mtk'],
|
||||
a = Analysis(['mtk.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('mtkclient/Windows/*', '.'), ('mtkclient/payloads', 'mtkclient/payloads'), ('mtkclient/Loader', 'mtkclient/Loader'), ('mtkclient/Library/Filesystem/bin', 'mtkclient/Library/Filesystem/bin')],
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@echo off
|
||||
title MTKClient Log
|
||||
python "%~dp0mtk_gui"
|
||||
python "%~dp0mtk_gui.py"
|
||||
|
|
|
@ -5,7 +5,7 @@ today = date.today()
|
|||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['mtk_gui'],
|
||||
a = Analysis(['mtk_gui.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('mtkclient/gui/images', 'mtkclient/gui/images'), ('mtkclient/Windows/*', '.'), ('mtkclient/payloads', 'mtkclient/payloads'), ('mtkclient/Loader', 'mtkclient/Loader'), ('mtkclient/Library/Filesystem/bin', 'mtkclient/Library/Filesystem/bin')],
|
||||
|
|
|
@ -83,7 +83,7 @@ class DA_handler(metaclass=LogBase):
|
|||
else:
|
||||
if mtk.serialportname is not None:
|
||||
mtk.preloader.init()
|
||||
if mtk.port.cdc.connected and os.path.exists(".state"):
|
||||
if mtk.port.cdc.connected and os.path.exists(os.path.join(mtk.hwparamFolder,".state")):
|
||||
mtk.daloader.reinit()
|
||||
return mtk
|
||||
if mtk.config.target_config is None:
|
||||
|
@ -757,10 +757,10 @@ class DA_handler(metaclass=LogBase):
|
|||
self.close()
|
||||
self.da_ess(sector=sector, parttype=parttype, sectors=sectors)
|
||||
elif cmd == "reset":
|
||||
if os.path.exists(".state"):
|
||||
os.remove(".state")
|
||||
if os.path.exists(os.path.join("logs", "hwparam.json")):
|
||||
os.remove(os.path.join("logs", "hwparam.json"))
|
||||
if os.path.exists(os.path.join(self.mtk.config.hwparam_path, ".state")):
|
||||
os.remove(os.path.join(self.mtk.config.hwparam_path, ".state"))
|
||||
if os.path.exists(os.path.join(self.mtk.config.hwparam_path, "hwparam.json")):
|
||||
os.remove(os.path.join(self.mtk.config.hwparam_path, "hwparam.json"))
|
||||
mtk.daloader.shutdown(bootmode=0)
|
||||
print("Reset command was sent. Disconnect usb cable to power off.")
|
||||
elif cmd == "da":
|
||||
|
|
|
@ -69,7 +69,7 @@ class DAloader(metaclass=LogBase):
|
|||
if not self.mtk.config.iot:
|
||||
config["m_sdmmc_ua_size"] = self.da.sdc.m_sdmmc_ua_size
|
||||
|
||||
open(".state", "w").write(json.dumps(config))
|
||||
open(os.path.join(self.mtk.config.hwparam_path, ".state"), "w").write(json.dumps(config))
|
||||
|
||||
def compute_hash_pos(self, da1, da2, da1sig_len, da2sig_len, v6):
|
||||
hashlen = len(da2) - da2sig_len
|
||||
|
@ -135,8 +135,8 @@ class DAloader(metaclass=LogBase):
|
|||
return da1
|
||||
|
||||
def reinit(self):
|
||||
if os.path.exists(".state"):
|
||||
config = json.loads(open(".state", "r").read())
|
||||
if os.path.exists(os.path.join(self.mtk.config.hwparam_path, ".state")):
|
||||
config = json.loads(open(os.path.join(self.mtk.config.hwparam_path, ".state"), "r").read())
|
||||
self.config.hwcode = config["hwcode"]
|
||||
if "meid" in config:
|
||||
self.config.meid = bytes.fromhex(config["meid"])
|
||||
|
@ -153,7 +153,7 @@ class DAloader(metaclass=LogBase):
|
|||
self.flashmode = damodes.XML
|
||||
self.config.init_hwcode(self.config.hwcode)
|
||||
if self.config.meid is not None:
|
||||
self.config.hwparam = hwparam(self.config.meid.hex(), self.mtk.config.hwparam_path)
|
||||
self.config.hwparam = hwparam(self.mtk.config, self.config.meid.hex(), self.mtk.config.hwparam_path)
|
||||
if self.flashmode == damodes.XML:
|
||||
self.da = DAXML(self.mtk, self.daconfig, self.loglevel)
|
||||
self.daconfig.flashtype = config["flashtype"]
|
||||
|
|
|
@ -1188,7 +1188,7 @@ class DAXFlash(metaclass=LogBase):
|
|||
if status == 0x0 and unpack("<I", ret)[0] == 0xA1A2A3A4:
|
||||
self.info("DA Extensions successfully added")
|
||||
self.daext = True
|
||||
self.config.hwparam = hwparam(self.mtk.config.meid, self.mtk.config.hwparam_path)
|
||||
self.config.hwparam = hwparam(self.mtk.config, self.mtk.config.meid, self.mtk.config.hwparam_path)
|
||||
self.config.hwparam.writesetting("hwcode", hex(self.config.hwcode))
|
||||
if not self.daext:
|
||||
self.warning("DA Extensions failed to enable")
|
||||
|
|
0
mtkclient/Library/Filesystem/__init__.py
Normal file
0
mtkclient/Library/Filesystem/__init__.py
Normal file
|
@ -11,6 +11,7 @@ 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 mtkclient.Library.utils import LogBase, logsetup
|
||||
from mtkclient.Library.error import ErrorHandler
|
||||
from mtkclient.config.brom_config import damodes
|
||||
|
@ -162,10 +163,10 @@ class Preloader(metaclass=LogBase):
|
|||
self.sendcmd = self.mtk.port.mtk_cmd
|
||||
|
||||
def init(self, maxtries=None, display=True):
|
||||
if os.path.exists(".state"):
|
||||
if os.path.exists(os.path.join(self.mtk.config.hwparam_path, ".state")):
|
||||
try:
|
||||
os.remove(".state")
|
||||
os.remove(os.path.join("logs", "hwparam.json"))
|
||||
os.remove(os.path.join(self.mtk.config.hwparam_path, ".state"))
|
||||
os.remove(os.path.join(self.mtk.config.hwparam_path, "hwparam.json"))
|
||||
except OSError:
|
||||
pass
|
||||
readsocid = self.config.readsocid
|
||||
|
|
|
@ -8,9 +8,10 @@ class hwparam:
|
|||
hwcode = None
|
||||
appid = b""
|
||||
|
||||
def __init__(self, meid: str, path: str = "logs"):
|
||||
def __init__(self, config, meid: str, path: str = "logs"):
|
||||
self.config = config
|
||||
self.paramfile = "hwparam.json"
|
||||
self.hwparampath = path
|
||||
self.config.hwparam_path = path
|
||||
self.appid = b""
|
||||
if isinstance(meid, bytearray) or isinstance(meid, bytes):
|
||||
meid = hexlify(meid).decode('utf-8')
|
||||
|
@ -18,8 +19,8 @@ class hwparam:
|
|||
self.paramsetting = {}
|
||||
if meid is not None:
|
||||
self.paramsetting["meid"] = meid
|
||||
if not os.path.exists(self.hwparampath):
|
||||
os.mkdir(self.hwparampath)
|
||||
if not os.path.exists(self.config.hwparam_path):
|
||||
os.mkdir(self.config.hwparam_path)
|
||||
open(os.path.join(path, self.paramfile), "w").write(json.dumps(self.paramsetting))
|
||||
else:
|
||||
self.paramsetting = {}
|
||||
|
@ -43,6 +44,6 @@ class hwparam:
|
|||
|
||||
def write_json(self):
|
||||
if self.paramsetting is not None:
|
||||
if not os.path.exists(self.hwparampath):
|
||||
os.mkdir(self.hwparampath)
|
||||
open(os.path.join(self.hwparampath, self.paramfile), "w").write(json.dumps(self.paramsetting))
|
||||
if not os.path.exists(self.config.hwparam_path):
|
||||
os.mkdir(self.config.hwparam_path)
|
||||
open(os.path.join(self.config.hwparam_path, self.paramfile), "w").write(json.dumps(self.paramsetting))
|
||||
|
|
Binary file not shown.
|
@ -67,12 +67,12 @@ class Mtk_Config(metaclass=LogBase):
|
|||
self.chipconfig = chipconfig()
|
||||
self.gpt_settings = None
|
||||
self.hwparam = None
|
||||
self.hwparam_path = "logs"
|
||||
self.hwparam_path = "."
|
||||
self.sram = None
|
||||
self.dram = None
|
||||
self.otp = None
|
||||
if loglevel == logging.DEBUG:
|
||||
logfilename = os.path.join("logs", "log.txt")
|
||||
logfilename = os.path.join(self.hwparam_path, "log.txt")
|
||||
fh = logging.FileHandler(logfilename)
|
||||
self.__logger.addHandler(fh)
|
||||
self.__logger.setLevel(logging.DEBUG)
|
||||
|
@ -113,7 +113,7 @@ class Mtk_Config(metaclass=LogBase):
|
|||
self.hwparam.writesetting("hwcode", hex(hwcode))
|
||||
|
||||
def set_meid(self, meid):
|
||||
self.hwparam = hwparam(meid, self.hwparam_path)
|
||||
self.hwparam = hwparam(self, meid, self.hwparam_path)
|
||||
self.meid = meid
|
||||
self.hwparam.writesetting("meid", hexlify(meid).decode('utf-8'))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[build-system]
|
||||
requires = [
|
||||
"setuptools>=42",
|
||||
"setuptools>=61",
|
||||
"wheel",
|
||||
]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
@ -13,7 +13,7 @@ maintainers = [
|
|||
]
|
||||
readme = "README.md"
|
||||
license = {file = "LICENSE"}
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
requires-python = ">= 3.8"
|
||||
dependencies = [
|
||||
"pyusb",
|
||||
|
@ -40,12 +40,30 @@ Issues = "https://github.com/bkerler/mtkclient/issues"
|
|||
|
||||
[project.scripts]
|
||||
mtk = "mtk:main"
|
||||
stage2 = "stage2:main"
|
||||
stage2 = "mtkclient.Tools.stage2:main"
|
||||
da_parser = "mtkclient.Tools.da_parser:main"
|
||||
brom_to_offs = "mtkclient.Tools.brom_to_offs:main"
|
||||
|
||||
[project.gui-scripts]
|
||||
mtk_gui = "mtk_gui:main"
|
||||
mtk_gui = "mtkclient.mtk_gui:main"
|
||||
|
||||
[tool.setuptools]
|
||||
# See also the MANIFEST.in file.
|
||||
packages = [
|
||||
"mtkclient.config",
|
||||
"mtkclient.Library",
|
||||
"mtkclient.Library.Connection",
|
||||
"mtkclient.Library.DA",
|
||||
"mtkclient.Library.DA.legacy",
|
||||
"mtkclient.Library.DA.legacy.extension",
|
||||
"mtkclient.Library.DA.xflash",
|
||||
"mtkclient.Library.DA.xflash.extension",
|
||||
"mtkclient.Library.DA.xml",
|
||||
"mtkclient.Library.DA.xml.extension",
|
||||
"mtkclient.Library.Exploit",
|
||||
"mtkclient.Library.Filesystem",
|
||||
"mtkclient.Library.Hardware",
|
||||
"mtkclient.Tools",
|
||||
]
|
||||
# We want to install all the files in the package directories...
|
||||
include-package-data = true
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
wheel >= 0.37.1
|
||||
pyusb >= 1.2.1
|
||||
pycryptodome >= 3.15.0
|
||||
wheel
|
||||
setuptools
|
||||
pyusb
|
||||
pycryptodome
|
||||
pycryptodomex
|
||||
colorama >= 0.4.4
|
||||
shiboken6 >= 6.4.0.1
|
||||
pyside6 >= 6.4.0.1
|
||||
mock >= 4.0.3
|
||||
pyserial >= 3.5
|
||||
colorama
|
||||
shiboken6
|
||||
pyside6
|
||||
mock
|
||||
pyserial
|
||||
flake8
|
||||
keystone-engine
|
||||
capstone
|
||||
unicorn
|
||||
fusepy
|
||||
|
||||
|
|
BIN
vbmeta.img.empty
BIN
vbmeta.img.empty
Binary file not shown.
Loading…
Reference in a new issue