mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 11:14:56 -05:00
Compare commits
11 commits
8fff2aba85
...
8d36ea4ef8
Author | SHA1 | Date | |
---|---|---|---|
|
8d36ea4ef8 | ||
|
4a827df91e | ||
|
c33522ba5d | ||
|
236db70e9f | ||
|
798696990a | ||
|
4e95d315c5 | ||
|
2a8131d881 | ||
|
2e70acc705 | ||
|
485e1e911d | ||
|
2fc9aa36c3 | ||
|
30cd8da27b |
5 changed files with 38 additions and 6 deletions
|
@ -204,6 +204,10 @@ python mtk.py --stock
|
|||
```bash
|
||||
python mtk.py script run.example
|
||||
```
|
||||
or
|
||||
```
|
||||
python mtk.py multi "cmd1;cmd2"
|
||||
```
|
||||
See the file "[run.example](https://github.com/bkerler/mtkclient/blob/main/run.example)" on how to structure the script file
|
||||
|
||||
### Root the phone (Tested with android 9 - 12)
|
||||
|
|
7
mtk.py
7
mtk.py
|
@ -37,7 +37,8 @@ cmds = {
|
|||
"stage": "Run stage2 payload via boot rom mode (kamakiri)",
|
||||
"plstage": "Run stage2 payload via preloader mode (send_da)",
|
||||
"da": "Run da xflash/legacy special commands",
|
||||
"script": "Run multiple commands using text script"
|
||||
"script": "Run multiple commands using text script",
|
||||
"multi": 'Run multiple commands using a semicolon-separated list (enclose list in quotes)'
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +53,10 @@ def main():
|
|||
'gettargetconfig, peek, stage, plstage, da, script\n')
|
||||
|
||||
parser_script = subparsers.add_parser("script", help="Run text script")
|
||||
parser_multi = subparsers.add_parser("multi", help='Run multiple commands using a semicolon-separatedlist (enclose list in quotes)')
|
||||
parser_multi.add_argument('commands', help='semicolon-separated list of commands to run')
|
||||
|
||||
|
||||
parser_printgpt = subparsers.add_parser("printgpt", help="Print GPT Table information")
|
||||
parser_gpt = subparsers.add_parser("gpt", help="Save gpt table to given directory")
|
||||
parser_r = subparsers.add_parser("r", help="Read flash to filename")
|
||||
|
|
|
@ -8,6 +8,8 @@ import sys
|
|||
from binascii import hexlify
|
||||
from struct import pack, unpack
|
||||
|
||||
from Cryptodome.Util.number import long_to_bytes
|
||||
|
||||
from mtkclient.Library.Auth.sla import generate_da_sla_signature
|
||||
from mtkclient.Library.DA.xflash.xflash_flash_param import NandExtension
|
||||
from mtkclient.Library.DA.xflash.xflash_param import Cmd, ChecksumAlgorithm, FtSystemOSE, DataType
|
||||
|
@ -1142,7 +1144,7 @@ class DAXFlash(metaclass=LogBase):
|
|||
rsakey = None
|
||||
from mtkclient.Library.Auth.sla_keys import da_sla_keys
|
||||
for key in da_sla_keys:
|
||||
if da2.find(bytes.fromhex(key.n)) != -1:
|
||||
if da2.find(long_to_bytes(key.n)) != -1:
|
||||
rsakey = key
|
||||
break
|
||||
if rsakey is None:
|
||||
|
|
|
@ -7,6 +7,7 @@ from struct import pack, unpack
|
|||
from queue import Queue
|
||||
from threading import Thread
|
||||
|
||||
from Cryptodome.Util.number import long_to_bytes
|
||||
from Cryptodome.Cipher import PKCS1_OAEP
|
||||
from Cryptodome.Hash import SHA256
|
||||
from Cryptodome.PublicKey import RSA
|
||||
|
@ -624,7 +625,7 @@ class DAXML(metaclass=LogBase):
|
|||
from mtkclient.Library.Auth.sla_keys import da_sla_keys, SlaKey
|
||||
for key in da_sla_keys:
|
||||
if isinstance(key, SlaKey):
|
||||
if da2.find(bytes.fromhex(key.n)) != -1:
|
||||
if da2.find(long_to_bytes(key.n)) != -1:
|
||||
rsakey = key
|
||||
if rsakey is None:
|
||||
print("No valid sla key found, using dummy auth ....")
|
||||
|
|
|
@ -42,7 +42,7 @@ class ArgHandler(metaclass=LogBase):
|
|||
config.pid = getint(args.pid)
|
||||
except AttributeError:
|
||||
pass
|
||||
config.stock = True
|
||||
config.stock = False
|
||||
try:
|
||||
if args.stock is not None:
|
||||
config.stock = args.stock
|
||||
|
@ -413,6 +413,26 @@ class Main(metaclass=LogBase):
|
|||
sys.stderr.flush()
|
||||
else:
|
||||
self.close()
|
||||
elif cmd == "multi":
|
||||
# Split the commands in the multi argument
|
||||
commands = self.args.commands.split(';')
|
||||
# DA / Flash commands start here
|
||||
try:
|
||||
preloader = self.args.preloader
|
||||
except Exception:
|
||||
preloader = None
|
||||
da_handler = DaHandler(mtk, loglevel)
|
||||
mtk = da_handler.configure_da(mtk, preloader)
|
||||
if mtk is not None:
|
||||
for rcmd in commands:
|
||||
self.args = parser.parse_args(rcmd.split(" "))
|
||||
ArgHandler(self.args, config)
|
||||
cmd = self.args.cmd
|
||||
da_handler.handle_da_cmds(mtk, cmd, self.args)
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
else:
|
||||
self.close()
|
||||
elif cmd == "dumpbrom":
|
||||
if mtk.preloader.init():
|
||||
rmtk = mtk.crasher()
|
||||
|
@ -662,8 +682,8 @@ class Main(metaclass=LogBase):
|
|||
mtk = da_handler.configure_da(mtk, preloader)
|
||||
if mtk is not None:
|
||||
da_handler.handle_da_cmds(mtk, cmd, self.args)
|
||||
else:
|
||||
self.close()
|
||||
mtk.port.close()
|
||||
self.close()
|
||||
|
||||
def cmd_log(self, mtk, filename):
|
||||
if mtk.preloader.init():
|
||||
|
|
Loading…
Reference in a new issue