diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc518ca6..8db8ed79b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 5723c3905..d4291fdde 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -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] ] [-b] [-w] [-f] [-c ]|[-l ]|[-y ]|[-s ] [-i] [-d <0|1|2>]", exec_name); + PrintAndLogEx(NORMAL, " %s [[-p] ] [-b] [-w] [-f] [-d <0|1|2>] [--incognito] [--ncpu ] [-c \"\"]|[-l ]|[-y ]|[-s ] [-i] [-- ...]", exec_name); #else // HAVE_PYTHON - PrintAndLogEx(NORMAL, " %s [[-p] ] [-b] [-w] [-f] [-c ]|[-l ]|[-s ] [-i] [-d <0|1|2>]", exec_name); + PrintAndLogEx(NORMAL, " %s [[-p] ] [-b] [-w] [-f] [-d <0|1|2>] [--incognito] [--ncpu ] [-c \"\"]|[-l ]|[-s ] [-i] [-- ...]", exec_name); #endif // HAVE_PYTHON PrintAndLogEx(NORMAL, " %s [-p] --flash [--unlock-bootloader] [--image ]+ [-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 execute one Proxmark3 command (or several separated by ';')."); + PrintAndLogEx(NORMAL, " --incognito do not use history, prefs file nor log files"); + PrintAndLogEx(NORMAL, " --ncpu override number of CPU cores"); + PrintAndLogEx(NORMAL, " -c/--command \"\" execute one Proxmark3 command (or several separated by ';')."); PrintAndLogEx(NORMAL, " -l/--lua 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 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 override number of CPU cores"); + PrintAndLogEx(NORMAL, " -- ... 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; diff --git a/pm3 b/pm3 index 5122fe536..e7a22e56b 100755 --- a/pm3 +++ b/pm3 @@ -424,6 +424,9 @@ fi # priority to the help options for ARG; do + if [ "$ARG" == "--" ]; then + break + fi if [ "$ARG" == "-h" ] || [ "$ARG" == "--help" ]; then HELP exit 0