mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Add -- to proxmark3 client to pass args to scripts
Examples: pm3 -y myscript.py -- -h pm3 -y myscript.py -- --input foo --output bar This enables usage in scripts shebang, e.g. #!/usr/bin/env -S uv run --with pycryptodome pm3 -y
This commit is contained in:
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Added `--` arg separator to client to pass following args to scripts (@doegox)
|
||||
- Fixed ISO14443-4 type B NDEF workflow + parsing (@team-orangeBlue)
|
||||
- Added Snapmaker U1 filament spool KDF in `hf mf keygen` (@Foxushka)
|
||||
- Replaced `hf mf bambukeys` with `hf mf keygen` with multiple KDFs support (@Foxushka)
|
||||
|
||||
+30
-5
@@ -716,9 +716,9 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nsyntax: %s [-h|-t|-m|--fulltext]", exec_name);
|
||||
#ifdef HAVE_PYTHON
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-y <python_script_file>]|[-s <cmd_script_file>] [-i] [-d <0|1|2>]", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-d <0|1|2>] [--incognito] [--ncpu <num_cores>] [-c \"<command>\"]|[-l <lua_script_file>]|[-y <python_script_file>]|[-s <cmd_script_file>] [-i] [-- <arg0> <arg1>...]", exec_name);
|
||||
#else // HAVE_PYTHON
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-s <cmd_script_file>] [-i] [-d <0|1|2>]", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-d <0|1|2>] [--incognito] [--ncpu <num_cores>] [-c \"<command>\"]|[-l <lua_script_file>]|[-s <cmd_script_file>] [-i] [-- <arg0> <arg1>...]", exec_name);
|
||||
#endif // HAVE_PYTHON
|
||||
PrintAndLogEx(NORMAL, " %s [-p] <port> --flash [--unlock-bootloader] [--image <imagefile>]+ [-w] [-f] [-d <0|1|2>]", exec_name);
|
||||
|
||||
@@ -736,7 +736,9 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
||||
PrintAndLogEx(NORMAL, " --fulltext dump all interactive command's help at once");
|
||||
PrintAndLogEx(NORMAL, " -m/--markdown dump all interactive command list at once in markdown syntax");
|
||||
PrintAndLogEx(NORMAL, " -b/--baud serial port speed (only needed for physical UART, not for USB-CDC or BT)");
|
||||
PrintAndLogEx(NORMAL, " -c/--command <command> execute one Proxmark3 command (or several separated by ';').");
|
||||
PrintAndLogEx(NORMAL, " --incognito do not use history, prefs file nor log files");
|
||||
PrintAndLogEx(NORMAL, " --ncpu <num_cores> override number of CPU cores");
|
||||
PrintAndLogEx(NORMAL, " -c/--command \"<command>\" execute one Proxmark3 command (or several separated by ';').");
|
||||
PrintAndLogEx(NORMAL, " -l/--lua <lua_script_file> execute Lua script.");
|
||||
#ifdef HAVE_PYTHON
|
||||
// Technically, --lua and --py are identical and interexchangeable
|
||||
@@ -744,8 +746,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
||||
#endif // HAVE_PYTHON
|
||||
PrintAndLogEx(NORMAL, " -s/--script-file <cmd_script_file> script file with one Proxmark3 command per line");
|
||||
PrintAndLogEx(NORMAL, " -i/--interactive enter interactive mode after executing the script or the command");
|
||||
PrintAndLogEx(NORMAL, " --incognito do not use history, prefs file nor log files");
|
||||
PrintAndLogEx(NORMAL, " --ncpu <num_cores> override number of CPU cores");
|
||||
PrintAndLogEx(NORMAL, " -- <arg0> <arg1>... all args following -- are passed to the client command line");
|
||||
PrintAndLogEx(NORMAL, "\nOptions in flasher mode:");
|
||||
PrintAndLogEx(NORMAL, " --flash flash Proxmark3, requires at least one --image");
|
||||
PrintAndLogEx(NORMAL, " --reboot-to-bootloader reboot Proxmark3 into bootloader mode");
|
||||
@@ -1230,6 +1231,30 @@ int main(int argc, char *argv[]) {
|
||||
continue;
|
||||
}
|
||||
#endif // HAVE_PYTHON
|
||||
// append all following args to script_cmd
|
||||
if (strcmp(argv[i], "--") == 0) {
|
||||
bool script_cmd_on_heap = false;
|
||||
for (++i; i < argc; i++) {
|
||||
int extra_len = strlen(argv[i]) + 1;
|
||||
int old_len = script_cmd ? strlen(script_cmd) : 0;
|
||||
char *new_cmd = (char *) calloc(old_len + extra_len + 1, sizeof(uint8_t));
|
||||
if (new_cmd == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return 1;
|
||||
}
|
||||
if (script_cmd) {
|
||||
strcpy(new_cmd, script_cmd);
|
||||
strcat(new_cmd, " ");
|
||||
if (script_cmd_on_heap) {
|
||||
free(script_cmd);
|
||||
}
|
||||
}
|
||||
strcat(new_cmd, argv[i]);
|
||||
script_cmd = new_cmd;
|
||||
script_cmd_on_heap = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// go to interactive instead of quitting after a script/command
|
||||
if (strcmp(argv[i], "-i") == 0 || strcmp(argv[i], "--interactive") == 0) {
|
||||
stayInCommandLoop = true;
|
||||
|
||||
Reference in New Issue
Block a user