From 30cd8da27b54a88cfa60bbeb38c787396e878e4b Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:28:35 -0400 Subject: [PATCH 1/7] Update mtk.py Add argument 'multi' to run multiple commands without a script --- mtk.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mtk.py b/mtk.py index 3803691e..8451c2c5 100755 --- a/mtk.py +++ b/mtk.py @@ -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 comma-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 comma-separated list (enclose list in quotes)') + parser_multi.add_argument('commands', help='Comma-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") From 2fc9aa36c31fbf4b8694a077da57c46726eb51d6 Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:29:43 -0400 Subject: [PATCH 2/7] Update mtk_main.py Add argument 'multi' to run multiple commands without a script --- mtkclient/Library/mtk_main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mtkclient/Library/mtk_main.py b/mtkclient/Library/mtk_main.py index 0cab23c9..0602641f 100755 --- a/mtkclient/Library/mtk_main.py +++ b/mtkclient/Library/mtk_main.py @@ -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() From 485e1e911d50ccca0d4a778e09cd5a4f389779ea Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:35:33 -0400 Subject: [PATCH 3/7] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d341f3ec..ce7d425f 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ python mtk.py --stock ### Run multiple commands ```bash python mtk.py script run.example +or python mtk.py multi "cmd1,cmd2" to run multiple commands without a script ``` See the file "[run.example](https://github.com/bkerler/mtkclient/blob/main/run.example)" on how to structure the script file From 2e70acc7052b4da83305ad15588bb6415dcc70f9 Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:37:21 -0400 Subject: [PATCH 4/7] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ce7d425f..2d3d4e58 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,10 @@ python mtk.py --stock ### Run multiple commands ```bash python mtk.py script run.example -or python mtk.py multi "cmd1,cmd2" to run multiple commands without a script +``` +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 From 798696990aec4cd157883213aa707621f83f6a87 Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:31:14 -0400 Subject: [PATCH 5/7] Update mtk_main.py --- mtkclient/Library/mtk_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtkclient/Library/mtk_main.py b/mtkclient/Library/mtk_main.py index 0602641f..8d681fae 100755 --- a/mtkclient/Library/mtk_main.py +++ b/mtkclient/Library/mtk_main.py @@ -415,7 +415,7 @@ def run(self, parser): self.close() elif cmd == "multi": # Split the commands in the multi argument - commands = self.args.commands.split(',') + commands = self.args.commands.split(';') # DA / Flash commands start here try: preloader = self.args.preloader From 236db70e9f415d1b16dba0289fa5541911aebb58 Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:32:34 -0400 Subject: [PATCH 6/7] Update mtk.py --- mtk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mtk.py b/mtk.py index 8451c2c5..0946d5c6 100755 --- a/mtk.py +++ b/mtk.py @@ -38,7 +38,7 @@ "plstage": "Run stage2 payload via preloader mode (send_da)", "da": "Run da xflash/legacy special commands", "script": "Run multiple commands using text script", - "multi": 'Run multiple commands using a comma-separated list (enclose list in quotes)' + "multi": 'Run multiple commands using a semicolon-separated list (enclose list in quotes)' } @@ -53,8 +53,8 @@ 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 comma-separated list (enclose list in quotes)') - parser_multi.add_argument('commands', help='Comma-separated list of commands to run') + 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") From c33522ba5d47214e7c760cab85c4b2014b6e5ced Mon Sep 17 00:00:00 2001 From: shmu1i <159483565+shmu1i@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:33:12 -0400 Subject: [PATCH 7/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d3d4e58..ecc5c2e5 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ python mtk.py script run.example ``` or ``` -python mtk.py multi "cmd1,cmd2" +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