mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
Merge branch 'master' into experimental_varlen
* master: fix segfault rework shell scripts for easy client or flasher Stop poking Internet when compiling doc multiple commands with -c Add support for: proxmark3 -c "hw ping;hw version;hw ping" update.sh flash boot only if option -b
This commit is contained in:
commit
fbec3f3125
7 changed files with 64 additions and 43 deletions
|
@ -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 <command> execute one proxmark3 command.");
|
||||
PrintAndLogEx(NORMAL, " -c/--command <command> execute one proxmark3 command (or several separated by ';').");
|
||||
PrintAndLogEx(NORMAL, " -l/--lua <lua script file> execute lua script.");
|
||||
PrintAndLogEx(NORMAL, " -s/--script-file <cmd_script_file> script file with one proxmark3 command per line");
|
||||
PrintAndLogEx(NORMAL, "\nsamples:");
|
||||
|
|
4
flash-all.sh
Executable file
4
flash-all.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd $(dirname "$0")
|
||||
. proxmark3.sh
|
4
flash-bootrom.sh
Executable file
4
flash-bootrom.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd $(dirname "$0")
|
||||
. proxmark3.sh
|
4
flash-fullimage.sh
Executable file
4
flash-fullimage.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd $(dirname "$0")
|
||||
. proxmark3.sh
|
43
proxmark3.sh
43
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 $?
|
||||
|
|
|
@ -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`;
|
||||
|
|
32
update.sh
32
update.sh
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue