diff --git a/client/proxmark3.c b/client/proxmark3.c index 1c3693ea2..5cf045170 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -62,6 +62,11 @@ main_loop(char *script_cmds_file, char *script_cmd, bool pm3_present) { char *cmd = NULL; bool execCommand = (script_cmd != NULL); + uint16_t script_cmd_len = 0; + if (execCommand) { + script_cmd_len = strlen(script_cmd); + strcreplace(script_cmd, script_cmd_len, ';', '\0'); + } bool stdinOnPipe = !isatty(STDIN_FILENO); FILE *sf = NULL; char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest @@ -134,11 +139,13 @@ main_loop(char *script_cmds_file, char *script_cmd, bool pm3_present) { } else { // If there is a script command if (execCommand) { - if ((cmd = strmcopy(script_cmd)) != NULL) PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd); - - execCommand = false; + uint16_t len = strlen(script_cmd) + 1; + script_cmd += len; + if (script_cmd_len == len - 1) + execCommand = false; + script_cmd_len -= len; } else { // exit after exec command if (script_cmd) @@ -255,7 +262,7 @@ static void show_help(bool showFullHelp, char *exec_name) { PrintAndLogEx(NORMAL, " -b/--baud serial port speed"); PrintAndLogEx(NORMAL, " -w/--wait 20sec waiting the serial port to appear in the OS"); PrintAndLogEx(NORMAL, " -f/--flush output will be flushed after every print"); - PrintAndLogEx(NORMAL, " -c/--command execute one proxmark3 command."); + PrintAndLogEx(NORMAL, " -c/--command execute one proxmark3 command (or several separated by ';')."); PrintAndLogEx(NORMAL, " -l/--lua execute lua script."); PrintAndLogEx(NORMAL, " -s/--script-file script file with one proxmark3 command per line"); PrintAndLogEx(NORMAL, "\nsamples:"); diff --git a/flash-all.sh b/flash-all.sh new file mode 100755 index 000000000..27e1fb526 --- /dev/null +++ b/flash-all.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd $(dirname "$0") +. proxmark3.sh diff --git a/flash-bootrom.sh b/flash-bootrom.sh new file mode 100755 index 000000000..27e1fb526 --- /dev/null +++ b/flash-bootrom.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd $(dirname "$0") +. proxmark3.sh diff --git a/flash-fullimage.sh b/flash-fullimage.sh new file mode 100755 index 000000000..27e1fb526 --- /dev/null +++ b/flash-fullimage.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd $(dirname "$0") +. proxmark3.sh diff --git a/proxmark3.sh b/proxmark3.sh index 4a7a004d5..0d7b36657 100755 --- a/proxmark3.sh +++ b/proxmark3.sh @@ -1,5 +1,10 @@ #!/bin/bash +FULLIMAGE="armsrc/obj/fullimage.elf" +BOOTIMAGE="bootrom/obj/bootrom.elf" + +cd $(dirname "$0") + function wait4proxmark_Linux { echo >&2 "Waiting for Proxmark to appear..." while [ ! -c /dev/ttyACM? -a ! -c /dev/pm3-? ]; do @@ -23,10 +28,38 @@ function wait4proxmark_macOS { echo $PM3 } -# start proxmark with first detected interface +SCRIPT=$(basename -- "$0") -if [[ $(uname | awk '{print toupper($0)}') == "LINUX" ]]; then - client/proxmark3 $(wait4proxmark_Linux) "$@" -elif [[ $(uname | awk '{print toupper($0)}') == "DARWIN" ]]; then - client/proxmark3 $(wait4proxmark_macOS) "$@" +if [ "$SCRIPT" = "proxmark3.sh" ]; then + CMD=client/proxmark3 +elif [ "$SCRIPT" = "flash-all.sh" ]; then + CMD=client/flasher + ARG1="-b $BOOTIMAGE" + ARG2="$FULLIMAGE" +elif [ "$SCRIPT" = "flash-fullimage.sh" ]; then + CMD=client/flasher + ARG2="$FULLIMAGE" +elif [ "$SCRIPT" = "flash-bootrom.sh" ]; then + CMD=client/flasher + ARG1="-b $BOOTIMAGE" +else + echo "Script ran under unknown name, abort: $SCRIPT" + exit 1 fi +HOSTOS=$(uname | awk '{print toupper($0)}') +if [ "$HOSTOS" = "LINUX" ]; then + PORT=$(wait4proxmark_Linux) +elif [ "$HOSTOS" = "DARWIN" ]; then + PORT=$(wait4proxmark_macOS) +else + echo "Host OS not recognized, abort: $HOSTOS" + exit 1 +fi +if [ "$PORT" = "" ]; then + echo "No port, abort" + exit 1 +fi + +echo Running "$CMD" "$PORT" $ARG1 $ARG2 "$@" +"$CMD" "$PORT" $ARG1 $ARG2 "$@" +exit $? diff --git a/tools/mkversion.pl b/tools/mkversion.pl index ed5cea206..715b8081c 100644 --- a/tools/mkversion.pl +++ b/tools/mkversion.pl @@ -14,7 +14,7 @@ $ENV{'LC_ALL'} = "C"; $ENV{'LANG'} = "C"; # if you are making your own fork, change this line to reflect your fork-name -my $fullgitinfo = 'iceman'; +my $fullgitinfo = 'RRG'; my $ctime; # GIT status 0 = dirty, 1 = clean , 2 = undecided my $clean = 2; @@ -32,7 +32,8 @@ my $commandGIT = "env which git"; if ( defined($commandGIT) ) { - my $githistory = `git fetch --all`; + # this goes on Internet and cause major slowdowns on poor connections or intranets, let's comment it + #my $githistory = `git fetch --all`; # now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case my $gitversion = `git describe --dirty --always`; my $gitbranch = `git rev-parse --abbrev-ref HEAD`; diff --git a/update.sh b/update.sh deleted file mode 100755 index fe5f0dd95..000000000 --- a/update.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -function wait4proxmark_Linux { - echo >&2 "Waiting for Proxmark to appear..." - while [ ! -c /dev/ttyACM? -a ! -L /dev/pm3-? ]; do - sleep .1 - done - local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1` - echo >&2 -e "Found proxmark on ${PM3}\n" - echo $PM3 -} - -function wait4proxmark_macOS { - echo >&2 "Waiting for Proxmark to appear..." - while true; do - PM3=$(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1) - if [[ $PM3 != "" ]]; then - #echo >&2 -e "Found proxmark on $(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)\n" - break - fi - sleep .1 - done - echo $PM3 -} - -# Detect OS and flash bootroom & system image - -if [[ $(uname | awk '{print toupper($0)}') == "LINUX" ]]; then - client/flasher $(wait4proxmark_Linux) -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf -elif [[ $(uname | awk '{print toupper($0)}') == "DARWIN" ]]; then - client/flasher $(wait4proxmark_macOS) -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf -fi