diff --git a/Makefile b/Makefile index 910aa62f6..64dbea4eb 100644 --- a/Makefile +++ b/Makefile @@ -145,12 +145,12 @@ style: # Make sure astyle is installed @which astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 ) # Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile - find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \ + find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \ -exec perl -pi -e 's/[ \t]+$$//' {} \; \ -exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \ -exec sh -c "echo >> {}" \; # Apply astyle on *.c, *.h, *.cpp - find . \( -name "*.[ch]" -or -name "*.cpp" \) -exec astyle --formatted --mode=c --suffix=none \ + find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) \) -exec astyle --formatted --mode=c --suffix=none \ --indent=spaces=4 --indent-switches \ --keep-one-line-blocks --max-instatement-indent=60 \ --style=google --pad-oper --unpad-paren --pad-header \ diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index 8f21882be..d211b543b 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -625,7 +625,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) { } // Incoming anti-collision frame - if (receivedCmd_len >= 2 && receivedCmd_len <= 6 && receivedCmd[1] == 0x50) { + // receivedCmd[1] indicates number of byte and bit collision, supports only for bit collision is zero + if (receivedCmd_len >= 3 && receivedCmd_len <= 6 && (receivedCmd[1] & 0x0f) == 0) { // we can process only full-byte frame anti-collision procedure if (memcmp(&receivedCmd[2], responses[uid_index].response, receivedCmd_len - 2) == 0) { // response missing part of UID via relative array index @@ -1036,8 +1037,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) { ); } cardAUTHKEY = AUTHKEYNONE; // not authenticated - EmSend4bit(mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA)); cardSTATE_TO_IDLE(); + // Really tags not respond NACK on invalid authentication + LogTrace(uart->output, uart->len, uart->startTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->endTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->parity, true); break; } diff --git a/client/fpga_compress.c b/client/fpga_compress.c index 7cd4652e1..a030afe81 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -375,7 +375,7 @@ static void print_version_info_preamble(FILE *outfile, int num_infiles) { fprintf(outfile, "\n"); fprintf(outfile, "\n"); fprintf(outfile, "const int fpga_bitstream_num = %d;\n", num_infiles); - fprintf(outfile, "const char* const fpga_version_information[%d] = {\n", num_infiles); + fprintf(outfile, "const char *const fpga_version_information[%d] = {\n", num_infiles); } static int generate_fpga_version_info(FILE *infile[], char *infile_names[], int num_infiles, FILE *outfile) { @@ -386,7 +386,7 @@ static int generate_fpga_version_info(FILE *infile[], char *infile_names[], int for (int i = 0; i < num_infiles; i++) { FpgaGatherVersion(infile[i], infile_names[i], version_string, sizeof(version_string)); - fprintf(outfile, "\t\" %s\"", version_string); + fprintf(outfile, " \" %s\"", version_string); if (i != num_infiles - 1) { fprintf(outfile, ","); } diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index eacdc4b62..db9a9084f 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -166,3 +166,4 @@ Or, by specifying the COM port manually: client/proxmark3 /dev/ttySX ``` +Note that it may take a quite long time for a freshly plugged Proxmark3 to be visible on a WSL /dev/ttySX port. diff --git a/flash-all.sh b/flash-all.sh index 27e1fb526..d4fcdc975 100755 --- a/flash-all.sh +++ b/flash-all.sh @@ -1,4 +1,5 @@ #!/bin/bash -cd $(dirname "$0") +PM3PATH=$(dirname "$0") +cd "$PM3PATH" || exit 1 . proxmark3.sh diff --git a/flash-bootrom.sh b/flash-bootrom.sh index 27e1fb526..d4fcdc975 100755 --- a/flash-bootrom.sh +++ b/flash-bootrom.sh @@ -1,4 +1,5 @@ #!/bin/bash -cd $(dirname "$0") +PM3PATH=$(dirname "$0") +cd "$PM3PATH" || exit 1 . proxmark3.sh diff --git a/flash-fullimage.sh b/flash-fullimage.sh index 27e1fb526..d4fcdc975 100755 --- a/flash-fullimage.sh +++ b/flash-fullimage.sh @@ -1,4 +1,5 @@ #!/bin/bash -cd $(dirname "$0") +PM3PATH=$(dirname "$0") +cd "$PM3PATH" || exit 1 . proxmark3.sh diff --git a/proxmark3.sh b/proxmark3.sh index 39eb80779..4cd6d76bc 100755 --- a/proxmark3.sh +++ b/proxmark3.sh @@ -3,28 +3,31 @@ FULLIMAGE="armsrc/obj/fullimage.elf" BOOTIMAGE="bootrom/obj/bootrom.elf" -cd $(dirname "$0") +PM3PATH=$(dirname "$0") +cd "$PM3PATH" || exit 1 function wait4proxmark_Linux { echo >&2 "Waiting for Proxmark to appear..." - while [ ! -c /dev/ttyACM? -a ! -c /dev/pm3-? ]; do + while true; do + PM3=$(find /dev/pm3-* /dev/ttyACM* 2>/dev/null | head -1) + if [[ $PM3 != "" ]]; then + break + fi sleep .1 done - local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1` - echo $PM3 + 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) + PM3=$(find /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 + echo "$PM3" } function wait4proxmark_Windows { @@ -37,7 +40,7 @@ function wait4proxmark_Windows { fi sleep .1 done - echo $PM3 + echo "$PM3" } function wait4proxmark_WSL { @@ -51,23 +54,23 @@ function wait4proxmark_WSL { fi sleep .1 done - echo $PM3 + if [ -e "$PM3" ] && [ ! -w "$PM3" ]; then + echo "We need to give current user read/write access to $PM3" + sudo chmod 666 "$PM3" + fi + echo "$PM3" } SCRIPT=$(basename -- "$0") if [ "$SCRIPT" = "proxmark3.sh" ]; then - CMD=client/proxmark3 + CMD() { client/proxmark3 "$@"; } elif [ "$SCRIPT" = "flash-all.sh" ]; then - CMD=client/flasher - ARG1="-b $BOOTIMAGE" - ARG2="$FULLIMAGE" + CMD() { client/flasher "$1" -b "$BOOTIMAGE" "$FULLIMAGE"; } elif [ "$SCRIPT" = "flash-fullimage.sh" ]; then - CMD=client/flasher - ARG2="$FULLIMAGE" + CMD() { client/flasher "$1" "$FULLIMAGE"; } elif [ "$SCRIPT" = "flash-bootrom.sh" ]; then - CMD=client/flasher - ARG1="-b $BOOTIMAGE" + CMD() { client/flasher "$1" -b "$BOOTIMAGE"; } else echo "Script ran under unknown name, abort: $SCRIPT" exit 1 @@ -92,6 +95,5 @@ if [ "$PORT" = "" ]; then exit 1 fi -#echo Running "$CMD" "$PORT" $ARG1 $ARG2 "$@" -"$CMD" "$PORT" $ARG1 $ARG2 "$@" +CMD "$PORT" "$@" exit $? diff --git a/uart/uart_posix.c b/uart/uart_posix.c index 22cc75207..ea535fd73 100644 --- a/uart/uart_posix.c +++ b/uart/uart_posix.c @@ -238,7 +238,8 @@ void uart_close(const serial_port sp) { // Does the system allows us to place a lock on this file descriptor int err = fcntl(spu->fd, F_SETLK, &fl); if (err == -1) { - printf("[!] UART error while closing port\n"); + //silent error message as it can be called from uart_open failing modes, e.g. when waiting for port to appear + //printf("[!] UART error while closing port\n"); } close(spu->fd); free(sp);