Skip to content

Commit

Permalink
Merge pull request #1215 from shmu1i/main
Browse files Browse the repository at this point in the history
New argument 'multi'
  • Loading branch information
bkerler authored Sep 19, 2024
2 parents 2a8131d + c33522b commit 4a827df
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion mtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"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)'
}


Expand All @@ -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")
Expand Down
20 changes: 20 additions & 0 deletions mtkclient/Library/mtk_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,26 @@ def run(self, parser):
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()
Expand Down

0 comments on commit 4a827df

Please sign in to comment.