From 3eee351f4fc5643bdc42338e2ae3f4664553136b Mon Sep 17 00:00:00 2001
From: Bjoern Kerler
Date: Tue, 28 Apr 2020 18:16:52 +0200
Subject: [PATCH 001/527] Return PM3_SUCCESS if iso df names not supported
---
client/src/cmdhfmfdes.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index 65b02b5f8..d8185e96b 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -1268,6 +1268,7 @@ static int handler_desfire_appids(uint8_t *dest, uint8_t *app_ids_len) {
// --- GET DF NAMES
static int handler_desfire_dfnames(dfname_t *dest, uint8_t *dfname_count) {
+ *dfname_count=0;
if (g_debugMode > 1) {
if (dest == NULL) PrintAndLogEx(ERR, "DEST=NULL");
if (dfname_count == NULL) PrintAndLogEx(ERR, "DFNAME_COUNT=NULL");
@@ -1277,8 +1278,11 @@ static int handler_desfire_dfnames(dfname_t *dest, uint8_t *dfname_count) {
int recv_len = 0;
uint16_t sw = 0;
int res = send_desfire_cmd(&apdu, true, (uint8_t *)dest, &recv_len, &sw, sizeof(dfname_t), true);
- if (res != PM3_SUCCESS)
+ if (res != PM3_SUCCESS){
+ if (sw == status(MFDES_E_ILLEGAL_COMMAND_CODE)) return PM3_SUCCESS;
return res;
+ }
+
if (sw != status(MFDES_S_OPERATION_OK))
return PM3_ESOFT;
*dfname_count = recv_len;
From a739d333982e190566906b61f89364ef8e3ba578 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 15 May 2020 13:07:27 +0200
Subject: [PATCH 002/527] Add mf_nonce_brute from
https://github.com/iceman1001/mf_nonce_brute and merge to pm3 Makefile
---
.gitignore | 2 +-
Makefile.host | 4 +-
tools/Makefile | 4 -
tools/mf_nonce_brute/Makefile | 20 ++
tools/mf_nonce_brute/README.md | 132 +++++++++
tools/mf_nonce_brute/iso14443crc.c | 46 +++
tools/mf_nonce_brute/iso14443crc.h | 26 ++
tools/mf_nonce_brute/mf_nonce_brute.c | 395 ++++++++++++++++++++++++++
tools/mf_nonce_brute/protocol.h | 20 ++
tools/mf_nonce_brute/sleep.c | 28 ++
tools/mf_nonce_brute/sleep.h | 27 ++
11 files changed, 698 insertions(+), 6 deletions(-)
create mode 100644 tools/mf_nonce_brute/Makefile
create mode 100644 tools/mf_nonce_brute/README.md
create mode 100644 tools/mf_nonce_brute/iso14443crc.c
create mode 100644 tools/mf_nonce_brute/iso14443crc.h
create mode 100644 tools/mf_nonce_brute/mf_nonce_brute.c
create mode 100644 tools/mf_nonce_brute/protocol.h
create mode 100644 tools/mf_nonce_brute/sleep.c
create mode 100644 tools/mf_nonce_brute/sleep.h
diff --git a/.gitignore b/.gitignore
index fd8fe070c..d28933d82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -87,7 +87,7 @@ client/dumps/*
*.ice
*.new
armsrc/TEMP EMV/*
-tools/mf_nonce_brute/*
+tools/mf_nonce_brute/mf_nonce_brute
tools/andrew/*
tools/jtag_openocd/openocd_configuration
ppls patches/*
diff --git a/Makefile.host b/Makefile.host
index c95f4bb4f..07b8c2199 100644
--- a/Makefile.host
+++ b/Makefile.host
@@ -17,6 +17,8 @@ endif
CFLAGS ?= $(DEFCFLAGS)
CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
+LDFLAGS += $(MYLDFLAGS)
+LDLIBS += $(MYLDLIBS)
vpath %.c $(MYSRCPATHS)
@@ -66,7 +68,7 @@ $(BINDIR)/$(LIB_A): $(MYOBJS)
$(BINDIR)/% : $(OBJDIR)/%.o $(MYOBJS) $(MYLIBS)
$(info [=] LD $(notdir $@))
- $(Q)$(LD) $(LDFLAGS) $(MYOBJS) $< -o $@ $(MYLIBS)
+ $(Q)$(LD) $(LDFLAGS) $(MYOBJS) $< -o $@ $(MYLIBS) $(MYLDLIBS)
$(OBJDIR)/%.o : %.c | $(OBJDIR)
$(info [-] CC $<)
diff --git a/tools/Makefile b/tools/Makefile
index 5f2355f20..df6a0682f 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -11,10 +11,6 @@ get_crapto1:
$(WGET) http://crapto1.netgarage.org/crapto1-v3.3.tar.xz
$(TAR) Jxvf crapto1-v3.3.tar.xz -C crapto1-v3.3
-get_nonce_bf:
-# $(GIT) https://github.com/J-Run/mf_key_brute.git mf_key_brute
- $(GIT) https://github.com/iceman1001/mf_nonce_brute mf_nonce_brute
-
get_xorsearch:
$(MKDIR) xorsearch
$(WGET) https://didierstevens.com/files/software/XORSearch_V1_11_2.zip
diff --git a/tools/mf_nonce_brute/Makefile b/tools/mf_nonce_brute/Makefile
new file mode 100644
index 000000000..7672c89a4
--- /dev/null
+++ b/tools/mf_nonce_brute/Makefile
@@ -0,0 +1,20 @@
+MYSRCPATHS = ../../common ../../common/crapto1
+MYSRCS = crypto1.c crapto1.c bucketsort.c iso14443crc.c sleep.c
+MYINCLUDES = -I../../include -I../../common
+MYCFLAGS =
+MYDEFS =
+MYLDLIBS = -lpthread
+
+BINS = mf_nonce_brute
+INSTALLTOOLS = $(BINS)
+
+include ../../Makefile.host
+
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
+
+mf_nonce_brute : $(OBJDIR)/mf_nonce_brute.o $(MYOBJS)
diff --git a/tools/mf_nonce_brute/README.md b/tools/mf_nonce_brute/README.md
new file mode 100644
index 000000000..c2e5f3e6f
--- /dev/null
+++ b/tools/mf_nonce_brute/README.md
@@ -0,0 +1,132 @@
+mf_nonce_brute
+==============
+
+Nested authentificated sector key recovery tool
+-----------------------------------------------
+
+Compatible tags:
+* Mifare Classic 1k (4k)
+* Mifare Plus in SL1 mode
+
+To recover keys to nested authentificated sectors you need a reader-card communication log. To get it use
+hardware tools that able to sniff communication (for example Proxmark3 or HydraNFC).
+
+This enhanced version:
+First 2 bytes should be bruteforced in phase 2 with mf_key_brute tool that interacts with a card.
+
+Sample trace:
+```
+ 93 70 fd ac f6 d8 7f 21 4f // select card with UID fdacf6d8
+TAG 08 b6 dd // sak
+ 60 04 d1 3d // wanna auth block 0x04 with A key
+TAG ed 12 9c 74 // 1st auth clear text nt
+ 55 53 9f cc 41 8d e8 f3 // nr', ar' (nr^ks1, ar^ks2 )
+TAG 05 49 e1 65 // at' ( at^ks3 )
+ 03 24 26 56 // wanna read block 0x04
+TAG ac 69 ef 58 45 e1 c2 1d a9 47 a5 94 54 ef 5d c7 1e a9 // block 0x04 content
+ d4 3e a8 aa
+TAG 8e 8e e3 e6 e9 e2 5f dd f6 08 ce fb 02 6a db 75 94 2f
+ 79 77 68 3c
+TAG e0 00 00 80 80 08 cc 80 08 9c 82 e0 68 64 60 30 91 60 // 18 bytes = 16 byte content + 2 bytes crc
+ ea 88 c3 c2 // 4 byte read cmd
+TAG a3 76 dc df c1 42 e0 ee c6 75 a4 ca eb 0c da eb 46 a0 // 18 bytes = 16 byte content + 2 bytes crc ks8 + crc
+ 2d 27 ab 6f // wanna auth to 0x04 block with key B
+
+-------Until this line we can recover key or decrypt communication with no troubles (see mfkey64 tool)--------------------------------
+
+TAG 52 6e af 8b // nested auth encrypted tag nonce that we dont know
+ 8e 21 3a 29 a4 80 7e 02 // nr_enc = nr^ks1, ar_enc = ar^ks2
+TAG b9 43 74 8d // at_enc = at^ks3
+ e2 25 f8 32 // probably next command (actually is read block cmd, but we dont know it yet)
+TAG 1f 26 82 8d 12 21 dd 42 c2 84 3e d0 26 7f 6b 2a 81 a9 // probably data
+ ba 85 1d 36 // probably read cmd
+TAG 62 a8 78 69 ee 36 22 16 1c ff 4b 4e 69 cb 27 c2 e8 7e // probably data
+ a7 b1 c8 da // probably read cmd
+TAG b2 fc 6c 65 60 ec 35 83 87 56 e3 7e 3c bf 38 b8 73 21 // probably data
+ 99 92 13 55 // probably read cmd
+TAG 93 5b 65 a3 1d 8c 75 b8 3a 63 e2 31 f0 d0 a9 24 9a f6 // probably data
+```
+
+
+Phase 1
+-------
+
+Syntax:
+`mf_nonce_brute <{nt}> <{nr}> <{ar}> <{at}> [<{next_command}>]`
+
+Example: if `nt` in trace is `8c! 42 e6! 4e!`, then `nt` is `8c42e64e` and `nt_par_err` is `1011`
+
+Example with parity (from this trace http://www.proxmark.org/forum/viewtopic.php?pid=550#p550) :
+
+```
+ + 561882: 1 : 26
+ + 64: 2 : TAG 04 00
+ + 10217: 2 : 93 20
+ + 64: 5 : TAG 9c 59 9b 32 6c UID
+ + 12313: 9 : 93 70 9c 59 9b 32 6c 6b 30
+ + 64: 3 : TAG 08 b6 dd
+ + 923318: 4 : 60 00 f5 7b AUTH Block 0
+ + 112: 4 : TAG 82 a4 16 6c Nonce Tag (NT)
+ + 6985: 8 : a1 e4! 58 ce! 6e ea! 41 e0! NR , AR
+ + 64: 4 : TAG 5c! ad f4 39! AT
+ + 811513: 4 : 8e 0e! 5d! b9 AUTH Block 0 (nested)
+ + 112: 4 : TAG 5a! 92 0d! 85! Nonce Tag (NT)
+ + 6946: 8 : 98! d7 6b! 77 d6 c6 e8 70 NR , AR
+ + 64: 4 : TAG ca 7e! 0b! 63! AT
+ + 670868: 4 : 3e! 70 9c! 8a
+ + 112: 4 : TAG 36! 41 24! 79
+ + 9505: 8 : 1b! 8c 3a! 48! 83 5a 4a! 27
+ + 64: 4 : TAG 40! 6a! 99! 4b
+ + 905612: 4 : c9 7c 64! 13! !crc
+ + 112: 4 : TAG b5! ab! 1d! 2b
+ + 6936: 8 : 7e! d2 5c! ca! 4b! 50! 88! c4 !crc
+ + 64: 4 : TAG bf dd 01 be!
+ + 987853: 4 : 56 98 49 d6! !crc
+```
+=>
+```
+./mf_nonce_brute 9c599b32 82a4166c 0000 a1e458ce 6eea41e0 0101 5cadf439 1001 3e709c8a
+ | | | | | | | | |
+ +UID +nt_enc | +nr_enc +ar_enc | +at_enc | +encrypted next cmd
+ +nt_par_err +at_par_err +at_par_err
+```
+
+These two taken from above use the plaintext tagnonce `nt`=`82a4166c`, they still find a possible key candidate.
+```
+./mf_nonce_brute 9c599b32 82a4166c 0000 a1e458ce 6eea41e0 0101 5cadf439 1001
+./mf_nonce_brute 9c599b32 82a4166c 0000 98d76b77 d6c6e870 0000 ca7e0b63 0111
+```
+
+This one uses the encrypted tagnonce `nt`=`5a920d85`, it finds a valid key.
+```
+./mf_nonce_brute 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111
+```
+
+This one uses the encrypted tagnonce `nt`=`5a920d85` and the encrypted cmd `3e709c8a` to validate , it finds a valid key.
+```
+./mf_nonce_brute 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a
+```
+Full output:
+```
+$ ./mf_nonce_brute 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a
+Mifare classic nested auth key recovery. Phase 1.
+-------------------------------------------------
+uid: 9c599b32
+nt encrypted: 5a920d85
+nt parity err: 1011
+nr encrypted: 98d76b77
+ar encrypted: d6c6e870
+ar parity err: 0000
+at encrypted: ca7e0b63
+at parity err: 0111
+next cmd enc: 3e709c8a
+
+
+Starting 4 threads to bruteforce encrypted tag nonce last bytes
+CMD enc(3e709c8a)
+ dec(6000f57b) <-- Valid cmd
+
+Valid Key found: [ffffffffffff]
+
+Time in mf_nonce_brute (Phase 1): 1763 ticks 2.0 seconds
+```
diff --git a/tools/mf_nonce_brute/iso14443crc.c b/tools/mf_nonce_brute/iso14443crc.c
new file mode 100644
index 000000000..60631f4fb
--- /dev/null
+++ b/tools/mf_nonce_brute/iso14443crc.c
@@ -0,0 +1,46 @@
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// ISO14443 CRC calculation code.
+//-----------------------------------------------------------------------------
+
+#include "iso14443crc.h"
+
+static unsigned short UpdateCrc14443(unsigned char ch, unsigned short *lpwCrc) {
+ ch = (ch ^ (unsigned char)((*lpwCrc) & 0x00FF));
+ ch = (ch ^ (ch << 4));
+ *lpwCrc = (*lpwCrc >> 8) ^ ((unsigned short) ch << 8) ^
+ ((unsigned short) ch << 3) ^ ((unsigned short) ch >> 4);
+ return (*lpwCrc);
+}
+
+void ComputeCrc14443(int CrcType,
+ const unsigned char *Data, int Length,
+ unsigned char *TransmitFirst,
+ unsigned char *TransmitSecond) {
+ unsigned char chBlock;
+ unsigned short wCrc = CrcType;
+
+ do {
+ chBlock = *Data++;
+ UpdateCrc14443(chBlock, &wCrc);
+ } while (--Length);
+
+ if (CrcType == CRC_14443_B)
+ wCrc = ~wCrc; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
+
+ *TransmitFirst = (unsigned char)(wCrc & 0xFF);
+ *TransmitSecond = (unsigned char)((wCrc >> 8) & 0xFF);
+ return;
+}
+
+int CheckCrc14443(int CrcType, const unsigned char *Data, int Length) {
+ unsigned char b1;
+ unsigned char b2;
+ if (Length < 3) return 0;
+ ComputeCrc14443(CrcType, Data, Length - 2, &b1, &b2);
+ if ((b1 == Data[Length - 2]) && (b2 == Data[Length - 1])) return 1;
+ return 0;
+}
diff --git a/tools/mf_nonce_brute/iso14443crc.h b/tools/mf_nonce_brute/iso14443crc.h
new file mode 100644
index 000000000..e9a82d521
--- /dev/null
+++ b/tools/mf_nonce_brute/iso14443crc.h
@@ -0,0 +1,26 @@
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// ISO14443 CRC calculation code.
+//-----------------------------------------------------------------------------
+
+#ifndef __ISO14443CRC_H
+#define __ISO14443CRC_H
+
+//-----------------------------------------------------------------------------
+// Routines to compute the CRCs (two different flavours, just for confusion)
+// required for ISO 14443, swiped directly from the spec.
+//-----------------------------------------------------------------------------
+#define CRC_14443_A 0x6363 /* ITU-V.41 */
+#define CRC_14443_B 0xFFFF /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
+#define CRC_ICLASS 0xE012 /* ICLASS PREFIX */
+
+void ComputeCrc14443(int CrcType,
+ const unsigned char *Data, int Length,
+ unsigned char *TransmitFirst,
+ unsigned char *TransmitSecond);
+int CheckCrc14443(int CrcType, const unsigned char *Data, int Length);
+
+#endif
diff --git a/tools/mf_nonce_brute/mf_nonce_brute.c b/tools/mf_nonce_brute/mf_nonce_brute.c
new file mode 100644
index 000000000..6bc69c3d9
--- /dev/null
+++ b/tools/mf_nonce_brute/mf_nonce_brute.c
@@ -0,0 +1,395 @@
+#define __STDC_FORMAT_MACROS
+#define _USE_32BIT_TIME_T 1
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "crapto1/crapto1.h"
+#include "protocol.h"
+#include "iso14443crc.h"
+
+#define odd_parity(i) (( (i) ^ (i)>>1 ^ (i)>>2 ^ (i)>>3 ^ (i)>>4 ^ (i)>>5 ^ (i)>>6 ^ (i)>>7 ^ 1) & 0x01)
+
+// a global mutex to prevent interlaced printing from different threads
+pthread_mutex_t print_lock;
+
+//--------------------- define options here
+uint32_t uid = 0; // serial number
+uint32_t nt_enc = 0; // Encrypted tag nonce
+uint32_t nr_enc = 0; // encrypted reader challenge
+uint32_t ar_enc = 0; // encrypted reader response
+uint32_t at_enc = 0; // encrypted tag response
+uint32_t cmd_enc = 0; // next encrypted command to sector
+
+uint32_t nt_par_err = 0;
+uint32_t ar_par_err = 0;
+uint32_t at_par_err = 0;
+
+typedef struct thread_args {
+ uint16_t xored;
+ int thread;
+ int idx;
+ bool ev1;
+} targs;
+
+//------------------------------------------------------------------
+uint8_t cmds[] = {
+ ISO14443A_CMD_READBLOCK,
+ ISO14443A_CMD_WRITEBLOCK,
+ MIFARE_AUTH_KEYA,
+ MIFARE_AUTH_KEYB,
+ MIFARE_CMD_INC,
+ MIFARE_CMD_DEC,
+ MIFARE_CMD_RESTORE,
+ MIFARE_CMD_TRANSFER
+};
+
+int global_counter = 0;
+int global_fin_flag = 0;
+int global_found = 0;
+int global_found_candidate = 0;
+size_t thread_count = 4;
+
+static uint16_t parity_from_err(uint32_t data, uint16_t par_err) {
+
+ uint16_t par = 0;
+ par |= odd_parity((data >> 24) & 0xFF) ^ ((par_err >> 12) & 1);
+ par <<= 4;
+
+ par |= odd_parity((data >> 16) & 0xFF) ^ ((par_err >> 8) & 1);
+ par <<= 4;
+
+ par |= odd_parity((data >> 8) & 0xFF) ^ ((par_err >> 4) & 1);
+ par <<= 4;
+
+ par |= odd_parity(data & 0xFF) ^ (par_err & 1);
+ return par;
+}
+
+static uint16_t xored_bits(uint16_t nt_par, uint32_t ntenc, uint16_t ar_par, uint32_t arenc, uint16_t at_par, uint32_t atenc) {
+ uint16_t xored = 0;
+
+ uint8_t par;
+ //1st (1st nt)
+ par = (nt_par >> 12) & 1;
+ xored |= par ^ ((ntenc >> 16) & 1);
+ xored <<= 1;
+
+ //2nd (2nd nt)
+ par = (nt_par >> 8) & 1;
+ xored |= par ^ ((ntenc >> 8) & 1);
+ xored <<= 1;
+
+ //3rd (3rd nt)
+ par = (nt_par >> 4) & 1;
+ xored |= par ^ (ntenc & 1);
+ xored <<= 1;
+
+ //4th (1st ar)
+ par = (ar_par >> 12) & 1;
+ xored |= par ^ ((arenc >> 16) & 1);
+ xored <<= 1;
+
+ //5th (2nd ar)
+ par = (ar_par >> 8) & 1;
+ xored |= par ^ ((arenc >> 8) & 1);
+ xored <<= 1;
+
+ //6th (3rd ar)
+ par = (ar_par >> 4) & 1;
+ xored |= par ^ (arenc & 1);
+ xored <<= 1;
+
+ //7th (4th ar)
+ par = ar_par & 1;
+ xored |= par ^ ((atenc >> 24) & 1);
+ xored <<= 1;
+
+ //8th (1st at)
+ par = (at_par >> 12) & 1;
+ xored |= par ^ ((atenc >> 16) & 1);
+ xored <<= 1;
+
+ //9th (2nd at)
+ par = (at_par >> 8) & 1;
+ xored |= par ^ ((atenc >> 8) & 1);
+ xored <<= 1;
+
+ //10th (3rd at)
+ par = (at_par >> 4) & 1;
+ xored |= par ^ (atenc & 1);
+
+ return xored;
+}
+
+static bool candidate_nonce(uint32_t xored, uint32_t nt, bool ev1) {
+ uint8_t byte, check;
+
+ if (!ev1) {
+ //1st (1st nt)
+ byte = (nt >> 24) & 0xFF;
+ check = odd_parity(byte) ^ ((nt >> 16) & 1) ^ ((xored >> 9) & 1);
+ if (check) return false;
+
+ //2nd (2nd nt)
+ byte = (nt >> 16) & 0xFF;
+ check = odd_parity(byte) ^ ((nt >> 8) & 1) ^ ((xored >> 8) & 1);
+ if (check) return false;
+ }
+
+ //3rd (3rd nt)
+ byte = (nt >> 8) & 0xFF;
+ check = odd_parity(byte) ^ (nt & 1) ^ ((xored >> 7) & 1);
+ if (check) return false;
+
+ uint32_t ar = prng_successor(nt, 64);
+
+ //4th (1st ar)
+ byte = (ar >> 24) & 0xFF;
+ check = odd_parity(byte) ^ ((ar >> 16) & 1) ^ ((xored >> 6) & 1);
+ if (check) return false;
+
+ //5th (2nd ar)
+ byte = (ar >> 16) & 0x0FF;
+ check = odd_parity(byte) ^ ((ar >> 8) & 1) ^ ((xored >> 5) & 1);
+ if (check) return false;
+
+ //6th (3rd ar)
+ byte = (ar >> 8) & 0xFF;
+ check = odd_parity(byte) ^ (ar & 1) ^ ((xored >> 4) & 1);
+ if (check) return false;
+
+ uint32_t at = prng_successor(nt, 96);
+
+ //7th (4th ar)
+ byte = ar & 0xFF;
+ check = odd_parity(byte) ^ ((at >> 24) & 1) ^ ((xored >> 3) & 1);
+ if (check) return false;
+
+ //8th (1st at)
+ byte = (at >> 24) & 0xFF;
+ check = odd_parity(byte) ^ ((at >> 16) & 1) ^ ((xored >> 2) & 1);
+ if (check) return false;
+
+ //9th (2nd at)
+ byte = (at >> 16) & 0xFF;
+ check = odd_parity(byte) ^ ((at >> 8) & 1) ^ ((xored >> 1) & 1) ;
+ if (check) return false;
+
+ //10th (3rd at)
+ byte = (at >> 8) & 0xFF;
+ check = odd_parity(byte) ^ (at & 1) ^ (xored & 1);
+ if (check) return false;
+
+ return true;
+}
+
+static bool checkValidCmd(uint32_t decrypted) {
+ uint8_t cmd = (decrypted >> 24) & 0xFF;
+ for (int i = 0; i < sizeof(cmds); ++i) {
+ if (cmd == cmds[i])
+ return true;
+ }
+ return false;
+}
+
+static bool checkCRC(uint32_t decrypted) {
+ uint8_t data[] = {
+ (decrypted >> 24) & 0xFF,
+ (decrypted >> 16) & 0xFF,
+ (decrypted >> 8) & 0xFF,
+ decrypted & 0xFF
+ };
+ return CheckCrc14443(CRC_14443_A, data, sizeof(data));
+}
+
+static void *brute_thread(void *arguments) {
+
+ //int shift = (int)arg;
+ struct thread_args *args = (struct thread_args *) arguments;
+
+ struct Crypto1State *revstate;
+ uint64_t key; // recovered key candidate
+ uint32_t ks2; // keystream used to encrypt reader response
+ uint32_t ks3; // keystream used to encrypt tag response
+ uint32_t ks4; // keystream used to encrypt next command
+ uint32_t nt; // current tag nonce
+
+ uint32_t p64 = 0;
+ uint32_t count;
+ int found = 0;
+ // TC == 4 (
+ // threads calls 0 ev1 == false
+ // threads calls 0,1,2 ev1 == true
+ for (count = args->idx; count < 0xFFFF; count += thread_count - 1) {
+
+ found = global_found;
+ if (found) break;
+
+ nt = count << 16 | prng_successor(count, 16);
+
+ if (!candidate_nonce(args->xored, nt, args->ev1))
+ continue;
+
+ p64 = prng_successor(nt, 64);
+ ks2 = ar_enc ^ p64;
+ ks3 = at_enc ^ prng_successor(p64, 32);
+ revstate = lfsr_recovery64(ks2, ks3);
+ ks4 = crypto1_word(revstate, 0, 0);
+
+ if (ks4 != 0) {
+
+ // lock this section to avoid interlacing prints from different threats
+ pthread_mutex_lock(&print_lock);
+ if (args->ev1)
+ printf("\n**** Possible key candidate ****\n");
+
+#if 0
+ printf("thread #%d idx %d %s\n", args->thread, args->idx, (args->ev1) ? "(Ev1)" : "");
+ printf("current nt(%08x) ar_enc(%08x) at_enc(%08x)\n", nt, ar_enc, at_enc);
+ printf("ks2:%08x\n", ks2);
+ printf("ks3:%08x\n", ks3);
+ printf("ks4:%08x\n", ks4);
+#endif
+ if (cmd_enc) {
+ uint32_t decrypted = ks4 ^ cmd_enc;
+ printf("CMD enc(%08x)\n", cmd_enc);
+ printf(" dec(%08x)\t", decrypted);
+
+ uint8_t isOK = 0;
+ // check if cmd exists
+ isOK = checkValidCmd(decrypted);
+
+ // Add a crc-check.
+ isOK = checkCRC(decrypted);
+
+ if (!isOK) {
+ printf("<-- not a valid cmd\n");
+ pthread_mutex_unlock(&print_lock);
+ continue;
+ } else {
+ printf("<-- Valid cmd\n");
+ }
+ }
+
+ lfsr_rollback_word(revstate, 0, 0);
+ lfsr_rollback_word(revstate, 0, 0);
+ lfsr_rollback_word(revstate, 0, 0);
+ lfsr_rollback_word(revstate, nr_enc, 1);
+ lfsr_rollback_word(revstate, uid ^ nt, 0);
+ crypto1_get_lfsr(revstate, &key);
+ free(revstate);
+
+ if (args->ev1) {
+ printf("\nKey candidate: [%012" PRIx64 "]\n\n", key);
+ __sync_fetch_and_add(&global_found_candidate, 1);
+ } else {
+ printf("\nValid Key found: [%012" PRIx64 "]\n\n", key);
+ __sync_fetch_and_add(&global_found, 1);
+ }
+ //release lock
+ pthread_mutex_unlock(&print_lock);
+ }
+ }
+ return NULL;
+}
+
+static int usage(void) {
+ printf(" syntax: mf_nonce_brute []\n\n");
+ printf(" example: nt in trace = 8c! 42 e6! 4e!\n");
+ printf(" nt = 8c42e64e\n");
+ printf(" nt_par_err = 1011\n\n");
+ printf("\n expected outcome:\n");
+ printf(" KEY 0xFFFFFFFFFFFF == fa247164 fb47c594 0000 71909d28 0c254817 1000 0dc7cfbd 1110\n");
+ return 1;
+}
+
+int main(int argc, char *argv[]) {
+ printf("Mifare classic nested auth key recovery. Phase 1.\n");
+
+ if (argc < 9) return usage();
+
+ sscanf(argv[1], "%x", &uid);
+ sscanf(argv[2], "%x", &nt_enc);
+ sscanf(argv[3], "%x", &nt_par_err);
+ sscanf(argv[4], "%x", &nr_enc);
+ sscanf(argv[5], "%x", &ar_enc);
+ sscanf(argv[6], "%x", &ar_par_err);
+ sscanf(argv[7], "%x", &at_enc);
+ sscanf(argv[8], "%x", &at_par_err);
+
+ if (argc > 9)
+ sscanf(argv[9], "%x", &cmd_enc);
+
+ printf("-------------------------------------------------\n");
+ printf("uid:\t\t%08x\n", uid);
+ printf("nt encrypted:\t%08x\n", nt_enc);
+ printf("nt parity err:\t%04x\n", nt_par_err);
+ printf("nr encrypted:\t%08x\n", nr_enc);
+ printf("ar encrypted:\t%08x\n", ar_enc);
+ printf("ar parity err:\t%04x\n", ar_par_err);
+ printf("at encrypted:\t%08x\n", at_enc);
+ printf("at parity err:\t%04x\n", at_par_err);
+
+ if (argc > 9)
+ printf("next cmd enc:\t%08x\n\n", cmd_enc);
+
+ clock_t t1 = clock();
+ uint16_t nt_par = parity_from_err(nt_enc, nt_par_err);
+ uint16_t ar_par = parity_from_err(ar_enc, ar_par_err);
+ uint16_t at_par = parity_from_err(at_enc, at_par_err);
+
+ //calc (parity XOR corresponding nonce bit encoded with the same keystream bit)
+ uint16_t xored = xored_bits(nt_par, nt_enc, ar_par, ar_enc, at_par, at_enc);
+
+#ifndef __WIN32
+ thread_count = sysconf(_SC_NPROCESSORS_CONF);
+ if (thread_count < 2)
+ thread_count = 2;
+#endif /* _WIN32 */
+
+ printf("\nBruteforce using %zu threads to find encrypted tagnonce last bytes\n", thread_count);
+
+ pthread_t threads[thread_count];
+
+ // create a mutex to avoid interlacing print commands from our different threads
+ pthread_mutex_init(&print_lock, NULL);
+
+ // one thread T0 for none EV1.
+ struct thread_args *a = malloc(sizeof(struct thread_args));
+ a->xored = xored;
+ a->thread = 0;
+ a->idx = 0;
+ a->ev1 = false;
+ pthread_create(&threads[0], NULL, brute_thread, (void *)a);
+
+ // the rest of available threads to EV1 scenario
+ for (int i = 0; i < thread_count - 1; ++i) {
+ struct thread_args *b = malloc(sizeof(struct thread_args));
+ b->xored = xored;
+ b->thread = i + 1;
+ b->idx = i;
+ b->ev1 = true;
+ pthread_create(&threads[i + 1], NULL, brute_thread, (void *)b);
+ }
+
+ // wait for threads to terminate:
+ for (int i = 0; i < thread_count; ++i)
+ pthread_join(threads[i], NULL);
+
+ if (!global_found && !global_found_candidate) {
+ printf("\nFailed to find a key\n\n");
+ }
+
+ t1 = clock() - t1;
+ if (t1 > 0)
+ printf("Execution time: %.0f ticks\n", (float)t1);
+
+ // clean up mutex
+ pthread_mutex_destroy(&print_lock);
+ return 0;
+}
diff --git a/tools/mf_nonce_brute/protocol.h b/tools/mf_nonce_brute/protocol.h
new file mode 100644
index 000000000..4f7f8b7e0
--- /dev/null
+++ b/tools/mf_nonce_brute/protocol.h
@@ -0,0 +1,20 @@
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#define ISO14443A_CMD_READBLOCK 0x30
+#define ISO14443A_CMD_WRITEBLOCK 0xA0
+
+#define MIFARE_AUTH_KEYA 0x60
+#define MIFARE_AUTH_KEYB 0x61
+#define MIFARE_CMD_INC 0xC0
+#define MIFARE_CMD_DEC 0xC1
+#define MIFARE_CMD_RESTORE 0xC2
+#define MIFARE_CMD_TRANSFER 0xB0
+
+// mifare 4bit card answers
+#define CARD_ACK 0x0A // 1010 - ACK
+#define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
+#define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
+
+#endif
+// PROTOCOL_H
diff --git a/tools/mf_nonce_brute/sleep.c b/tools/mf_nonce_brute/sleep.c
new file mode 100644
index 000000000..0dd4c089d
--- /dev/null
+++ b/tools/mf_nonce_brute/sleep.c
@@ -0,0 +1,28 @@
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// platform-independant sleep macros
+//-----------------------------------------------------------------------------
+
+#ifndef _WIN32
+
+#define _POSIX_C_SOURCE 199309L
+#include "sleep.h"
+#include
+#include
+#include
+#include
+
+void nsleep(uint64_t n) {
+ struct timespec timeout;
+ timeout.tv_sec = n / 1000000000;
+ timeout.tv_nsec = n % 1000000000;
+ while (nanosleep(&timeout, &timeout) && errno == EINTR);
+}
+
+#endif // _WIN32
+
diff --git a/tools/mf_nonce_brute/sleep.h b/tools/mf_nonce_brute/sleep.h
new file mode 100644
index 000000000..8465b6041
--- /dev/null
+++ b/tools/mf_nonce_brute/sleep.h
@@ -0,0 +1,27 @@
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// platform-independant sleep macros
+//-----------------------------------------------------------------------------
+
+#ifndef SLEEP_H__
+#define SLEEP_H__
+
+#ifdef _WIN32
+# include
+# define sleep(n) Sleep(1000 * n)
+# define msleep(n) Sleep(n)
+#else
+# include
+# include
+void nsleep(uint64_t n);
+# define msleep(n) nsleep(1000000 * n)
+# define usleep(n) nsleep(1000 * n)
+#endif // _WIN32
+
+#endif // SLEEP_H__
+
From ddb432ec8f808dcb699b21f0b2d0c13b2e3d2d58 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 17:00:53 +0200
Subject: [PATCH 003/527] textual
---
client/src/loclass/cipher.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/client/src/loclass/cipher.c b/client/src/loclass/cipher.c
index 9cc683300..b8d481f1e 100644
--- a/client/src/loclass/cipher.c
+++ b/client/src/loclass/cipher.c
@@ -247,7 +247,6 @@ static void MAC(uint8_t *k, BitstreamIn input, BitstreamOut out) {
void doMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4]) {
uint8_t cc_nr[13] = { 0 };
uint8_t div_key[8];
- //cc_nr=(uint8_t*) calloc(length+1, sizeof(uint8_t));
memcpy(cc_nr, cc_nr_p, 12);
memcpy(div_key, div_key_p, 8);
@@ -260,7 +259,6 @@ void doMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4]) {
//The output MAC must also be reversed
reverse_arraybytes(dest, sizeof(dest));
memcpy(mac, dest, 4);
- //free(cc_nr);
}
void doMAC_N(uint8_t *address_data_p, uint8_t address_data_size, uint8_t *div_key_p, uint8_t mac[4]) {
@@ -296,9 +294,9 @@ int testMAC(void) {
doMAC(cc_nr, div_key, calculated_mac);
if (memcmp(calculated_mac, correct_MAC, 4) == 0) {
- PrintAndLogEx(SUCCESS, "MAC calculation OK!");
+ PrintAndLogEx(SUCCESS, " MAC calculation (%s)", _GREEN_("ok"));
} else {
- PrintAndLogEx(FAILED, "FAILED: MAC calculation failed:");
+ PrintAndLogEx(FAILED, " MAC calculation (%s)", _RED_("failed"));
printarr(" Calculated_MAC", calculated_mac, 4);
printarr(" Correct_MAC ", correct_MAC, 4);
return PM3_ESOFT;
From f3b4028e8a4ef9ee92573700e42ec5436c1eb0fb Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 17:02:42 +0200
Subject: [PATCH 004/527] textaul, worked return codes for tests and swaped to
printandlog
---
client/src/loclass/cipherutils.c | 27 +++---
client/src/loclass/elite_crack.c | 82 ++++++++--------
client/src/loclass/elite_crack.h | 2 +-
client/src/loclass/hash1_brute.c | 1 -
client/src/loclass/ikeys.c | 154 ++++++++++++++-----------------
client/src/loclass/ikeys.h | 2 +-
6 files changed, 130 insertions(+), 138 deletions(-)
diff --git a/client/src/loclass/cipherutils.c b/client/src/loclass/cipherutils.c
index fa58dfeaa..31ff90e50 100644
--- a/client/src/loclass/cipherutils.c
+++ b/client/src/loclass/cipherutils.c
@@ -169,12 +169,17 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
if (arr == NULL) return;
int cx = 0, i;
- size_t outsize = 100 + strlen(title) + len * 4;
+ size_t outsize = 100 + strlen(title) + (len * 4);
char *output = calloc(outsize, sizeof(char));
PrintAndLogEx(INFO, "%s", title);
for (i = 0; i < len; i++) {
- if (i % 16 == 0)
- cx += snprintf(output + cx, outsize - cx, "\n%02x| ", i);
+ if (i % 16 == 0) {
+
+ if (i == 0)
+ cx += snprintf(output + cx, outsize - cx, "%02x| ", i);
+ else
+ cx += snprintf(output + cx, outsize - cx, "\n%02x| ", i);
+ }
cx += snprintf(output + cx, outsize - cx, "%02x ", *(arr + i));
}
PrintAndLogEx(INFO, output);
@@ -199,9 +204,9 @@ static int testBitStream(void) {
}
if (memcmp(input, output, sizeof(input)) == 0) {
- PrintAndLogEx(SUCCESS, " Bitstream test 1 ok");
+ PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok") );
} else {
- PrintAndLogEx(FAILED, " Bitstream test 1 failed");
+ PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed") );
uint8_t i;
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
PrintAndLogEx(NORMAL, " IN %02x, OUT %02x", input[i], output[i]);
@@ -229,9 +234,9 @@ static int testReversedBitstream(void) {
}
if (memcmp(input, output, sizeof(input)) == 0) {
- PrintAndLogEx(SUCCESS, " Bitstream test 2 ok");
+ PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok") );
} else {
- PrintAndLogEx(FAILED, " Bitstream test 2 failed");
+ PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed") );
uint8_t i;
for (i = 0 ; i < ARRAYLEN(input) ; i++) {
PrintAndLogEx(NORMAL, " IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]);
@@ -241,12 +246,12 @@ static int testReversedBitstream(void) {
return PM3_SUCCESS;
}
-
int testCipherUtils(void) {
PrintAndLogEx(INFO, "Testing some internals...");
- int retval = 0;
- retval |= testBitStream();
- retval |= testReversedBitstream();
+ int retval = testBitStream();
+ if (retval == PM3_SUCCESS)
+ retval = testReversedBitstream();
+
return retval;
}
#endif
diff --git a/client/src/loclass/elite_crack.c b/client/src/loclass/elite_crack.c
index 4dbac9704..cc9570351 100644
--- a/client/src/loclass/elite_crack.c
+++ b/client/src/loclass/elite_crack.c
@@ -293,7 +293,7 @@ static int _readFromDump(uint8_t dump[], dumpdata *item, uint8_t i) {
* @return
*/
int bruteforceItem(dumpdata item, uint16_t keytable[]) {
- int errors = 0;
+
int found = false;
uint8_t key_sel_p[8] = {0};
uint8_t div_key[8] = {0};
@@ -334,7 +334,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) {
keytable[bytes_to_recover[0]] &= ~BEING_CRACKED;
keytable[bytes_to_recover[1]] &= ~BEING_CRACKED;
keytable[bytes_to_recover[2]] &= ~BEING_CRACKED;
- return 1;
+ return PM3_ESOFT;
}
}
@@ -400,11 +400,13 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) {
}
}
+ int errors = PM3_SUCCESS;
+
if (!found) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(WARNING, "Failed to recover %d bytes using the following CSN", numbytes_to_recover);
PrintAndLogEx(INFO, "CSN %s", sprint_hex(item.csn, 8));
- errors++;
+ errors = PM3_ESOFT;
//Before we exit, reset the 'BEING_CRACKED' to zero
for (i = 0; i < numbytes_to_recover; i++) {
@@ -475,14 +477,14 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) {
if (master_key != NULL)
memcpy(master_key, key64, 8);
+ PrintAndLogEx(NORMAL, "\n");
if (memcmp(z_0, result, 4) != 0) {
PrintAndLogEx(WARNING, _RED_("Failed to verify") " calculated master key (k_cus)! Something is wrong.");
- return 1;
- } else {
- PrintAndLogEx(NORMAL, "\n");
- PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!"));
- }
- return 0;
+ return PM3_ESOFT;
+ }
+
+ PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!"));
+ return PM3_SUCCESS;
}
/**
* @brief Same as bruteforcefile, but uses a an array of dumpdata instead
@@ -493,27 +495,29 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) {
*/
int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
uint8_t i;
- int errors = 0;
size_t itemsize = sizeof(dumpdata);
-
uint64_t t1 = msclock();
dumpdata *attack = (dumpdata *) calloc(itemsize, sizeof(uint8_t));
-
+ if (attack == NULL) {
+ PrintAndLogEx(WARNING, "failed to allocate memory");
+ return PM3_EMALLOC;
+ }
+
+ int res = 0;
for (i = 0 ; i * itemsize < dumpsize ; i++) {
memcpy(attack, dump + i * itemsize, itemsize);
- errors += bruteforceItem(*attack, keytable);
- if (errors)
+ res += bruteforceItem(*attack, keytable);
+ if (res != PM3_SUCCESS)
break;
}
free(attack);
t1 = msclock() - t1;
PrintAndLogEx(SUCCESS, "time: %" PRIu64 " seconds", t1 / 1000);
-
- if (errors) {
+ if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "loclass exiting. Try run " _YELLOW_("`hf iclass sim 2`") " again and collect new data");
- return 1;
+ return PM3_ESOFT;
}
// Pick out the first 16 bytes of the keytable.
@@ -527,11 +531,10 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
if (!(keytable[i] & CRACKED)) {
PrintAndLogEx(WARNING, "Warning: we are missing byte %d, custom key calculation will fail...", i);
- return 1;
+ return PM3_ESOFT;
}
}
- errors += calculateMasterKey(first16bytes, NULL);
- return errors;
+ return calculateMasterKey(first16bytes, NULL);
}
/**
* Perform a bruteforce against a file which has been saved by pm3
@@ -589,12 +592,11 @@ static int _testBruteforce(void) {
**** The 64-bit HS Custom Key Value = 5B7C62C491C11B39 ****
**/
uint16_t keytable[128] = {0};
- int errors = bruteforceFile("iclass_dump.bin", keytable);
- if (errors) {
+ int res = bruteforceFile("iclass_dump.bin", keytable);
+ if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "Error: The file " _YELLOW_("iclass_dump.bin") "was not found!");
}
-
- return errors;
+ return res;
}
static int _test_iclass_key_permutation(void) {
@@ -609,18 +611,18 @@ static int _test_iclass_key_permutation(void) {
PrintAndLogEx(ERR, "Error with iclass key permute!");
printarr("testcase_output", testcase_output, 8);
printarr("testcase_output_correct", testcase_output_correct, 8);
- return 1;
+ return PM3_ESOFT;
}
if (memcmp(testcase, testcase_output_rev, 8) != 0) {
PrintAndLogEx(ERR, "Error with reverse iclass key permute");
printarr("testcase", testcase, 8);
printarr("testcase_output_rev", testcase_output_rev, 8);
- return 1;
+ return PM3_ESOFT;
}
- PrintAndLogEx(SUCCESS, "Iclass key permutation OK!");
- return 0;
+ PrintAndLogEx(SUCCESS, "Iclass key permutation (%s)", _GREEN_("OK"));
+ return PM3_SUCCESS;
}
static int _testHash1(void) {
@@ -633,9 +635,9 @@ static int _testHash1(void) {
PrintAndLogEx(ERR, "Error with hash1!");
printarr("calculated", k, 8);
printarr("expected", expected, 8);
- return 1;
+ return PM3_ESOFT;
}
- return 0;
+ return PM3_SUCCESS;
}
int testElite(bool slowtests) {
@@ -662,15 +664,21 @@ int testElite(bool slowtests) {
hash2(k_cus, keytable);
printarr_human_readable("Hash2", keytable, 128);
if (keytable[3] == 0xA1 && keytable[0x30] == 0xA3 && keytable[0x6F] == 0x95) {
- PrintAndLogEx(SUCCESS, "Hash2 looks fine...");
+ PrintAndLogEx(SUCCESS, " Hash2 (%s)", _GREEN_("ok"));
}
- int errors = 0 ;
+ int res = PM3_SUCCESS;
PrintAndLogEx(INFO, "Testing hash1...");
- errors += _testHash1();
- PrintAndLogEx(INFO, "Testing key diversification ...");
- errors += _test_iclass_key_permutation();
+ res += _testHash1();
+ PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
+
+ PrintAndLogEx(INFO, "Testing key diversification...");
+ res += _test_iclass_key_permutation();
+ if (res == PM3_SUCCESS)
+ PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") );
+
if (slowtests)
- errors += _testBruteforce();
- return errors;
+ res += _testBruteforce();
+
+ return res;
}
diff --git a/client/src/loclass/elite_crack.h b/client/src/loclass/elite_crack.h
index 8b357ac66..a9de5dbd1 100644
--- a/client/src/loclass/elite_crack.h
+++ b/client/src/loclass/elite_crack.h
@@ -104,7 +104,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]);
* @param csn the CSN used
* @param k output
*/
-void hash1(uint8_t csn[], uint8_t k[]);
+void hash1(uint8_t *csn, uint8_t *k);
void hash2(uint8_t *key64, uint8_t *outp_keytable);
/**
* From dismantling iclass-paper:
diff --git a/client/src/loclass/hash1_brute.c b/client/src/loclass/hash1_brute.c
index e381c5a3a..1c944b99e 100644
--- a/client/src/loclass/hash1_brute.c
+++ b/client/src/loclass/hash1_brute.c
@@ -8,7 +8,6 @@
#include
#include "elite_crack.h"
-
static void calc_score(uint8_t *csn, uint8_t *k) {
uint8_t score = 0 ;
uint8_t i;
diff --git a/client/src/loclass/ikeys.c b/client/src/loclass/ikeys.c
index 3bbe9fc2b..d828583d7 100644
--- a/client/src/loclass/ikeys.c
+++ b/client/src/loclass/ikeys.c
@@ -72,13 +72,17 @@ From "Dismantling iclass":
#include "cipherutils.h"
#include "mbedtls/des.h"
-uint8_t pi[35] = {0x0F, 0x17, 0x1B, 0x1D, 0x1E, 0x27, 0x2B, 0x2D, 0x2E, 0x33, 0x35, 0x39, 0x36, 0x3A, 0x3C, 0x47, 0x4B, 0x4D, 0x4E, 0x53, 0x55, 0x56, 0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x69, 0x6A, 0x6C, 0x71, 0x72, 0x74, 0x78};
+uint8_t pi[35] = {
+ 0x0F, 0x17, 0x1B, 0x1D, 0x1E, 0x27, 0x2B, 0x2D,
+ 0x2E, 0x33, 0x35, 0x39, 0x36, 0x3A, 0x3C, 0x47,
+ 0x4B, 0x4D, 0x4E, 0x53, 0x55, 0x56, 0x59, 0x5A,
+ 0x5C, 0x63, 0x65, 0x66, 0x69, 0x6A, 0x6C, 0x71,
+ 0x72, 0x74, 0x78
+};
static mbedtls_des_context ctx_enc;
static mbedtls_des_context ctx_dec;
-static int debug_print = 0;
-
/**
* @brief The key diversification algorithm uses 6-bit bytes.
* This implementation uses 64 bit uint to pack seven of them into one
@@ -219,25 +223,19 @@ static void permute(BitstreamIn *p_in, uint64_t z, int l, int r, BitstreamOut *o
}
}
-static void printbegin(void) {
- if (debug_print < 2)
- return;
-
- PrintAndLogEx(NORMAL, " | x| y|z0|z1|z2|z3|z4|z5|z6|z7|");
-}
-
static void printState(const char *desc, uint64_t c) {
- if (debug_print < 2)
- return;
-
- printf("%s : ", desc);
+ char s[60] = {0};
+ snprintf(s, sizeof(s), "%s : ", desc);
+
uint8_t x = (c & 0xFF00000000000000) >> 56;
uint8_t y = (c & 0x00FF000000000000) >> 48;
- printf(" %02x %02x", x, y);
- int i;
- for (i = 0; i < 8; i++)
- printf(" %02x", getSixBitByte(c, i));
- printf("\n");
+
+ snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x %02x", x, y);
+
+ for (uint8_t i = 0; i < 8; i++)
+ snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x", getSixBitByte(c, i));
+
+ PrintAndLogEx(DEBUG, "%s", s);
}
/**
@@ -254,7 +252,7 @@ static void printState(const char *desc, uint64_t c) {
void hash0(uint64_t c, uint8_t k[8]) {
c = swapZvalues(c);
- printbegin();
+ PrintAndLogEx(DEBUG, " | x| y|z0|z1|z2|z3|z4|z5|z6|z7|");
printState("origin", c);
//These 64 bits are divided as c = x, y, z [0] , . . . , z [7]
// x = 8 bits
@@ -286,7 +284,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
if (x & 1) //Check if x7 is 1
p = ~p;
- if (debug_print >= 2) PrintAndLogEx(DEBUG, "p:%02x", p);
+ PrintAndLogEx(DEBUG, "p: %02x", p);
BitstreamIn p_in = { &p, 8, 0 };
uint8_t outbuffer[] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -297,7 +295,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
// if all went well
//Shift z-values down onto the lower segment
- uint64_t zTilde = x_bytes_to_num(outbuffer, 8);
+ uint64_t zTilde = x_bytes_to_num(outbuffer, sizeof(outbuffer));
zTilde >>= 16;
@@ -353,7 +351,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
* @param key
* @param div_key
*/
-void diversifyKey(uint8_t csn[8], uint8_t key[8], uint8_t div_key[8]) {
+void diversifyKey(uint8_t* csn, uint8_t* key, uint8_t* div_key) {
// Prepare the DES key
mbedtls_des_setkey_enc(&ctx_enc, key);
@@ -363,10 +361,10 @@ void diversifyKey(uint8_t csn[8], uint8_t key[8], uint8_t div_key[8]) {
mbedtls_des_crypt_ecb(&ctx_enc, csn, crypted_csn);
//Calculate HASH0(DES))
- uint64_t crypt_csn = x_bytes_to_num(crypted_csn, 8);
+ uint64_t c_csn = x_bytes_to_num(crypted_csn, sizeof(crypted_csn));
//uint64_t crypted_csn_swapped = swapZvalues(crypt_csn);
- hash0(crypt_csn, div_key);
+ hash0(c_csn, div_key);
}
/*
static void testPermute(void) {
@@ -571,58 +569,42 @@ static int testKeyDiversificationWithMasterkeyTestcases(void) {
return error;
}
-static void print64bits(const char *name, uint64_t val) {
- printf("%s%08x%08x\n", name, (uint32_t)(val >> 32), (uint32_t)(val & 0xFFFFFFFF));
-}
+static int testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
-static uint64_t testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
- int retval = 0;
uint8_t result[8] = {0};
- if (debug_print) {
- PrintAndLogEx(DEBUG, "debug_print %d", debug_print);
- print64bits(" {csn} ", crypted_csn);
- }
-
uint64_t crypted_csn_swapped = swapZvalues(crypted_csn);
-
- if (debug_print) print64bits(" {csn-revz} ", crypted_csn_swapped);
-
hash0(crypted_csn, result);
uint64_t resultbyte = x_bytes_to_num(result, 8);
- if (debug_print) print64bits(" hash0 ", resultbyte);
+
+ PrintAndLogEx(DEBUG, "");
+ PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypted_csn);
+ PrintAndLogEx(DEBUG, " {csn-revz} %"PRIx64, crypted_csn_swapped);
+ PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL") );
if (resultbyte != expected) {
- if (debug_print) {
- PrintAndLogEx(NORMAL, "\n");
- PrintAndLogEx(FAILED, "FAIL!");
- print64bits(" expected ", expected);
- }
- retval = 1;
- } else {
- if (debug_print) PrintAndLogEx(SUCCESS, "[OK]");
+ PrintAndLogEx(DEBUG, " expected " _YELLOW_("%"PRIx64), expected);
+ return PM3_ESOFT;
}
- return retval;
+ return PM3_SUCCESS;
}
static int testDES2(uint64_t csn, uint64_t expected) {
uint8_t result[8] = {0};
uint8_t input[8] = {0};
- print64bits(" csn ", csn);
+ PrintAndLogEx(DEBUG, " csn %"PRIx64, csn);
x_num_to_bytes(csn, 8, input);
mbedtls_des_crypt_ecb(&ctx_enc, input, result);
uint64_t crypt_csn = x_bytes_to_num(result, 8);
- print64bits(" {csn} ", crypt_csn);
- print64bits(" expected ", expected);
- if (expected == crypt_csn) {
- PrintAndLogEx(SUCCESS, "OK");
- return 0;
- } else {
- return 1;
- }
+ PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypt_csn);
+ PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL") );
+
+ if (expected != crypt_csn)
+ return PM3_ESOFT;
+ return PM3_SUCCESS;
}
/**
@@ -632,53 +614,52 @@ static int testDES2(uint64_t csn, uint64_t expected) {
*/
static int doTestsWithKnownInputs(void) {
// KSel from http://www.proxmark.org/forum/viewtopic.php?pid=10977#p10977
- int errors = 0;
- PrintAndLogEx(SUCCESS, "Testing DES encryption");
+ PrintAndLogEx(INFO, "Testing DES encryption");
uint8_t key[8] = {0x6c, 0x8d, 0x44, 0xf9, 0x2a, 0x2d, 0x01, 0xbf};
mbedtls_des_setkey_enc(&ctx_enc, key);
testDES2(0xbbbbaaaabbbbeeee, 0xd6ad3ca619659e6b);
- PrintAndLogEx(SUCCESS, "Testing hashing algorithm");
+ PrintAndLogEx(INFO, "Testing hashing algorithm");
- errors += testCryptedCSN(0x0102030405060708, 0x0bdd6512073c460a);
- errors += testCryptedCSN(0x1020304050607080, 0x0208211405f3381f);
- errors += testCryptedCSN(0x1122334455667788, 0x2bee256d40ac1f3a);
- errors += testCryptedCSN(0xabcdabcdabcdabcd, 0xa91c9ec66f7da592);
- errors += testCryptedCSN(0xbcdabcdabcdabcda, 0x79ca5796a474e19b);
- errors += testCryptedCSN(0xcdabcdabcdabcdab, 0xa8901b9f7ec76da4);
- errors += testCryptedCSN(0xdabcdabcdabcdabc, 0x357aa8e0979a5b8d);
- errors += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea);
- errors += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3);
+ int res = PM3_SUCCESS;
+ res += testCryptedCSN(0x0102030405060708, 0x0bdd6512073c460a);
+ res += testCryptedCSN(0x1020304050607080, 0x0208211405f3381f);
+ res += testCryptedCSN(0x1122334455667788, 0x2bee256d40ac1f3a);
+ res += testCryptedCSN(0xabcdabcdabcdabcd, 0xa91c9ec66f7da592);
+ res += testCryptedCSN(0xbcdabcdabcdabcda, 0x79ca5796a474e19b);
+ res += testCryptedCSN(0xcdabcdabcdabcdab, 0xa8901b9f7ec76da4);
+ res += testCryptedCSN(0xdabcdabcdabcdabc, 0x357aa8e0979a5b8d);
+ res += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea);
+ res += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3);
- if (errors)
- PrintAndLogEx(FAILED, "%d errors occurred (9 testcases)", errors);
- else
+ if (res != PM3_SUCCESS) {
+ PrintAndLogEx(FAILED, "%d res occurred (9 testcases)", res);
+ res = PM3_ESOFT;
+ } else {
PrintAndLogEx(SUCCESS, "Hashing seems to work (9 testcases)");
- return errors;
+ res = PM3_SUCCESS;
+ }
+ return res;
}
-
static bool readKeyFile(uint8_t *key, size_t keylen) {
+ bool retval = false;
size_t len = 0;
uint8_t *keyptr = NULL;
if (loadFile_safe("iclass_key.bin", "", (void **)&keyptr, &len) != PM3_SUCCESS) {
- return false;
+ return retval;
}
-
- if (keylen != len) {
- free(keyptr);
- return false;
+ if (keylen == len) {
+ memcpy(key, keyptr, keylen);
+ retval = true;
}
-
- memcpy(key, keyptr, keylen);
free(keyptr);
- return true;
+ return retval;
}
-int doKeyTests(uint8_t debuglevel) {
- debug_print = debuglevel;
+int doKeyTests(void) {
PrintAndLogEx(INFO, "Checking if the master key is present (iclass_key.bin)...");
uint8_t key[8] = {0};
@@ -705,9 +686,8 @@ int doKeyTests(uint8_t debuglevel) {
testKeyDiversificationWithMasterkeyTestcases();
}
}
- PrintAndLogEx(SUCCESS, "Testing key diversification with non-sensitive keys...");
- doTestsWithKnownInputs();
- return 0;
+ PrintAndLogEx(INFO, "Testing key diversification with non-sensitive keys...");
+ return doTestsWithKnownInputs();
}
/**
diff --git a/client/src/loclass/ikeys.h b/client/src/loclass/ikeys.h
index ccbc5539b..4fceda95f 100644
--- a/client/src/loclass/ikeys.h
+++ b/client/src/loclass/ikeys.h
@@ -52,7 +52,7 @@
* @return
*/
void hash0(uint64_t c, uint8_t k[8]);
-int doKeyTests(uint8_t debuglevel);
+int doKeyTests(void);
/**
* @brief Performs Elite-class key diversification
* @param csn
From 351a8d26affe4eae1eb4e69ebf346853c7bf2a38 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 17:03:28 +0200
Subject: [PATCH 005/527] adjust tests
---
client/src/cmdhficlass.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c
index 66314e2c6..73b9a6b18 100644
--- a/client/src/cmdhficlass.c
+++ b/client/src/cmdhficlass.c
@@ -1938,11 +1938,15 @@ static int CmdHFiClass_loclass(const char *Cmd) {
}
} else if (opt == 't') {
char opt2 = tolower(param_getchar(Cmd, 1));
+
int errors = testCipherUtils();
errors += testMAC();
- errors += doKeyTests(0);
+ errors += doKeyTests();
errors += testElite(opt2 == 'l');
- if (errors) PrintAndLogEx(ERR, "There were errors!!!");
+
+ if (errors != PM3_SUCCESS)
+ PrintAndLogEx(ERR, "There were errors!!!");
+
return PM3_ESOFT;
}
return PM3_SUCCESS;
@@ -2076,7 +2080,7 @@ void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite
hash2(KEY, keytable);
hash1(CSN, key_index);
for (uint8_t i = 0; i < 8 ; i++)
- key_sel[i] = keytable[key_index[i]] & 0xFF;
+ key_sel[i] = keytable[key_index[i]];
//Permute from iclass format to standard format
permutekey_rev(key_sel, key_sel_p);
From 8c656492582bff98f0b257bb380c8e63b5f88f27 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 17:04:33 +0200
Subject: [PATCH 006/527] better fault text
---
client/src/proxmark3.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 08a4686ac..c8d70cb0d 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -241,8 +241,11 @@ check_script:
// read script file
if (fgets(script_cmd_buf, sizeof(script_cmd_buf), current_cmdscriptfile()) == NULL) {
+ PrintAndLogEx(ERR, "Unexpected end, [%s]", current_cmdscriptfile());
+
if (!pop_cmdscriptfile())
break;
+
goto check_script;
} else {
prompt_ctx = PROXPROMPT_CTX_SCRIPTFILE;
From 43b5ba4ae2eeb1e05dede8b1c94fd596c6440058 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 17:05:33 +0200
Subject: [PATCH 007/527] chg: enabled param to swap modulation to test
---
client/luascripts/test_t55x7.lua | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/client/luascripts/test_t55x7.lua b/client/luascripts/test_t55x7.lua
index b92375520..f6e0e1ca2 100644
--- a/client/luascripts/test_t55x7.lua
+++ b/client/luascripts/test_t55x7.lua
@@ -9,7 +9,7 @@ local floor = math.floor
copyright = ''
author = "Iceman"
-version = 'v1.0.2'
+version = 'v1.0.3'
desc =[[
This script will program a T55x7 TAG with a configuration and four blocks of data.
It will then try to detect and read back those block data and compare if read data matches the expected data.
@@ -31,12 +31,17 @@ testsuit for T55XX commands demodulation
]]
example = [[
1. script run test_t55x7
+ 2. script run test_t55x7 -t FSK2A
+ 3. script run test_t55x7 -t PSK1
]]
usage = [[
-script run test_t55x7 [-h]
+script run test_t55x7 [-h] [-t
]]
arguments = [[
-h this help
+ -t (optional, defaults to ASK) 'PSK1', 'PSK2', 'PSK3',
+ 'FSK1', 'FSK2', 'FSK1A', 'FSK2A',
+ 'ASK', 'BI'
]]
local DEBUG = true -- the debug flag
@@ -303,9 +308,11 @@ local function main(args)
print( string.rep('--',20) )
print( string.rep('--',20) )
+ local modulation_type = 'ASK'
-- Arguments for the script
- for o, arg in getopt.getopt(args, 'h') do
+ for o, arg in getopt.getopt(args, 'ht:') do
if o == 'h' then return help() end
+ if o == 't' then modulation_type = arg end
end
core.clearCommandBuffer()
@@ -313,7 +320,8 @@ local function main(args)
-- Adjust this table to set which configurations should be tested
-- local test_modes = { 'PSK1', 'PSK2', 'PSK3', 'FSK1', 'FSK2', 'FSK1A', 'FSK2A', 'ASK', 'BI' }
- local test_modes = { 'ASK' }
+ --local test_modes = { 'PSK1' }
+ local test_modes = { modulation_type }
for _ = 1, #test_modes do
res = WipeCard()
From 94e1a9e680b180be8006b6a7d69825ac7b647c5b Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 15 May 2020 17:37:22 +0200
Subject: [PATCH 008/527] Add mf_nonce_brute to main makefile
---
Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 1da96fa2e..2ba15fb0c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ ifneq (,$(DESTDIR))
endif
endif
-all clean install uninstall: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% fpga_compress/%
+all clean install uninstall: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% fpga_compress/%
INSTALLTOOLS=pm3_eml2lower.sh pm3_eml2upper.sh pm3_mfdread.py pm3_mfd2eml.py pm3_eml2mfd.py findbits.py rfidtest.pl xorcheck.py
INSTALLSIMFW=sim011.bin sim011.sha512.txt
@@ -84,6 +84,9 @@ mfkey/%: FORCE
nonce2key/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@) DESTDIR=$(MYDESTDIR)
+mf_nonce_brute/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C tools/mf_nonce_brute $(patsubst mf_nonce_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
fpga_compress/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/fpga_compress $(patsubst fpga_compress/%,%,$@) DESTDIR=$(MYDESTDIR)
@@ -103,7 +106,7 @@ recovery/%: FORCE cleanifplatformchanged
$(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
-.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key style checks FORCE udev accessrights cleanifplatformchanged
+.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute style checks FORCE udev accessrights cleanifplatformchanged
help:
@echo "Multi-OS Makefile"
@@ -122,6 +125,7 @@ help:
@echo "+ client - Make only the OS-specific host client"
@echo "+ mfkey - Make tools/mfkey"
@echo "+ nonce2key - Make tools/nonce2key"
+ @echo "+ mf_nonce_brute - Make tools/mf_nonce_brute"
@echo "+ fpga_compress - Make tools/fpga_compress"
@echo
@echo "+ style - Apply some automated source code formatting rules"
@@ -152,6 +156,8 @@ mfkey: mfkey/all
nonce2key: nonce2key/all
+mf_nonce_brute: mf_nonce_brute/all
+
fpga_compress: fpga_compress/all
newtarbin:
From 5984e1c03ed0dcf9741c28e6c87c42c2235ede97 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 15 May 2020 17:40:59 +0200
Subject: [PATCH 009/527] makefiles: allow to skip pthread (for termux)
---
client/Makefile | 5 ++++-
tools/mf_nonce_brute/Makefile | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index 54fa3af2c..ad2f5aa75 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -22,7 +22,10 @@ vpath %.dic dictionaries
OBJDIR = obj
LDLIBS ?= -L/usr/local/lib
-LDLIBS += -lreadline -lpthread -lm
+LDLIBS += -lreadline -lm
+ifneq ($(SKIPPTHREAD),1)
+LDLIBS += -lpthread
+endif
# RPi Zero gcc requires -latomic
# but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
diff --git a/tools/mf_nonce_brute/Makefile b/tools/mf_nonce_brute/Makefile
index 7672c89a4..cf565e72c 100644
--- a/tools/mf_nonce_brute/Makefile
+++ b/tools/mf_nonce_brute/Makefile
@@ -3,7 +3,10 @@ MYSRCS = crypto1.c crapto1.c bucketsort.c iso14443crc.c sleep.c
MYINCLUDES = -I../../include -I../../common
MYCFLAGS =
MYDEFS =
-MYLDLIBS = -lpthread
+MYLDLIBS =
+ifneq ($(SKIPPTHREAD),1)
+MYLDLIBS += -lpthread
+endif
BINS = mf_nonce_brute
INSTALLTOOLS = $(BINS)
From 39258fa5c5d5da7ce4172cc5ee29552164773b80 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 18:00:06 +0200
Subject: [PATCH 010/527] revert...
---
client/src/proxmark3.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index c8d70cb0d..abf014e08 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -241,8 +241,6 @@ check_script:
// read script file
if (fgets(script_cmd_buf, sizeof(script_cmd_buf), current_cmdscriptfile()) == NULL) {
- PrintAndLogEx(ERR, "Unexpected end, [%s]", current_cmdscriptfile());
-
if (!pop_cmdscriptfile())
break;
From c8e281cb6bb5a327a86e9464930cc6e33de7ee5f Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Fri, 15 May 2020 18:06:06 +0200
Subject: [PATCH 011/527] fix: ok text for iclass loclass test adjusted
---
pm3test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pm3test.sh b/pm3test.sh
index f96285e7e..5b91c0bdc 100755
--- a/pm3test.sh
+++ b/pm3test.sh
@@ -136,7 +136,7 @@ while true; do
if ! CheckExecute "hf iclass test" "$PM3BIN -c 'hf iclass loclass t l'" "verified ok"; then break; fi
if ! CheckExecute "emv test" "$PM3BIN -c 'emv test -l'" "Test(s) \[ OK"; then break; fi
else
- if ! CheckExecute "hf iclass test" "$PM3BIN -c 'hf iclass loclass t'" "OK!"; then break; fi
+ if ! CheckExecute "hf iclass test" "$PM3BIN -c 'hf iclass loclass t'" "key diversification (ok)"; then break; fi
if ! CheckExecute "emv test" "$PM3BIN -c 'emv test'" "Test(s) \[ OK"; then break; fi
fi
From 4edea34b6b72a1d27289d7b5325077e0a560799c Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 16 May 2020 14:24:21 +0200
Subject: [PATCH 012/527] pm3 script for linux: alternative if udevadm is not
available (termux)
---
pm3 | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/pm3 b/pm3
index 4af441c40..82e794d42 100755
--- a/pm3
+++ b/pm3
@@ -31,10 +31,19 @@ function get_pm3_list_Linux {
N=$1
PM3LIST=()
for DEV in $(find /dev/ttyACM* 2>/dev/null); do
- if udevadm info -q property -n "$DEV" | grep -q "ID_VENDOR=proxmark.org"; then
- PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
- return
+ if which udevadm >/dev/null; then
+ if udevadm info -q property -n "$DEV" | grep -q "ID_VENDOR=proxmark.org"; then
+ PM3LIST+=("$DEV")
+ if [ ${#PM3LIST[*]} -ge $N ]; then
+ return
+ fi
+ fi
+ else
+ if grep -q "PRODUCT=9ac4/4b8f" "/sys/class/tty/${DEV#/dev/}/../../uevent" 2>/dev/null; then
+ PM3LIST+=("$DEV")
+ if [ ${#PM3LIST[*]} -ge $N ]; then
+ return
+ fi
fi
fi
done
From eb7957d9942a0bac191c1092b89c7a422de2d919 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 16 May 2020 14:50:43 +0200
Subject: [PATCH 013/527] Add mf_nonce_brute in pm3test
---
pm3test.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pm3test.sh b/pm3test.sh
index 5b91c0bdc..b65f94a15 100755
--- a/pm3test.sh
+++ b/pm3test.sh
@@ -151,6 +151,9 @@ while true; do
if ! CheckExecute "findbits test" "tools/findbits.py 73 0110010101110011" "Match at bit 9: 011001010"; then break; fi
if ! CheckExecute "findbits_test test" "tools/findbits_test.py 2>&1" "OK"; then break; fi
if ! CheckExecute "pm3_eml_mfd test" "tools/pm3_eml_mfd_test.py 2>&1" "OK"; then break; fi
+ if $SLOWTESTS; then
+ if ! CheckExecute "mf_nonce_brute test" "tools/mf_nonce_brute/mf_nonce_brute 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a" "Key.*: \[ffffffffffff\]"; then break; fi
+ fi
fi
printf "\n${C_GREEN}Tests [OK]${C_NC}\n\n"
From bca9326684b29d9c8b3a37398c48c30305c8efce Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 16 May 2020 14:55:33 +0200
Subject: [PATCH 014/527] Document SKIPPTHREAD
---
doc/md/Development/Maintainers.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 705d97707..85fcf8963 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -65,6 +65,10 @@ If you're cross-compiling, these ones might be useful:
* `make client SKIPREVENGTEST=1` to skip compilation and execution of a consistency test for reveng, which can be problematic in case of cross-compilation
* `make client cpu_arch=generic` to skip Intel specialized hardnested components, which is required e.g. if cross-compilation host is Intel but not the target
+On some architectures, pthread library is not present:
+
+* `make client SKIPPTHREAD=1` to skip `-lpthread` at linker stage.
+
`make install` is actually triggering the following individual targets which can be accessed individually:
* `make client/install`
From bc767f167f179c396c772a83392245423b8ffac6 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 16 May 2020 15:58:24 +0200
Subject: [PATCH 015/527] pm3 without udev: change detection routine
---
pm3 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pm3 b/pm3
index 82e794d42..ddcaa14ee 100755
--- a/pm3
+++ b/pm3
@@ -39,7 +39,7 @@ function get_pm3_list_Linux {
fi
fi
else
- if grep -q "PRODUCT=9ac4/4b8f" "/sys/class/tty/${DEV#/dev/}/../../uevent" 2>/dev/null; then
+ if grep -q "proxmark.org" "/sys/class/tty/${DEV#/dev/}/../../../manufacturer" 2>/dev/null; then
PM3LIST+=("$DEV")
if [ ${#PM3LIST[*]} -ge $N ]; then
return
From be1659b1bf99da52e56d2bdf6f26e3b4c0094012 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 17 May 2020 12:06:39 +0200
Subject: [PATCH 016/527] pm3: textual and --list with no device, exit 1
---
pm3 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pm3 b/pm3
index ddcaa14ee..c9c616352 100755
--- a/pm3
+++ b/pm3
@@ -338,7 +338,7 @@ done
if [ "$1" == "--list" ]; then
shift
if [ "$1" != "" ]; then
- echo "Option --list must be used alone"
+ echo "[!!] Option --list must be used alone"
exit 1
fi
SHOWLIST=true
@@ -352,7 +352,7 @@ if [ "$1" == "-n" ]; then
N=$1
shift
else
- echo "Option -n requires a number between 1 and 9, got \"$1\""
+ echo "[!!] Option -n requires a number between 1 and 9, got \"$1\""
exit 1
fi
fi
@@ -363,7 +363,7 @@ if [ "$HOSTOS" = "LINUX" ]; then
# Test presence of wmic
wmic.exe computersystem get name >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo "[!] Cannot run wmic.exe, are you sure your WSL is authorized to run Windows processes? (cf WSL interop flag)"
+ echo "[!!] Cannot run wmic.exe, are you sure your WSL is authorized to run Windows processes? (cf WSL interop flag)"
exit 1
fi
GETPM3LIST=get_pm3_list_WSL
@@ -384,7 +384,7 @@ if $SHOWLIST; then
$GETPM3LIST 9
if [ ${#PM3LIST} -lt 1 ]; then
echo "[!!] No port found"
- exit 0
+ exit 1
fi
n=1
for DEV in ${PM3LIST[@]}
From e3180be45c1a4e5d3426c3fce1d2086cc2364021 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 17 May 2020 12:12:13 +0200
Subject: [PATCH 017/527] pm3: err msgs on stderr
---
pm3 | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/pm3 b/pm3
index c9c616352..5509d1087 100755
--- a/pm3
+++ b/pm3
@@ -148,7 +148,7 @@ function get_pm3_list_WSL {
if [ -e "$DEV" ]; then
PM3LIST+=("$DEV")
if [ ! -w "$DEV" ]; then
- echo "[!!] Let's give users read/write access to $DEV"
+ echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
if [ ${#PM3LIST[*]} -ge $N ]; then
@@ -167,7 +167,7 @@ function get_pm3_list_WSL {
if [ -e "$DEV" ]; then
PM3LIST+=("$DEV")
if [ ! -w "$DEV" ]; then
- echo "[!!] Let's give users read/write access to $DEV"
+ echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
if [ ${#PM3LIST[*]} -ge $N ]; then
@@ -185,7 +185,7 @@ function get_pm3_list_WSL {
if [ -e "$DEV" ]; then
PM3LIST+=("$DEV")
if [ ! -w "$DEV" ]; then
- echo "[!!] Let's give users read/write access to $DEV"
+ echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
if [ ${#PM3LIST[*]} -ge $N ]; then
@@ -319,7 +319,7 @@ Usage:
EOF
}
else
- echo "[!!] Script ran under unknown name, abort: $SCRIPT"
+ echo >&2 "[!!] Script ran under unknown name, abort: $SCRIPT"
exit 1
fi
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
@@ -338,7 +338,7 @@ done
if [ "$1" == "--list" ]; then
shift
if [ "$1" != "" ]; then
- echo "[!!] Option --list must be used alone"
+ echo >&2 "[!!] Option --list must be used alone"
exit 1
fi
SHOWLIST=true
@@ -352,7 +352,7 @@ if [ "$1" == "-n" ]; then
N=$1
shift
else
- echo "[!!] Option -n requires a number between 1 and 9, got \"$1\""
+ echo >&2 "[!!] Option -n requires a number between 1 and 9, got \"$1\""
exit 1
fi
fi
@@ -363,7 +363,7 @@ if [ "$HOSTOS" = "LINUX" ]; then
# Test presence of wmic
wmic.exe computersystem get name >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo "[!!] Cannot run wmic.exe, are you sure your WSL is authorized to run Windows processes? (cf WSL interop flag)"
+ echo >&2 "[!!] Cannot run wmic.exe, are you sure your WSL is authorized to run Windows processes? (cf WSL interop flag)"
exit 1
fi
GETPM3LIST=get_pm3_list_WSL
@@ -375,7 +375,7 @@ elif [ "$HOSTOS" = "DARWIN" ]; then
elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then
GETPM3LIST=get_pm3_list_Windows
else
- echo "[!!] Host OS not recognized, abort: $HOSTOS"
+ echo >&2 "[!!] Host OS not recognized, abort: $HOSTOS"
exit 1
fi
@@ -383,7 +383,7 @@ if $SHOWLIST; then
# Probe for up to 9 devs
$GETPM3LIST 9
if [ ${#PM3LIST} -lt 1 ]; then
- echo "[!!] No port found"
+ echo >&2 "[!!] No port found"
exit 1
fi
n=1
@@ -409,7 +409,7 @@ while true; do
done
if [ ${#PM3LIST} -lt $N ]; then
- echo "[!!] No port found, abort"
+ echo >&2 "[!!] No port found, abort"
exit 1
fi
From 227c4e89bd6581bc08cb7cf3d823e3a60af9d385 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 17 May 2020 12:23:03 +0200
Subject: [PATCH 018/527] pm3: shellcheck
---
pm3 | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/pm3 b/pm3
index 5509d1087..19399f0bd 100755
--- a/pm3
+++ b/pm3
@@ -34,14 +34,14 @@ function get_pm3_list_Linux {
if which udevadm >/dev/null; then
if udevadm info -q property -n "$DEV" | grep -q "ID_VENDOR=proxmark.org"; then
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
else
if grep -q "proxmark.org" "/sys/class/tty/${DEV#/dev/}/../../../manufacturer" 2>/dev/null; then
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -52,7 +52,7 @@ function get_pm3_list_Linux {
for DEV in $(find /dev/ttyUSB* 2>/dev/null); do
if udevadm info -q property -n "$DEV" | grep -q "ID_MODEL=CP2104_USB_to_UART_Bridge_Controller"; then
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -67,7 +67,7 @@ function get_pm3_list_Linux {
# check which are Proxmark3 and, side-effect, if they're actually present
if hcitool name "$MAC" | grep -q "PM3"; then
PM3LIST+=("/dev/$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -75,7 +75,6 @@ function get_pm3_list_Linux {
fi
if $FINDBTDIRECT; then
# check if the MAC of a Proxmark3 was registered in the known devices
- MACS=()
for MAC in $(dbus-send --system --print-reply --type=method_call --dest='org.bluez' '/' org.freedesktop.DBus.ObjectManager.GetManagedObjects 2>/dev/null|\
awk '/"Address"/{getline;gsub(/"/,"",$3);a=$3}/Name/{getline;if (/PM3_RDV4/) print a}'); do
PM3LIST+=("bt:$MAC")
@@ -91,7 +90,7 @@ function get_pm3_list_macOS {
$2=="USB Vendor Name"{b=($4=="proxmark.org")}
b==1 && $2=="IODialinDevice"{print $4}'); do
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
done
@@ -106,7 +105,7 @@ function get_pm3_list_Windows {
for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Caption -like 'Standard Serial over Bluetooth link (COM*' | Select Name" 2> /dev/null | awk '$0 ~ /COM/{print substr($6,2,4)}'); do
DEV=${DEV/ */}
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
done
@@ -116,7 +115,7 @@ function get_pm3_list_Windows {
for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_9AC4&PID_4B8F*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do
DEV=${DEV/ */}
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
done
@@ -126,7 +125,7 @@ function get_pm3_list_Windows {
for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_10C4&PID_EA60*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do
DEV=${DEV/ */}
PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
done
@@ -151,7 +150,7 @@ function get_pm3_list_WSL {
echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -170,7 +169,7 @@ function get_pm3_list_WSL {
echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -188,7 +187,7 @@ function get_pm3_list_WSL {
echo "[!] Let's give users read/write access to $DEV"
sudo chmod 666 "$DEV"
fi
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
return
fi
fi
@@ -235,7 +234,7 @@ elif [ "$SCRIPT" = "pm3-flash" ]; then
fi
shift;
done
- $CLIENT ${ARGS[@]};
+ $CLIENT "${ARGS[@]}";
}
HELP() {
cat << EOF
@@ -361,8 +360,7 @@ HOSTOS=$(uname | awk '{print toupper($0)}')
if [ "$HOSTOS" = "LINUX" ]; then
if uname -a|grep -q Microsoft; then
# Test presence of wmic
- wmic.exe computersystem get name >/dev/null 2>&1
- if [ $? -ne 0 ]; then
+ if ! wmic.exe computersystem get name >/dev/null 2>&1; then
echo >&2 "[!!] Cannot run wmic.exe, are you sure your WSL is authorized to run Windows processes? (cf WSL interop flag)"
exit 1
fi
@@ -387,7 +385,7 @@ if $SHOWLIST; then
exit 1
fi
n=1
- for DEV in ${PM3LIST[@]}
+ for DEV in "${PM3LIST[@]}"
do
echo "$n: $DEV"
n=$((n+1))
@@ -396,19 +394,19 @@ if $SHOWLIST; then
fi
# Wait till we get at least N proxmark3 devices
-$GETPM3LIST $N
-if [ ${#PM3LIST} -lt $N ]; then
+$GETPM3LIST "$N"
+if [ ${#PM3LIST} -lt "$N" ]; then
echo >&2 "[=] Waiting for Proxmark3 to appear..."
fi
while true; do
- if [ ${#PM3LIST[*]} -ge $N ]; then
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
break
fi
sleep .1
- $GETPM3LIST $N
+ $GETPM3LIST "$N"
done
-if [ ${#PM3LIST} -lt $N ]; then
+if [ ${#PM3LIST} -lt "$N" ]; then
echo >&2 "[!!] No port found, abort"
exit 1
fi
From 35ec13e7af77d09552913a3b4d2a74f44af74f5e Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 17 May 2020 12:35:12 +0200
Subject: [PATCH 019/527] pm3tests shellcheck
---
pm3test.sh | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/pm3test.sh b/pm3test.sh
index b65f94a15..bf58b028c 100755
--- a/pm3test.sh
+++ b/pm3test.sh
@@ -32,7 +32,7 @@ function CheckFileExist() {
return 0
fi
- if ls $2 1> /dev/null 2>&1; then
+ if ls "$2" 1> /dev/null 2>&1; then
echo -e "$1 ${C_GREEN}[OK]${C_NC}"
return 0
fi
@@ -44,7 +44,7 @@ function CheckFileExist() {
# title, command line, check result, repeat several times if failed, ignore if fail
function CheckExecute() {
- if [ $4 ]; then
+ if [ "$4" ]; then
local RETRY="1 2 3 e"
else
local RETRY="e"
@@ -61,7 +61,7 @@ function CheckExecute() {
done
- if [ $5 ]; then
+ if [ "$5" ]; then
echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}"
return 0
fi
@@ -71,11 +71,11 @@ function CheckExecute() {
return 1
}
-printf "\n${C_BLUE}RRG/Iceman Proxmark3 test tool ${C_NC}\n\n"
+echo -e "\n${C_BLUE}RRG/Iceman Proxmark3 test tool ${C_NC}\n"
-printf "work directory: "
+echo -n "work directory: "
pwd
-printf "client ${PM3BIN:="./client/proxmark3"}\n"
+echo "client ${PM3BIN:="./client/proxmark3"}"
if [ "$TRAVIS_COMMIT" ]; then
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
@@ -85,16 +85,16 @@ if [ "$TRAVIS_COMMIT" ]; then
fi
fi
-printf "git branch: "
+echo -n "git branch: "
git describe --all
-printf "git sha: "
+echo -n "git sha: "
git rev-parse HEAD
echo ""
while true; do
- printf "\n${C_BLUE}Testing files:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing files:${C_NC}"
if ! CheckFileExist "proxmark3 exists" "$PM3BIN"; then break; fi
- if ! CheckFileExist "hardnested tables exists" "./client/resources/hardnested_tables/*.z"; then break; fi
+ if ! CheckFileExist "hardnested tables exists" "./client/resources/hardnested_tables/bitflip_0_001_states.bin.z"; then break; fi
if ! CheckFileExist "simmodule fw file exists" "./tools/simmodule/sim011.bin"; then break; fi
if $TESTDEVICE; then
@@ -102,19 +102,19 @@ while true; do
if ! CheckFileExist "bootrom exists" "./bootrom/obj/bootrom.elf"; then break; fi
fi
- printf "\n${C_BLUE}Testing basic help:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing basic help:${C_NC}"
if ! CheckExecute "proxmark help" "$PM3BIN -h" "wait"; then break; fi
if ! CheckExecute "proxmark help text ISO7816" "$PM3BIN -t 2>&1" "ISO7816"; then break; fi
if ! CheckExecute "proxmark help text hardnested" "$PM3BIN -t 2>&1" "hardnested"; then break; fi
- printf "\n${C_BLUE}Testing data manipulation:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing data manipulation:${C_NC}"
if ! CheckExecute "reveng readline test" "$PM3BIN -c 'reveng -h;reveng -D'" "CRC-64/GO-ISO"; then break; fi
if ! CheckExecute "reveng -g test" "$PM3BIN -c 'reveng -g abda202c'" "CRC-16/ISO-IEC-14443-3-A"; then break; fi
if ! CheckExecute "reveng -w test" "$PM3BIN -c 'reveng -w 8 -s 01020304e3 010204039d'" "CRC-8/SMBUS"; then break; fi
if ! CheckExecute "mfu pwdgen test" "$PM3BIN -c 'hf mfu pwdgen t'" "Selftest OK"; then break; fi
if ! CheckExecute "trace load/list test" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list 1;'" "READBLOCK(8)"; then break; fi
- printf "\n${C_BLUE}Testing LF:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing LF:${C_NC}"
if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
if ! CheckExecute "lf EM410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
if ! CheckExecute "lf VISA2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
@@ -129,7 +129,7 @@ while true; do
if ! CheckExecute "lf FDX-B test" "$PM3BIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
if ! CheckExecute "lf INDALA test" "$PM3BIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
- printf "\n${C_BLUE}Testing HF:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing HF:${C_NC}"
if ! CheckExecute "hf mf offline text" "$PM3BIN -c 'hf mf'" "at_enc"; then break; fi
if $SLOWTESTS; then
if ! CheckExecute "hf mf hardnested test" "$PM3BIN -c 'hf mf hardnested t 1 000000000000'" "found:" "repeat" "ignore"; then break; fi
@@ -141,7 +141,7 @@ while true; do
fi
if $TESTTOOLS; then
- printf "\n${C_BLUE}Testing tools:${C_NC}\n"
+ echo -e "\n${C_BLUE}Testing tools:${C_NC}"
# Need a decent example for mfkey32...
if ! CheckExecute "mfkey32v2 test" "tools/mfkey/mfkey32v2 12345678 1AD8DF2B 1D316024 620EF048 30D6CB07 C52077E2 837AC61A" "Found Key: \[a0a1a2a3a4a5\]"; then break; fi
if ! CheckExecute "mfkey64 test" "tools/mfkey/mfkey64 9c599b32 82a4166c a1e458ce 6eea41e0 5cadf439" "Found Key: \[ffffffffffff\]"; then break; fi
@@ -156,9 +156,9 @@ while true; do
fi
fi
- printf "\n${C_GREEN}Tests [OK]${C_NC}\n\n"
+ echo -e "\n${C_GREEN}Tests [OK]${C_NC}\n"
exit 0
done
-printf "\n${C_RED}Tests [FAIL]${C_NC}\n\n"
+echo -e "\n${C_RED}Tests [FAIL]${C_NC}\n"
exit 1
From 2ed5f1f6149b5ec79e3dc3d0b5586e4d6225fc2d Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 17 May 2020 14:18:52 +0200
Subject: [PATCH 020/527] iclass bf: avoid slowdown
---
client/src/loclass/ikeys.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/client/src/loclass/ikeys.c b/client/src/loclass/ikeys.c
index d828583d7..f50d276dc 100644
--- a/client/src/loclass/ikeys.c
+++ b/client/src/loclass/ikeys.c
@@ -224,6 +224,8 @@ static void permute(BitstreamIn *p_in, uint64_t z, int l, int r, BitstreamOut *o
}
static void printState(const char *desc, uint64_t c) {
+ if (g_debugMode == 0)
+ return;
char s[60] = {0};
snprintf(s, sizeof(s), "%s : ", desc);
From 11f02967bcae43f27912e1266e1c82db399268ea Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 18 May 2020 01:05:49 +0200
Subject: [PATCH 021/527] pm3: test access to /dev/ttyXXX files as prerequisite
for linux
---
pm3 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pm3 b/pm3
index 19399f0bd..7d2c5e5f7 100755
--- a/pm3
+++ b/pm3
@@ -30,6 +30,10 @@ SHOWLIST=false
function get_pm3_list_Linux {
N=$1
PM3LIST=()
+ if [ ! -c "/dev/tty0" ]; then
+ echo >&2 "[!!] Script cannot access /dev/ttyXXX files, insufficient privileges"
+ exit 1
+ fi
for DEV in $(find /dev/ttyACM* 2>/dev/null); do
if which udevadm >/dev/null; then
if udevadm info -q property -n "$DEV" | grep -q "ID_VENDOR=proxmark.org"; then
From 6d1beb07c186ebdd14dea5ce8a133543527c8978 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 18 May 2020 01:16:29 +0200
Subject: [PATCH 022/527] pm3: attempt to detect BT dongle when udevadm is not
available
---
pm3 | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/pm3 b/pm3
index 7d2c5e5f7..31ed0695b 100755
--- a/pm3
+++ b/pm3
@@ -54,10 +54,19 @@ function get_pm3_list_Linux {
if $FINDBTDONGLE; then
# check if the HC-06-USB white dongle is present (still, that doesn't tell us if it's paired with a Proxmark3...)
for DEV in $(find /dev/ttyUSB* 2>/dev/null); do
- if udevadm info -q property -n "$DEV" | grep -q "ID_MODEL=CP2104_USB_to_UART_Bridge_Controller"; then
- PM3LIST+=("$DEV")
- if [ ${#PM3LIST[*]} -ge "$N" ]; then
- return
+ if which udevadm >/dev/null; then
+ if udevadm info -q property -n "$DEV" | grep -q "ID_MODEL=CP2104_USB_to_UART_Bridge_Controller"; then
+ PM3LIST+=("$DEV")
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
+ return
+ fi
+ fi
+ else
+ if grep -q "DRIVER=cp210x" "/sys/class/tty/${DEV#/dev/}/../../uevent" 2>/dev/null; then
+ PM3LIST+=("$DEV")
+ if [ ${#PM3LIST[*]} -ge "$N" ]; then
+ return
+ fi
fi
fi
done
From 837d644b6cd16253dda76e6fb64dbb5a0235823d Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Mon, 18 May 2020 23:49:45 +0200
Subject: [PATCH 023/527] chg: first attempt for trace log header
---
client/src/cmdtrace.c | 59 +++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 6cbfc2e7a..187ba5a01 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -25,6 +25,16 @@ static int CmdHelp(const char *Cmd);
static uint8_t *g_trace;
long g_traceLen = 0;
+typedef struct {
+ uint32_t timestamp;
+ uint16_t duration;
+ uint16_t data_len;
+ uint8_t frame[];
+} tracelog_hdr_t;
+
+// 4 + 2 + 2
+#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
+
static int usage_trace_list(void) {
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
PrintAndLogEx(NORMAL, "Usage: trace list [f][c| <0|1>");
@@ -120,39 +130,29 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol) {
// sanity check
- if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
+ if (tracepos + TRACELOG_HDR_LEN > traceLen) return traceLen;
+
+ tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
bool isResponse;
- uint16_t data_len, parity_len;
- uint32_t timestamp;
-
- timestamp = *((uint32_t *)(trace + tracepos));
- tracepos += 4;
-
-
- // currently we don't use duration, so we skip it
- tracepos += 2;
-
- data_len = *((uint16_t *)(trace + tracepos));
- tracepos += 2;
-
- if (data_len & 0x8000) {
- data_len &= 0x7fff;
+ uint16_t parity_len;
+
+ if (hdr->data_len & 0x8000) {
+ hdr->data_len &= 0x7fff;
isResponse = true;
} else {
isResponse = false;
}
- parity_len = (data_len - 1) / 8 + 1;
+ parity_len = (hdr->data_len - 1) / 8 + 1;
- if (tracepos + data_len + parity_len > traceLen) {
+ if (sizeof(tracelog_hdr_t) + hdr->data_len + parity_len > traceLen) {
return traceLen;
}
- uint8_t *frame = trace + tracepos;
- tracepos += data_len;
- //currently we don't use parity bytes, so we skip it
- tracepos += parity_len;
- if (data_len == 0) {
+ //set trace position
+ tracepos += sizeof(tracelog_hdr_t) + hdr->data_len + parity_len;
+
+ if (hdr->data_len == 0) {
PrintAndLogEx(NORMAL, "");
return tracepos;
}
@@ -167,25 +167,24 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
* we use format timestamp, newline, offset (0x000000), pseudo header, data
* `text2pcap -t "%S." -l 264 -n `
*/
- char line[(data_len * 3) + 1];
+ char line[(hdr->data_len * 3) + 1];
char *ptr = &line[0];
- for (int j = 0; j < data_len ; j++) {
- ptr += sprintf(ptr, "%02x", frame[j]);
- ptr += sprintf(ptr, " ");
+ for (int i = 0; i < hdr->data_len ; i++) {
+ ptr += sprintf(ptr, "%02x ", hdr->frame[i]);
}
char data_len_str[5];
char temp_str1[3] = {0};
char temp_str2[3] = {0};
-
- sprintf(data_len_str, "%04x", data_len);
+
+ sprintf(data_len_str, "%04x", hdr->data_len);
strncat(temp_str1, data_len_str, 2);
temp_str1[2] = '\0';
strncat(temp_str2, data_len_str + 2, 2);
temp_str2[2] = '\0';
- PrintAndLogEx(NORMAL, "0.%010u", timestamp);
+ PrintAndLogEx(NORMAL, "0.%010u", hdr->timestamp);
PrintAndLogEx(NORMAL, "000000 00 %s %s %s %s",
(isResponse ? "ff" : "fe"),
temp_str1,
From 97c96385187bebd656bf828984d6b09950c0c965 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 00:25:40 +0200
Subject: [PATCH 024/527] next attempt for tracelog. simplify
---
client/src/cmdtrace.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 187ba5a01..6ef3974e2 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -33,7 +33,8 @@ typedef struct {
} tracelog_hdr_t;
// 4 + 2 + 2
-#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
+#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
+#define TRACELOG_NEXT_PARITY_LEN(x) (((x)hdr->data_len - 1) / 8 + 1)
static int usage_trace_list(void) {
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
@@ -81,13 +82,13 @@ static int usage_trace_save(void) {
return PM3_SUCCESS;
}
-static bool is_last_record(uint16_t tracepos, uint8_t *trace, uint16_t traceLen) {
- return (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) >= traceLen);
+static bool is_last_record(uint16_t tracepos, uint16_t traceLen) {
+ return ((tracepos + TRACELOG_HDR_LEN) >= traceLen);
}
static bool next_record_is_response(uint16_t tracepos, uint8_t *trace) {
- uint16_t next_records_datalen = *((uint16_t *)(trace + tracepos + sizeof(uint32_t) + sizeof(uint16_t)));
- return ((next_records_datalen & 0x8000) == 0x8000);
+ tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
+ return ((hdr->data_len & 0x8000) == 0x8000);
}
static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t *tracepos, uint16_t traceLen,
@@ -101,22 +102,24 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
memcpy(topaz_reader_command, frame, *data_len);
- while (!is_last_record(*tracepos, trace, traceLen) && !next_record_is_response(*tracepos, trace)) {
- uint32_t next_timestamp = *((uint32_t *)(trace + *tracepos));
- *tracepos += sizeof(uint32_t);
- uint16_t next_duration = *((uint16_t *)(trace + *tracepos));
- *tracepos += sizeof(uint16_t);
- uint16_t next_data_len = *((uint16_t *)(trace + *tracepos)) & 0x7FFF;
- *tracepos += sizeof(uint16_t);
- uint8_t *next_frame = (trace + *tracepos);
- *tracepos += next_data_len;
+ while (!is_last_record(*tracepos, traceLen) && !next_record_is_response(*tracepos, trace)) {
+
+ tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + *tracepos);
+
+ uint32_t next_timestamp = hdr->timestamp;
+ uint16_t next_duration = hdr->duration;
+ uint16_t next_data_len = hdr->data_len & 0x7FFF;
+ uint8_t *next_frame = hdr->frame;
+
+ *tracepos += TRACELOG_HDR_LEN + next_data_len;
+
if ((next_data_len == 1) && (*data_len + next_data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
memcpy(topaz_reader_command + *data_len, next_frame, next_data_len);
*data_len += next_data_len;
last_timestamp = next_timestamp + next_duration;
} else {
// rewind and exit
- *tracepos = *tracepos - next_data_len - sizeof(uint16_t) - sizeof(uint16_t) - sizeof(uint32_t);
+ *tracepos = *tracepos - next_data_len - TRACELOG_HDR_LEN;
break;
}
uint16_t next_parity_len = (next_data_len - 1) / 8 + 1;
@@ -130,19 +133,20 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol) {
// sanity check
- if (tracepos + TRACELOG_HDR_LEN > traceLen) return traceLen;
+ if (is_last_record(tracepos, traceLen)) return traceLen;
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
bool isResponse;
uint16_t parity_len;
- if (hdr->data_len & 0x8000) {
+ if ((hdr->data_len & 0x8000) == 0x8000) {
hdr->data_len &= 0x7fff;
isResponse = true;
} else {
isResponse = false;
}
+
parity_len = (hdr->data_len - 1) / 8 + 1;
if (sizeof(tracelog_hdr_t) + hdr->data_len + parity_len > traceLen) {
@@ -435,7 +439,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
explanation);
}
- if (is_last_record(tracepos, trace, traceLen)) return traceLen;
+ if (is_last_record(tracepos, traceLen)) return traceLen;
if (showWaitCycles && !isResponse && next_record_is_response(tracepos, trace)) {
uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
From d72d8044870599dfe9d1a08b79c1b3b41a7946cd Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 00:36:30 +0200
Subject: [PATCH 025/527] third part fixing cmdtracelog
---
client/src/cmdtrace.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 6ef3974e2..4b923f0a0 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -149,12 +149,12 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
parity_len = (hdr->data_len - 1) / 8 + 1;
- if (sizeof(tracelog_hdr_t) + hdr->data_len + parity_len > traceLen) {
+ if (TRACELOG_HDR_LEN + hdr->data_len + parity_len > traceLen) {
return traceLen;
}
//set trace position
- tracepos += sizeof(tracelog_hdr_t) + hdr->data_len + parity_len;
+ tracepos += TRACELOG_HDR_LEN + hdr->data_len + parity_len;
if (hdr->data_len == 0) {
PrintAndLogEx(NORMAL, "");
@@ -208,7 +208,7 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol, bool showWaitCycles, bool markCRCBytes) {
// sanity check
- if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
+ if (is_last_record(tracepos, traceLen)) return traceLen;
bool isResponse;
uint16_t data_len, parity_len;
@@ -218,16 +218,14 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
uint8_t mfData[32] = {0};
size_t mfDataLen = 0;
+ tracelog_hdr_t *first_hdr = (tracelog_hdr_t *)(trace);
+ tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
- first_timestamp = *((uint32_t *)(trace));
- timestamp = *((uint32_t *)(trace + tracepos));
- tracepos += 4;
-
- duration = *((uint16_t *)(trace + tracepos));
- tracepos += 2;
-
- data_len = *((uint16_t *)(trace + tracepos));
- tracepos += 2;
+ first_timestamp = first_hdr->timestamp;
+
+ timestamp = hdr->timestamp;
+ duration = hdr->duration;
+ data_len = hdr->data_len;
if (data_len & 0x8000) {
data_len &= 0x7fff;
@@ -237,13 +235,14 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
}
parity_len = (data_len - 1) / 8 + 1;
- if (tracepos + data_len + parity_len > traceLen) {
+ if (tracepos + TRACELOG_HDR_LEN + data_len + parity_len > traceLen) {
return traceLen;
}
- uint8_t *frame = trace + tracepos;
- tracepos += data_len;
- uint8_t *parityBytes = trace + tracepos;
- tracepos += parity_len;
+
+ uint8_t *frame = hdr->frame;
+ uint8_t *parityBytes = hdr->frame + data_len;
+
+ tracepos += TRACELOG_HDR_LEN + data_len + parity_len;
if (protocol == TOPAZ && !isResponse) {
// topaz reader commands come in 1 or 9 separate frames with 7 or 8 Bits each.
From 00bde060c1b67e4067ff1602f116a4afc49dd78d Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 00:40:22 +0200
Subject: [PATCH 026/527] fourth, making struct packed
---
client/src/cmdtrace.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 4b923f0a0..1cf8c054e 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -30,7 +30,7 @@ typedef struct {
uint16_t duration;
uint16_t data_len;
uint8_t frame[];
-} tracelog_hdr_t;
+} PACKED tracelog_hdr_t;
// 4 + 2 + 2
#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
@@ -441,6 +441,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (is_last_record(tracepos, traceLen)) return traceLen;
if (showWaitCycles && !isResponse && next_record_is_response(tracepos, trace)) {
+
uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
(EndOfTransmissionTimestamp - first_timestamp),
From e46639ee60710eef79479165c319976e6a9bafb3 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 00:46:10 +0200
Subject: [PATCH 027/527] fifth adjustment to tracelog
---
client/src/cmdtrace.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 1cf8c054e..5cb61fdf0 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -297,9 +297,14 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
//1 CRC-command, CRC ok
//2 Not crc-command
- //--- Draw the data column
+ //--- Draw the data column
char line[18][120] = {{0}};
+ if (data_len == 0) {
+ sprintf(line[0], "");
+ return tracepos;
+ }
+
for (int j = 0; j < data_len && j / 18 < 18; j++) {
uint8_t parityBits = parityBytes[j >> 3];
@@ -345,11 +350,6 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
}
}
- if (data_len == 0) {
- sprintf(line[0], "");
- return tracepos;
- }
-
// Draw the CRC column
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
@@ -442,7 +442,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (showWaitCycles && !isResponse && next_record_is_response(tracepos, trace)) {
- uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
+ tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
+
+ uint32_t next_timestamp = next_hdr->timestamp;
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
(EndOfTransmissionTimestamp - first_timestamp),
(next_timestamp - first_timestamp),
From afafdce3c92f91d79e3f26182bc8ba041eb43825 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 00:52:11 +0200
Subject: [PATCH 028/527] test for hex output / wireshark
---
pm3test.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pm3test.sh b/pm3test.sh
index bf58b028c..27a7619b8 100755
--- a/pm3test.sh
+++ b/pm3test.sh
@@ -112,7 +112,8 @@ while true; do
if ! CheckExecute "reveng -g test" "$PM3BIN -c 'reveng -g abda202c'" "CRC-16/ISO-IEC-14443-3-A"; then break; fi
if ! CheckExecute "reveng -w test" "$PM3BIN -c 'reveng -w 8 -s 01020304e3 010204039d'" "CRC-8/SMBUS"; then break; fi
if ! CheckExecute "mfu pwdgen test" "$PM3BIN -c 'hf mfu pwdgen t'" "Selftest OK"; then break; fi
- if ! CheckExecute "trace load/list test" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list 1;'" "READBLOCK(8)"; then break; fi
+ if ! CheckExecute "trace load/list 14a" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list 1;'" "READBLOCK(8)"; then break; fi
+ if ! CheckExecute "trace load/list x" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list x 1;'" "0.0101840425"; then break; fi
echo -e "\n${C_BLUE}Testing LF:${C_NC}"
if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
From 2ba350903a92c6e27b7d7ba389af52904e81b1cb Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 02:14:43 +0200
Subject: [PATCH 029/527] more tracelog rework
---
client/src/cmdtrace.c | 115 ++++++++++++++----------------------------
include/pm3_cmd.h | 14 +++++
2 files changed, 51 insertions(+), 78 deletions(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 5cb61fdf0..43d84c3f3 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -18,6 +18,7 @@
#include "comms.h" // for sending cmds to device. GetFromBigBuf
#include "fileutils.h" // for saveFile
#include "cmdlfhitag.h" // annotate hitag
+#include "pm3_cmd.h" // tracelog_hdr_t
static int CmdHelp(const char *Cmd);
@@ -25,17 +26,6 @@ static int CmdHelp(const char *Cmd);
static uint8_t *g_trace;
long g_traceLen = 0;
-typedef struct {
- uint32_t timestamp;
- uint16_t duration;
- uint16_t data_len;
- uint8_t frame[];
-} PACKED tracelog_hdr_t;
-
-// 4 + 2 + 2
-#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
-#define TRACELOG_NEXT_PARITY_LEN(x) (((x)hdr->data_len - 1) / 8 + 1)
-
static int usage_trace_list(void) {
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
PrintAndLogEx(NORMAL, "Usage: trace list [f][c| <0|1>");
@@ -88,7 +78,7 @@ static bool is_last_record(uint16_t tracepos, uint16_t traceLen) {
static bool next_record_is_response(uint16_t tracepos, uint8_t *trace) {
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
- return ((hdr->data_len & 0x8000) == 0x8000);
+ return (hdr->isResponse);
}
static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t *tracepos, uint16_t traceLen,
@@ -106,24 +96,18 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + *tracepos);
- uint32_t next_timestamp = hdr->timestamp;
- uint16_t next_duration = hdr->duration;
- uint16_t next_data_len = hdr->data_len & 0x7FFF;
- uint8_t *next_frame = hdr->frame;
-
- *tracepos += TRACELOG_HDR_LEN + next_data_len;
+ *tracepos += TRACELOG_HDR_LEN + hdr->data_len;
- if ((next_data_len == 1) && (*data_len + next_data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
- memcpy(topaz_reader_command + *data_len, next_frame, next_data_len);
- *data_len += next_data_len;
- last_timestamp = next_timestamp + next_duration;
+ if ((hdr->data_len == 1) && (*data_len + hdr->data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
+ memcpy(topaz_reader_command + *data_len, hdr->frame, hdr->data_len);
+ *data_len += hdr->data_len;
+ last_timestamp = hdr->timestamp + hdr->duration;
} else {
// rewind and exit
- *tracepos = *tracepos - next_data_len - TRACELOG_HDR_LEN;
+ *tracepos = *tracepos - hdr->data_len - TRACELOG_HDR_LEN;
break;
}
- uint16_t next_parity_len = (next_data_len - 1) / 8 + 1;
- *tracepos += next_parity_len;
+ *tracepos += TRACELOG_PARITY_LEN(hdr);
}
*duration = last_timestamp - timestamp;
@@ -137,24 +121,12 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
- bool isResponse;
- uint16_t parity_len;
-
- if ((hdr->data_len & 0x8000) == 0x8000) {
- hdr->data_len &= 0x7fff;
- isResponse = true;
- } else {
- isResponse = false;
- }
-
- parity_len = (hdr->data_len - 1) / 8 + 1;
-
- if (TRACELOG_HDR_LEN + hdr->data_len + parity_len > traceLen) {
+ if (TRACELOG_HDR_LEN + hdr->data_len + TRACELOG_PARITY_LEN(hdr) > traceLen) {
return traceLen;
}
//set trace position
- tracepos += TRACELOG_HDR_LEN + hdr->data_len + parity_len;
+ tracepos += TRACELOG_HDR_LEN + hdr->data_len + TRACELOG_PARITY_LEN(hdr);
if (hdr->data_len == 0) {
PrintAndLogEx(NORMAL, "");
@@ -190,7 +162,7 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
PrintAndLogEx(NORMAL, "0.%010u", hdr->timestamp);
PrintAndLogEx(NORMAL, "000000 00 %s %s %s %s",
- (isResponse ? "ff" : "fe"),
+ (hdr->isResponse ? "ff" : "fe"),
temp_str1,
temp_str2,
line);
@@ -210,44 +182,32 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
// sanity check
if (is_last_record(tracepos, traceLen)) return traceLen;
- bool isResponse;
- uint16_t data_len, parity_len;
- uint32_t duration, timestamp, first_timestamp, EndOfTransmissionTimestamp;
+ uint32_t duration;
+ uint16_t data_len;
+ uint32_t EndOfTransmissionTimestamp;
uint8_t topaz_reader_command[9];
char explanation[40] = {0};
uint8_t mfData[32] = {0};
size_t mfDataLen = 0;
-
tracelog_hdr_t *first_hdr = (tracelog_hdr_t *)(trace);
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + tracepos);
- first_timestamp = first_hdr->timestamp;
-
- timestamp = hdr->timestamp;
duration = hdr->duration;
data_len = hdr->data_len;
- if (data_len & 0x8000) {
- data_len &= 0x7fff;
- isResponse = true;
- } else {
- isResponse = false;
- }
- parity_len = (data_len - 1) / 8 + 1;
-
- if (tracepos + TRACELOG_HDR_LEN + data_len + parity_len > traceLen) {
+ if (tracepos + TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr) > traceLen) {
return traceLen;
}
uint8_t *frame = hdr->frame;
uint8_t *parityBytes = hdr->frame + data_len;
- tracepos += TRACELOG_HDR_LEN + data_len + parity_len;
+ tracepos += TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr);
- if (protocol == TOPAZ && !isResponse) {
+ if (protocol == TOPAZ && !hdr->isResponse) {
// topaz reader commands come in 1 or 9 separate frames with 7 or 8 Bits each.
// merge them:
- if (merge_topaz_reader_frames(timestamp, &duration, &tracepos, traceLen, trace, frame, topaz_reader_command, &data_len)) {
+ if (merge_topaz_reader_frames(hdr->timestamp, &duration, &tracepos, traceLen, trace, frame, topaz_reader_command, &data_len)) {
frame = topaz_reader_command;
}
}
@@ -258,7 +218,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (data_len > 2) {
switch (protocol) {
case ICLASS:
- crcStatus = iclass_CRC_check(isResponse, frame, data_len);
+ crcStatus = iclass_CRC_check(hdr->isResponse, frame, data_len);
break;
case ISO_14443B:
case TOPAZ:
@@ -266,12 +226,12 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
crcStatus = !felica_CRC_check(frame + 2, data_len - 4);
break;
case PROTO_MIFARE:
- crcStatus = mifare_CRC_check(isResponse, frame, data_len);
+ crcStatus = mifare_CRC_check(hdr->isResponse, frame, data_len);
break;
case ISO_14443A:
case MFDES:
case LTO:
- crcStatus = iso14443A_CRC_check(isResponse, frame, data_len);
+ crcStatus = iso14443A_CRC_check(hdr->isResponse, frame, data_len);
break;
case THINFILM:
frame[data_len - 1] ^= frame[data_len - 2];
@@ -319,11 +279,11 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
&& protocol != THINFILM
&& protocol != FELICA
&& protocol != LTO
- && (isResponse || protocol == ISO_14443A)
+ && (hdr->isResponse || protocol == ISO_14443A)
&& (oddparity8(frame[j]) != ((parityBits >> (7 - (j & 0x0007))) & 0x01))) {
snprintf(line[j / 18] + ((j % 18) * 4), 120, "%02x! ", frame[j]);
- } else if (protocol == ICLASS && isResponse == false) {
+ } else if (protocol == ICLASS && hdr->isResponse == false) {
uint8_t parity = 0;
for (int i = 0; i < 6; i++) {
parity ^= ((frame[0] >> i) & 1);
@@ -353,19 +313,19 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
// Draw the CRC column
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
- EndOfTransmissionTimestamp = timestamp + duration;
+ EndOfTransmissionTimestamp = hdr->timestamp + duration;
// Always annotate LEGIC read/tag
if (protocol == LEGIC)
annotateLegic(explanation, sizeof(explanation), frame, data_len);
if (protocol == PROTO_MIFARE)
- annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, parity_len, isResponse);
+ annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, TRACELOG_PARITY_LEN(hdr), hdr->isResponse);
if (protocol == FELICA)
annotateFelica(explanation, sizeof(explanation), frame, data_len);
- if (!isResponse) {
+ if (!hdr->isResponse) {
switch (protocol) {
case ICLASS:
annotateIclass(explanation, sizeof(explanation), frame, data_len);
@@ -412,9 +372,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
for (int j = 0; j < num_lines ; j++) {
if (j == 0) {
PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-72s | %s| %s",
- (timestamp - first_timestamp),
- (EndOfTransmissionTimestamp - first_timestamp),
- (isResponse ? "Tag" : "Rdr"),
+ (hdr->timestamp - first_hdr->timestamp),
+ (EndOfTransmissionTimestamp - first_hdr->timestamp),
+ (hdr->isResponse ? "Tag" : "Rdr"),
line[j],
(j == num_lines - 1) ? crc : " ",
(j == num_lines - 1) ? explanation : "");
@@ -426,12 +386,12 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
}
}
- if (DecodeMifareData(frame, data_len, parityBytes, isResponse, mfData, &mfDataLen)) {
+ if (DecodeMifareData(frame, data_len, parityBytes, hdr->isResponse, mfData, &mfDataLen)) {
memset(explanation, 0x00, sizeof(explanation));
- if (!isResponse) {
+ if (!hdr->isResponse) {
annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen);
}
- uint8_t crcc = iso14443A_CRC_check(isResponse, mfData, mfDataLen);
+ uint8_t crcc = iso14443A_CRC_check(hdr->isResponse, mfData, mfDataLen);
PrintAndLogEx(NORMAL, " | | * |%-72s | %-4s| %s",
sprint_hex_inrow_spaces(mfData, mfDataLen, 2),
(crcc == 0 ? "!crc" : (crcc == 1 ? " ok " : " ")),
@@ -440,16 +400,15 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (is_last_record(tracepos, traceLen)) return traceLen;
- if (showWaitCycles && !isResponse && next_record_is_response(tracepos, trace)) {
+ if (showWaitCycles && !hdr->isResponse && next_record_is_response(tracepos, trace)) {
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
- uint32_t next_timestamp = next_hdr->timestamp;
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
- (EndOfTransmissionTimestamp - first_timestamp),
- (next_timestamp - first_timestamp),
+ (EndOfTransmissionTimestamp - first_hdr->timestamp),
+ (next_hdr->timestamp - first_hdr->timestamp),
" ",
- (next_timestamp - EndOfTransmissionTimestamp));
+ (next_hdr->timestamp - EndOfTransmissionTimestamp));
}
return tracepos;
diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h
index c9125b1aa..b6de6f292 100644
--- a/include/pm3_cmd.h
+++ b/include/pm3_cmd.h
@@ -121,6 +121,20 @@ typedef struct {
int32_t samples_to_skip;
bool verbose;
} PACKED sample_config;
+
+typedef struct {
+ uint32_t timestamp;
+ uint16_t duration;
+ uint16_t data_len : 15;
+ bool isResponse : 1;
+ uint8_t frame[];
+ // data_len bytes of data
+ // ceil(data_len/8) bytes of parity
+} PACKED tracelog_hdr_t;
+
+#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
+#define TRACELOG_PARITY_LEN(x) (((x)->data_len - 1) / 8 + 1)
+
/*
typedef struct {
uint16_t start_gap;
From a999243a451249e376d993e0e348af5d4367b70d Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 02:39:39 +0200
Subject: [PATCH 030/527] use tracelog struct in arm too
---
armsrc/BigBuf.c | 36 ++++++++++--------------------------
1 file changed, 10 insertions(+), 26 deletions(-)
diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c
index 765d230a5..5f1ace5f8 100644
--- a/armsrc/BigBuf.c
+++ b/armsrc/BigBuf.c
@@ -12,6 +12,7 @@
#include "string.h"
#include "dbprint.h"
+#include "pm3_cmd.h"
// BigBuf is the large multi-purpose buffer, typically used to hold A/D samples or traces.
// Also used to hold various smaller buffers and the Mifare Emulator Memory.
@@ -146,40 +147,23 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
if (!tracing) return false;
uint8_t *trace = BigBuf_get_addr();
+ tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + traceLen);
uint32_t num_paritybytes = (iLen - 1) / 8 + 1; // number of valid paritybytes in *parity
- uint32_t duration = timestamp_end - timestamp_start;
// Return when trace is full
- if (traceLen + sizeof(iLen) + sizeof(timestamp_start) + sizeof(duration) + num_paritybytes + iLen >= BigBuf_max_traceLen()) {
+ if (TRACELOG_HDR_LEN + iLen + num_paritybytes >= BigBuf_max_traceLen() - traceLen) {
tracing = false; // don't trace any more
return false;
}
- // Traceformat:
- // 32 bits timestamp (little endian)
- // 16 bits duration (little endian)
- // 16 bits data length (little endian, Highest Bit used as readerToTag flag)
- // y Bytes data
- // x Bytes parity (one byte per 8 bytes data)
-
- // timestamp (start)
- trace[traceLen++] = ((timestamp_start >> 0) & 0xff);
- trace[traceLen++] = ((timestamp_start >> 8) & 0xff);
- trace[traceLen++] = ((timestamp_start >> 16) & 0xff);
- trace[traceLen++] = ((timestamp_start >> 24) & 0xff);
-
- // duration
- trace[traceLen++] = ((duration >> 0) & 0xff);
- trace[traceLen++] = ((duration >> 8) & 0xff);
-
- // data length
- trace[traceLen++] = ((iLen >> 0) & 0xff);
- trace[traceLen++] = ((iLen >> 8) & 0xff);
-
- // readerToTag flag
- if (!readerToTag) {
- trace[traceLen - 1] |= 0x80;
+ if (timestamp_end - timestamp_start > UINT16_MAX) {
+ return false; // duration too long
}
+ hdr->timestamp = timestamp_start;
+ hdr->duration = timestamp_end - timestamp_start;
+ hdr->data_len = iLen;
+ hdr->isResponse = !readerToTag;
+ traceLen += TRACELOG_HDR_LEN;
// data bytes
if (btBytes != NULL && iLen != 0) {
From 23d754c85f6ef5b4dd2246b108b827b007ee4d8d Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 02:48:03 +0200
Subject: [PATCH 031/527] fix max duration in LogTrace
---
armsrc/BigBuf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c
index 5f1ace5f8..8ee7cc189 100644
--- a/armsrc/BigBuf.c
+++ b/armsrc/BigBuf.c
@@ -156,8 +156,8 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
tracing = false; // don't trace any more
return false;
}
- if (timestamp_end - timestamp_start > UINT16_MAX) {
- return false; // duration too long
+ if (timestamp_end - timestamp_start > 0x7FFF) {
+ return false; // duration too long, must be max 15 bits
}
hdr->timestamp = timestamp_start;
hdr->duration = timestamp_end - timestamp_start;
From 966bcc0d2825ae3f411dacb84f8a2f08a20d24f7 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 09:13:31 +0200
Subject: [PATCH 032/527] chg: adding execute/home/current working directory
functions to lua
---
client/luascripts/tracetest.lua | 14 +++++-----
client/src/preferences.c | 9 -------
client/src/proxmark3.c | 8 ------
client/src/proxmark3.h | 9 +++++++
client/src/scripting.c | 48 ++++++++++++++++++++++++++++++++-
5 files changed, 64 insertions(+), 24 deletions(-)
diff --git a/client/luascripts/tracetest.lua b/client/luascripts/tracetest.lua
index c1917b401..e45d1ceba 100644
--- a/client/luascripts/tracetest.lua
+++ b/client/luascripts/tracetest.lua
@@ -7,15 +7,15 @@ local ansicolors = require('ansicolors')
copyright = ''
author = 'Iceman'
-version = 'v1.0.2'
+version = 'v1.0.3'
desc = [[
-This script will load several traces files in ../traces/ folder and do
+This script will load several traces files in current working directory/traces/ folder and do
"data load"
"lf search 1 u"
The following tracefiles will be loaded:
em*.pm3
- m*.pm3
+ modulation*.pm3
]]
example = [[
1. script run tracetest
@@ -78,8 +78,10 @@ local function main(args)
print( string.rep('--',20) )
local cmdDataLoad = 'data load %s';
- local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
- local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
+ local cwd = core.cwd();
+
+ local tracesEM = "find '"..cwd.."/traces/ ' -iname 'em*.pm3' -type f"
+ local tracesMOD = "find '"..cwd.."/traces/' -iname 'modulation*.pm3' -type f"
local write2File = false
local outputTemplate = os.date('testtest_%Y-%m-%d_%H%M%S')
@@ -100,7 +102,7 @@ local function main(args)
end
p.close();
- -- Find a set of traces staring with MOD
+ -- Find a set of traces staring with MODULATION
p = assert( io.popen(tracesMOD) )
for file in p:lines() do
table.insert(files, file)
diff --git a/client/src/preferences.c b/client/src/preferences.c
index 0ef715075..4c8fefb77 100644
--- a/client/src/preferences.c
+++ b/client/src/preferences.c
@@ -29,15 +29,6 @@
static int CmdHelp(const char *Cmd);
static int setCmdHelp(const char *Cmd);
-// Load all settings into memory (struct)
-#ifdef _WIN32
-#include
-#define GetCurrentDir _getcwd
-#else
-#include
-#define GetCurrentDir getcwd
-#endif
-
static char *prefGetFilename(void) {
char *path;
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index abf014e08..07d777a2c 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -29,14 +29,6 @@
#include "flash.h"
#include "preferences.h"
-#ifdef _WIN32
-#include
-#define GetCurrentDir _getcwd
-#else
-#include
-#define GetCurrentDir getcwd
-#endif
-
// Used to enable/disable use of preferences json file
#define USE_PREFERENCE_FILE
diff --git a/client/src/proxmark3.h b/client/src/proxmark3.h
index 6402baea9..6d7e9dfb4 100644
--- a/client/src/proxmark3.h
+++ b/client/src/proxmark3.h
@@ -12,6 +12,7 @@
#ifndef PROXMARK3_H__
#define PROXMARK3_H__
+#include
#include "common.h"
#define PROXPROMPT_MAX_SIZE 255
@@ -36,6 +37,14 @@
extern "C" {
#endif
+// Load all settings into memory (struct)
+#ifdef _WIN32
+#include
+#define GetCurrentDir _getcwd
+#else
+#define GetCurrentDir getcwd
+#endif
+
int push_cmdscriptfile(char *path, bool stayafter);
const char *get_my_executable_path(void);
const char *get_my_executable_directory(void);
diff --git a/client/src/scripting.c b/client/src/scripting.c
index 25bda6322..4a3bab49c 100644
--- a/client/src/scripting.c
+++ b/client/src/scripting.c
@@ -12,9 +12,11 @@
#include
#include
+#include
#include "lauxlib.h"
#include "cmdmain.h"
+#include "proxmark3.h"
#include "comms.h"
#include "mifare/mifarehost.h"
#include "crc.h"
@@ -28,7 +30,7 @@
#include "mifare/ndef.h" // ndef parsing
#include "commonutil.h"
#include "ui.h"
-#include "proxmark3.h"
+
#include "crc16.h"
#include "protocols.h"
#include "fileutils.h" // searchfile
@@ -912,6 +914,12 @@ static int l_detect_prng(lua_State *L) {
* @return
*/
static int l_keygen_algoD(lua_State *L) {
+ //Check number of arguments
+ int n = lua_gettop(L);
+ if (n != 1) {
+ return returnToLuaWithError(L, "Only UID");
+ }
+
size_t size;
uint32_t tmp;
const char *p_uid = luaL_checklstring(L, 1, &size);
@@ -1129,6 +1137,9 @@ static int l_remark(lua_State *L) {
return 1;
}
+// 1. filename
+// 2. extension
+// output: full search path to file
static int l_searchfile(lua_State *L) {
//Check number of arguments
int n = lua_gettop(L);
@@ -1154,6 +1165,38 @@ static int l_searchfile(lua_State *L) {
return 1;
}
+static int l_ud(lua_State *L) {
+ const char *ud = get_my_user_directory();
+ lua_pushstring(L, ud);
+ return 1;
+}
+static int l_ewd(lua_State *L) {
+ const char *ewd = get_my_executable_directory();
+ lua_pushstring(L, ewd);
+ return 1;
+}
+static int l_cwd(lua_State *L) {
+
+ uint16_t path_len = FILENAME_MAX; // should be a good starting point
+ bool error = false;
+ char *cwd = NULL;
+ cwd = (char *)calloc(path_len, sizeof(uint8_t));
+
+ while (!error && (GetCurrentDir(cwd, path_len) == NULL)) {
+ if (errno == ERANGE) { // Need bigger buffer
+ path_len += 10; // if buffer was too small add 10 characters and try again
+ cwd = realloc(cwd, path_len);
+ } else {
+ error = true;
+ free(cwd);
+ return returnToLuaWithError(L, "Failed to get current working directory");
+ }
+ }
+ lua_pushstring(L, cwd);
+ free(cwd);
+ return 1;
+}
+
/**
* @brief Sets the lua path to include "./lualibs/?.lua", in order for a script to be
* able to do "require('foobar')" if foobar.lua is within lualibs folder.
@@ -1215,6 +1258,9 @@ int set_pm3_libraries(lua_State *L) {
{"ndefparse", l_ndefparse},
{"fast_push_mode", l_fast_push_mode},
{"search_file", l_searchfile},
+ {"cwd", l_cwd},
+ {"ewd", l_ewd},
+ {"ud", l_ud},
{"rem", l_remark},
{NULL, NULL}
};
From 339a3ee152ff3c3b4a06a6e4584a9ac776c523b3 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 09:29:11 +0200
Subject: [PATCH 033/527] update trace log documentation
---
doc/trace_notes.md | 51 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/doc/trace_notes.md b/doc/trace_notes.md
index a126a238f..1cdf8dead 100644
--- a/doc/trace_notes.md
+++ b/doc/trace_notes.md
@@ -1,10 +1,18 @@
-# Trace command notes
+# Notes about the tracelog.
+
+## Table of Contents
+ * [Command](#trace-command)
+ * [File format](#tracelog-format)
+ * [Wireshark dissector interoperability](#trace-and-wireshark)
+
+
+## Trace command
The `trace` command lists the data exchange by the proxmark3 and a tag or a reader in human readable form.
With `trace list` a table is shown which gives timing information, the src of the data bytes, the transmitted/received bytes itself, a check if the CRC was correct and some decoding of the command.
-## Timing
+### Timing
The Start and the End coloumn lists timestamps when the transmission of the shown data started (time of first bit) and when it ended (end of last modulation).
@@ -20,26 +28,55 @@ The unit for this time information depends on the protocol in use:
By specifing the option ```f``` (e.g. ```trace list 14a f```) the frame delay times are shown. (So you don't have to do the math by your own).
-## Sources
+### Sources
If the data is marked as a response the source is shown as Tag. Otherwise it is marked as Reader (Rdr).
-## Data
+### Data
This coloumn show the raw bytes trasmitted over the air. With option ```c``` CRC bytes are marked in square brackets.
-## CRC
+### CRC
Marks if the transmitted CRC matches with the calculated CRC.
-## Annotation
+### Annotation
Annotations provide a rough decoding of the transmitted data. For ISO14443A a more detailed decoding is available with Wireshark (s. next chapter)
+--
+## Tracelog format
+The binary format for the dynamic tracelog is as following.
+
+```
+ /*
+ Traceformat:
+ 32 bits timestamp (little endian)
+ 16 bits duration (little endian)
+ 15 bits data length (little endian) (0x7FFF)
+ 1 bit isResponse (used as readerToTag flag)
+ y Bytes data
+ x Bytes parity, where x == ceil(data_len/8)
+*/
+
+typedef struct {
+ uint32_t timestamp;
+ uint16_t duration;
+ uint16_t data_len : 15;
+ bool isResponse : 1;
+ uint8_t frame[];
+ // data_len bytes of data
+ // ceil(data_len/8) bytes of parity
+} PACKED tracelog_hdr_t;
+
+#define TRACELOG_HDR_LEN sizeof(tracelog_hdr_t)
+#define TRACELOG_PARITY_LEN(x) (((x)->data_len - 1) / 8 + 1)
+```
+
--
-# Trace and Wireshark
+## Trace and Wireshark
To get a more detailed explanation of the transmitted data for ISO14443A traces the output can be converted to a pcapng file to read it with [Wireshark](https://www.wireshark.org/).
From 66920e66995fbfc9eeacd427ac00f96597c9f003 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:31:52 +0200
Subject: [PATCH 034/527] Update trace_notes.md
---
doc/trace_notes.md | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/doc/trace_notes.md b/doc/trace_notes.md
index 1cdf8dead..8344c6184 100644
--- a/doc/trace_notes.md
+++ b/doc/trace_notes.md
@@ -1,4 +1,4 @@
-# Notes about the tracelog.
+# Notes about the tracelog
## Table of Contents
* [Command](#trace-command)
@@ -44,7 +44,6 @@ Marks if the transmitted CRC matches with the calculated CRC.
Annotations provide a rough decoding of the transmitted data. For ISO14443A a more detailed decoding is available with Wireshark (s. next chapter)
---
## Tracelog format
The binary format for the dynamic tracelog is as following.
@@ -73,9 +72,6 @@ typedef struct {
#define TRACELOG_PARITY_LEN(x) (((x)->data_len - 1) / 8 + 1)
```
-
---
-
## Trace and Wireshark
To get a more detailed explanation of the transmitted data for ISO14443A traces the output can be converted to a pcapng file to read it with [Wireshark](https://www.wireshark.org/).
From 01139ac7e7bdc36762f0354f7a0c8eded05b26c4 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:40:25 +0200
Subject: [PATCH 035/527] Update README.md
---
README.md | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index f97017965..d19c187c4 100644
--- a/README.md
+++ b/README.md
@@ -16,17 +16,24 @@
|[Why didn't you base it on official Proxmark3 Master?](#why-didnt-you-base-it-on-official-proxmark3-master)| **[Homebrew (Mac OS X) & Upgrading HomeBrew Tap Formula](/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md)** | [First Use and Verification](/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md)|
|[Proxmark3 GUI](#proxmark3-gui)|**[Setup and build for Windows](/doc/md/Installation_Instructions/Windows-Installation-Instructions.md)**|[Commands & Features](/doc/md/Use_of_Proxmark/3_Commands-and-Features.md)|
|[Issues](#issues)|[Blue shark manual](/doc/bt_manual_v10.md) ||
-|[Notes on UART](/doc/uart_notes.md)|[Maintainers](/doc/md/Development/Maintainers.md)|[Command Cheat sheet](/doc/cheatsheet.md)|
-|[Notes on frame format](/doc/new_frame_format.md)|[Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)|[More cheat sheets](https://github.com/RfidResearchGroup/proxmark3/wiki/More-cheat-sheets)|
-|[Notes on external flash](/doc/ext_flash_notes.md)||[EMV](/doc/emv_notes.md)|
-|[Notes on Termux / Android](/doc/termux_notes.md)|**[Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md)**|[Complete client command set](/doc/commands.md)|
-|[Notes on tracedata / wireshark](/doc/trace_notes.md)|**[JTAG](/doc/jtag_notes.md)**||
-|[Notes on loclass](/doc/loclass_notes.md)|||
-|[Notes on paths](/doc/path_notes.md)|||
+||[Maintainers](/doc/md/Development/Maintainers.md)|[Command Cheat sheet](/doc/cheatsheet.md)|
+||[Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)|[More cheat sheets](https://github.com/RfidResearchGroup/proxmark3/wiki/More-cheat-sheets)|
+|||[EMV](/doc/emv_notes.md)|
+||**[Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md)**|[Complete client command set](/doc/commands.md)|
+||**[JTAG](/doc/jtag_notes.md)**||
+||||
+||||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode) ||
|[Donations](#Donations)|||
+| Notes / helpful documents |||
+| ------------------- |:-------------------:| -------------------:|
+|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
+|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracedata / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
+|[Notes on external flash](/doc/ext_flash_notes.md)|[Notes on loclass](/doc/loclass_notes.md)|[Notes on Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md)|
+|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|[Notes on standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
+
## Build for non-RDV4 Proxmark3 platforms
In order to build this repo for other Proxmark3 platforms we urge you to read [Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)
@@ -60,18 +67,7 @@ The [public roadmap](https://github.com/RfidResearchGroup/proxmark3/wiki/Public-
> 👉 **Remember!** If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
We usually merge your contributions fast since we do like the idea of getting a functionality in the Proxmark3 and weed out the bugs afterwards.
-## Notes / helpful documents
-- notes on [Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md).
-- notes on [UART](/doc/uart_notes.md)
-- notes on [Frame format](/doc/new_frame_format.md)
-- notes on [external flash](/doc/ext_flash_notes.md)
-- notes on [standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)
-- notes on [Termux / Android](/doc/termux_notes.md)
-- notes on [tracedata / Wireshark](/doc/trace_notes.md)
-- notes on [loclass](/doc/loclass_notes.md)
-- notes on [EMV](/doc/emv_notes.md)
-- notes on [Paths](/doc/path_notes.md)
-- notes on [file formats used with Proxmark3](/doc/extensions_notes.md)
+
## Cheat sheet
Thanks to Alex Dibs, you can enjoy a [command cheat sheet](/doc/cheatsheet.md)
From 5e022c4be008eace5ea79a81e587dda3f15e6877 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:40:52 +0200
Subject: [PATCH 036/527] Update README.md
---
README.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/README.md b/README.md
index d19c187c4..80bf92355 100644
--- a/README.md
+++ b/README.md
@@ -21,8 +21,6 @@
|||[EMV](/doc/emv_notes.md)|
||**[Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md)**|[Complete client command set](/doc/commands.md)|
||**[JTAG](/doc/jtag_notes.md)**||
-||||
-||||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode) ||
|[Donations](#Donations)|||
From eb9a485fe020fa1fc0d9d810dca46878582acd97 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:42:54 +0200
Subject: [PATCH 037/527] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 80bf92355..2897131f6 100644
--- a/README.md
+++ b/README.md
@@ -18,14 +18,14 @@
|[Issues](#issues)|[Blue shark manual](/doc/bt_manual_v10.md) ||
||[Maintainers](/doc/md/Development/Maintainers.md)|[Command Cheat sheet](/doc/cheatsheet.md)|
||[Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)|[More cheat sheets](https://github.com/RfidResearchGroup/proxmark3/wiki/More-cheat-sheets)|
-|||[EMV](/doc/emv_notes.md)|
||**[Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md)**|[Complete client command set](/doc/commands.md)|
||**[JTAG](/doc/jtag_notes.md)**||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode) ||
|[Donations](#Donations)|||
-| Notes / helpful documents |||
+## Notes / helpful documents
+| Notes |||
| ------------------- |:-------------------:| -------------------:|
|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracedata / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
From dcaf7e1ea72ba512875c46eef36dee575d7f56f7 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:46:18 +0200
Subject: [PATCH 038/527] Update README.md
---
README.md | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 2897131f6..988274a08 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,10 @@
|[Why didn't you base it on official Proxmark3 Master?](#why-didnt-you-base-it-on-official-proxmark3-master)| **[Homebrew (Mac OS X) & Upgrading HomeBrew Tap Formula](/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md)** | [First Use and Verification](/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md)|
|[Proxmark3 GUI](#proxmark3-gui)|**[Setup and build for Windows](/doc/md/Installation_Instructions/Windows-Installation-Instructions.md)**|[Commands & Features](/doc/md/Use_of_Proxmark/3_Commands-and-Features.md)|
|[Issues](#issues)|[Blue shark manual](/doc/bt_manual_v10.md) ||
-||[Maintainers](/doc/md/Development/Maintainers.md)|[Command Cheat sheet](/doc/cheatsheet.md)|
+|[Donations](#Donations)|[Maintainers](/doc/md/Development/Maintainers.md)|[Command Cheat sheet](/doc/cheatsheet.md)|
||[Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)|[More cheat sheets](https://github.com/RfidResearchGroup/proxmark3/wiki/More-cheat-sheets)|
||**[Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md)**|[Complete client command set](/doc/commands.md)|
||**[JTAG](/doc/jtag_notes.md)**||
-|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode) ||
-|[Donations](#Donations)|||
## Notes / helpful documents
@@ -30,7 +28,8 @@
|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracedata / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
|[Notes on external flash](/doc/ext_flash_notes.md)|[Notes on loclass](/doc/loclass_notes.md)|[Notes on Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md)|
-|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|[Notes on standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
+|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|||
+|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
## Build for non-RDV4 Proxmark3 platforms
From 505cfed5a029cb65021516ceff54c68acffbb7f4 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 09:49:53 +0200
Subject: [PATCH 039/527] Update README.md
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 988274a08..02eb139b2 100644
--- a/README.md
+++ b/README.md
@@ -53,9 +53,11 @@ On the software side: quite a lot, see the [Changelog file](CHANGELOG.md).
This repo compiles nicely on
- Proxspace v3.x
- Windows/mingw environment with Qt5.6.1 & GCC 4.8
- - Ubuntu 1604, 1804, 1904
+ - Ubuntu 1604, 1804, 1904, 2004
+ - ParrotOS, Gentoo, Pentoo, Kali, Nethunter, Archlinux, Fedora, Debian
+ - Rasbian Pi, Jetson Nano,
+ - Android / Termux
- Mac OS X / Homebrew
- - ParrotOS, Gentoo, Pentoo, Kali, Nethunter, Archlinux, Fedora
- WSL, WSL2 (Windows subsystem linux) on Windows 10
- Docker container
From 3e50a305211f3969cd62c6c433ecb22a228a216a Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 10:01:49 +0200
Subject: [PATCH 040/527] trace doc: minor
---
doc/trace_notes.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/trace_notes.md b/doc/trace_notes.md
index 8344c6184..84a692930 100644
--- a/doc/trace_notes.md
+++ b/doc/trace_notes.md
@@ -53,9 +53,9 @@ The binary format for the dynamic tracelog is as following.
32 bits timestamp (little endian)
16 bits duration (little endian)
15 bits data length (little endian) (0x7FFF)
- 1 bit isResponse (used as readerToTag flag)
- y Bytes data
- x Bytes parity, where x == ceil(data_len/8)
+ 1 bit isResponse (0=reader to tag, 1=tag to reader)
+ data length Bytes data
+ x Bytes parity, where x == ceil(data length/8)
*/
typedef struct {
From e73aab8ed3294546ec8c8f76c95fa8e83181bcd6 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:11:40 +0200
Subject: [PATCH 041/527] Update bt_manual_v10.md
---
doc/bt_manual_v10.md | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/doc/bt_manual_v10.md b/doc/bt_manual_v10.md
index d54d458c2..b091ef40b 100644
--- a/doc/bt_manual_v10.md
+++ b/doc/bt_manual_v10.md
@@ -1,4 +1,5 @@
# MANUAL Bluetooth / Battery add-on 'Blue Shark'
+
_rev. v1.1_
## Table of Contents
@@ -29,6 +30,7 @@ _rev. v1.1_
* [6.5 Get better signals](#65-get-better-signals)
## 1. FEATURES
+^[Top](#top)
* Built-in Bluetooth 2.0 with EDR Bluetooth module, default baud rate 115200.
* Built-in 400 mAh polymer lithium-ion battery, typical standby time up to 3.5 hours.
@@ -44,6 +46,7 @@ Built-in battery can support standalone mode, off-line sniffing, off-line readin
## 2. PARAMETERS
+^[Top](#top)
* Battery capacity: 400 mAh
* Standby time: 3.5h @ StandBy; 2.9h @ LF-On; 50min @ HF-On;
@@ -56,6 +59,7 @@ Built-in battery can support standalone mode, off-line sniffing, off-line readin
## 3. ASSEMBLY STEPS
+^[Top](#top)
* Unplug your Proxmark3 RDV4.0 device from any usb cable.
* Remove the plastic upper case of Proxmark3 RDV4.0 with opener.
@@ -72,8 +76,11 @@ Built-in battery can support standalone mode, off-line sniffing, off-line readin
## 4. COMPILATION / FLASHING
+^[Top](#top)
#### 4.1 From Source
+^[Top](#top)
+
Please download the latest source code from Rfid Research Group's Github repo:
https://github.com/RfidResearchGroup/proxmark3
@@ -91,6 +98,8 @@ You are now ready to run the client with the serial port you got from your BT de
See instructions below.
#### 4.2 Homebrew (macOS)
+^[Top](#top)
+
From the [homebrew-proxmark3 readme](https://github.com/RfidResearchGroup/homebrew-proxmark3)
1. `brew tap rfidresearchgroup/proxmark3`
@@ -98,13 +107,17 @@ From the [homebrew-proxmark3 readme](https://github.com/RfidResearchGroup/homebr
## 5. CONNECT WITH BLUETOOTH
+^[Top](#top)
You can have both USB cable connect and BT active at the same time and connect to either serial port.
You can also switch serial port from inside the proxmark3 client using the new command `hw connect`.
### 5.1 Windows
+^[Top](#top)
#### 5.1.1 Connecting your RDV4.0 with Bluetooth on mobile phone or computer
+^[Top](#top)
+
* Open Bluetooth and search for a device named PM3_RDV4.0.
* Enter the paired password 1234 and establish the connection.
* The blue state LED on the add-on will keep blinking after the connection is established. Only when the mobile phone or computer opens the correct COM port, the blue LED turns on solid, indicating that the connection is successful.
@@ -130,6 +143,7 @@ You can also switch serial port from inside the proxmark3 client using the new c
* done!
#### 5.1.2 Fast connection using dedicated USB Bluetooth adapter under Windows
+^[Top](#top)

@@ -143,8 +157,10 @@ http://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp
* look for _CP2104 USB tp UART bridge controller_ under devices in order to get the assigned serial port
### 5.2 Linux
+^[Top](#top)
#### 5.2.1 Connecting rdv4.0 with Bluetooth on Linux computer via native Bluetooth support in the client
+^[Top](#top)
This requires to have compiled the client with Bluetooth support.
@@ -189,6 +205,7 @@ Discovery started
```
#### 5.2.2 Fast connection using dedicated USB Bluetooth adapter under Linux
+^[Top](#top)

@@ -212,6 +229,7 @@ turn on solid.
```
#### 5.2.3 (deprecated) Connecting rdv4.0 with Bluetooth on Linux computer via rfcomm
+^[Top](#top)
rfcomm is a deprecated tool which might be unavailable in your Linux distribution.
@@ -245,8 +263,10 @@ connection is successful.
See instructions above (method 1) for initial pairing.
### 5.3 MacOS
+^[Top](#top)
#### 5.3.1 Connecting rdv4.0 with Bluetooth on MacOS
+^[Top](#top)
With MacOS Mojave 10.14.5 you could experience some continuosly disconnecting and difficult to recconnect the device at the system wakeup, to avoid this problem do a PRAM reset before to add your Proxmark3 RDV4 Blue Shark:
@@ -266,17 +286,21 @@ After reboot you can go ahead to pairing your Proxmark3 RDV4 Blue Shark:
./proxmark3 /dev/tty.PM3_RDV40-DevB
```
### 5.4 Android
+^[Top](#top)
#### 5.4.1 Fast connection using dedicated Bluetooth (HC-06 Master + CP2102) adapter under Android with Termux
-
+^[Top](#top)
+
1. Make sure you already followed this tutorial https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/termux_notes.md#setup and have Termux with an running Proxmark3 client ready. You need additional the `cp210x` serial usb driver enabled and working, like the `USB_ACM` driver to communicate wireless.
2. Insert the Bluetooth adapter with an fitting USB-C/Micro-USB converter into your Android USB port and a serial port `/dev/ttyUSB0` will be created. To see if it's working, run `tsudo ls /dev/ttyU*` and it should list `/dev/ttyUSB0`.
3. The adapter will search automatically and establish the connection to BlueShark. The adapter will remember the device that was first connected and after that the same device will be connected. After the connection is established, the blue state LED on add-on will turn on solid.
4. If you see this, congratulations, you can run your Proxmark3 client in Termux with `tsudo proxmark3/client/proxmark3 /dev/ttyUSB0`
## 6. OTHER NOTES
+^[Top](#top)
### 6.1 Default settings
+^[Top](#top)
Settings of the Blue Shark add-on and of the white dongle:
@@ -287,19 +311,27 @@ Settings of the Blue Shark add-on and of the white dongle:
If you bought your Bluetooth adapter dongle somewhere else, make sure to set the baud rate to 115200 `AT+BAUD8`, the name `AT+NAMEPM3_RDV4.0` and PIN `AT+PIN1234` correctly.
### 6.1 UART and LED behavior
+^[Top](#top)
+
Bluetooth is connected to Proxmark3 RDV4.0 via UART. The USB and UART interfaces of RDV4.0 can coexist without conflict, and no special switching is required.
The following link has helpful notes on UART usage and baud rates:
https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/uart_notes.md
### 6.2 Disassembly
+^[Top](#top)
+
There is a heat conductive double-sided tape inside the add-on, which has strong adhesive force. Therefore, if add-on needs to be removed, it needs to be pulled out from the heat sink end with greater efforts. Each disassembly will reduce the viscidity of double-sided tape. When double-sided tape is well protected, it will not affect the second use. Thermal conductivity will be slightly worse and will therefore have a direct impact on the thermal performance of the heat sink.
### 6.3 Battery charging
+^[Top](#top)
+
The battery charging circuit is turned on by default. Any time a USB cable is inserted, the battery will be automatically charged. The red LED will remain bright when charging.
The red LED will be extinguished when charging is completed.
### 6.4 Get better signals
+^[Top](#top)
+
For the better heat dissipation, we have used a cast metal enclosure for the add-on. As a result Bluetooth wireless signals are sacrificed. For example, if the back of add-on is facing the Bluetooth host, the signal is very bad and the distance will be reduced. The best signal strength can be obtained when the front glass faces the Bluetooth host.
If the Proxmark3 is not responding, it may be due to a poor Bluetooth connection. To improve performance, try repositioning the Proxmark3 so the glass face is directed toward the host.
From ecd709494abf090a3bbd9a9014a806079641bb0a Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:13:19 +0200
Subject: [PATCH 042/527] Update bt_manual_v10.md
---
doc/bt_manual_v10.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/doc/bt_manual_v10.md b/doc/bt_manual_v10.md
index b091ef40b..e474c0ec7 100644
--- a/doc/bt_manual_v10.md
+++ b/doc/bt_manual_v10.md
@@ -310,7 +310,7 @@ Settings of the Blue Shark add-on and of the white dongle:
If you bought your Bluetooth adapter dongle somewhere else, make sure to set the baud rate to 115200 `AT+BAUD8`, the name `AT+NAMEPM3_RDV4.0` and PIN `AT+PIN1234` correctly.
-### 6.1 UART and LED behavior
+### 6.2 UART and LED behavior
^[Top](#top)
Bluetooth is connected to Proxmark3 RDV4.0 via UART. The USB and UART interfaces of RDV4.0 can coexist without conflict, and no special switching is required.
@@ -318,18 +318,18 @@ Bluetooth is connected to Proxmark3 RDV4.0 via UART. The USB and UART interfaces
The following link has helpful notes on UART usage and baud rates:
https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/uart_notes.md
-### 6.2 Disassembly
+### 6.3 Disassembly
^[Top](#top)
There is a heat conductive double-sided tape inside the add-on, which has strong adhesive force. Therefore, if add-on needs to be removed, it needs to be pulled out from the heat sink end with greater efforts. Each disassembly will reduce the viscidity of double-sided tape. When double-sided tape is well protected, it will not affect the second use. Thermal conductivity will be slightly worse and will therefore have a direct impact on the thermal performance of the heat sink.
-### 6.3 Battery charging
+### 6.4 Battery charging
^[Top](#top)
The battery charging circuit is turned on by default. Any time a USB cable is inserted, the battery will be automatically charged. The red LED will remain bright when charging.
The red LED will be extinguished when charging is completed.
-### 6.4 Get better signals
+### 6.5 Get better signals
^[Top](#top)
For the better heat dissipation, we have used a cast metal enclosure for the add-on. As a result Bluetooth wireless signals are sacrificed. For example, if the back of add-on is facing the Bluetooth host, the signal is very bad and the distance will be reduced. The best signal strength can be obtained when the front glass faces the Bluetooth host.
From 0112346dac818b5cfc59d22a6a069951daedd342 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:14:39 +0200
Subject: [PATCH 043/527] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 02eb139b2..441b060c2 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@
| Notes |||
| ------------------- |:-------------------:| -------------------:|
|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
-|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracedata / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
+|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracelog / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
|[Notes on external flash](/doc/ext_flash_notes.md)|[Notes on loclass](/doc/loclass_notes.md)|[Notes on Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md)|
|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
From 7e213fcf43584525ae2b87f555d92fdafa547528 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:15:43 +0200
Subject: [PATCH 044/527] Update trace_notes.md
---
doc/trace_notes.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/doc/trace_notes.md b/doc/trace_notes.md
index 84a692930..ccf9a5e5e 100644
--- a/doc/trace_notes.md
+++ b/doc/trace_notes.md
@@ -1,4 +1,5 @@
# Notes about the tracelog
+
## Table of Contents
* [Command](#trace-command)
@@ -7,12 +8,14 @@
## Trace command
+^[Top](#top)
The `trace` command lists the data exchange by the proxmark3 and a tag or a reader in human readable form.
With `trace list` a table is shown which gives timing information, the src of the data bytes, the transmitted/received bytes itself, a check if the CRC was correct and some decoding of the command.
### Timing
+^[Top](#top)
The Start and the End coloumn lists timestamps when the transmission of the shown data started (time of first bit) and when it ended (end of last modulation).
@@ -29,22 +32,28 @@ The unit for this time information depends on the protocol in use:
By specifing the option ```f``` (e.g. ```trace list 14a f```) the frame delay times are shown. (So you don't have to do the math by your own).
### Sources
+^[Top](#top)
If the data is marked as a response the source is shown as Tag. Otherwise it is marked as Reader (Rdr).
### Data
+^[Top](#top)
This coloumn show the raw bytes trasmitted over the air. With option ```c``` CRC bytes are marked in square brackets.
### CRC
+^[Top](#top)
Marks if the transmitted CRC matches with the calculated CRC.
### Annotation
+^[Top](#top)
Annotations provide a rough decoding of the transmitted data. For ISO14443A a more detailed decoding is available with Wireshark (s. next chapter)
## Tracelog format
+^[Top](#top)
+
The binary format for the dynamic tracelog is as following.
```
@@ -73,6 +82,7 @@ typedef struct {
```
## Trace and Wireshark
+^[Top](#top)
To get a more detailed explanation of the transmitted data for ISO14443A traces the output can be converted to a pcapng file to read it with [Wireshark](https://www.wireshark.org/).
From 2adace964de02ee0281d2524e889dafefcb20b13 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:16:20 +0200
Subject: [PATCH 045/527] Update trace_notes.md
---
doc/trace_notes.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/trace_notes.md b/doc/trace_notes.md
index ccf9a5e5e..a95285518 100644
--- a/doc/trace_notes.md
+++ b/doc/trace_notes.md
@@ -1,5 +1,5 @@
-# Notes about the tracelog
+# Notes about the tracelog
## Table of Contents
* [Command](#trace-command)
From db416483421d168541ec34307929450f824bbfcc Mon Sep 17 00:00:00 2001
From: Iceman
Date: Tue, 19 May 2020 10:17:46 +0200
Subject: [PATCH 046/527] Update cheatsheet.md
---
doc/cheatsheet.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/cheatsheet.md b/doc/cheatsheet.md
index 74a061b10..0ae47b68c 100644
--- a/doc/cheatsheet.md
+++ b/doc/cheatsheet.md
@@ -1,5 +1,5 @@
-# Command Cheat Sheet
+# Command Cheat Sheet
|Generic|Low Frequence 125 kHz|High Frequence 13.56 MHz|
|---|---|---|
From f7534f412081631faf0ab1a174373674d7e1122e Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 14:00:45 +0200
Subject: [PATCH 047/527] try to update build status logo
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 441b060c2..1c4cdaf83 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
| Releases | Linux & OSX CI | Windows CI | Coverity |
| ------------------- |:-------------------:| -------------------:| -------------------:|
-| [](https://github.com/RfidResearchGroup/proxmark3/releases/latest) | [](https://travis-ci.org/RfidResearchGroup/proxmark3) | [](https://ci.appveyor.com/project/RfidResearchGroup/proxmark3/branch/master) | [](https://scan.coverity.com/projects/proxmark3-rrg-iceman-repo)|
+| [](https://github.com/RfidResearchGroup/proxmark3/releases/latest) | [](https://travis-ci.org/RfidResearchGroup/proxmark3) | [](https://ci.appveyor.com/project/RfidResearchGroup/proxmark3/branch/master) | [](https://scan.coverity.com/projects/proxmark3-rrg-iceman-repo)|
From e8f723620ee5f3b76d507947cb657653d122cbac Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 16:26:08 +0200
Subject: [PATCH 048/527] Fix issue #736, still other errors on armsrc to solve
---
common_arm/Makefile.common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 95b419e8e..81f2b0131 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -39,7 +39,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
-ARMCFLAGS = -mthumb-interwork
+ARMCFLAGS = -mthumb-interwork -fno-builtin
DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
From fbaf634779f91db7cd0ba0336c29fa78c24814d7 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 16:33:55 +0200
Subject: [PATCH 049/527] legicrf & gcc 10: Remove inline warning
---
armsrc/legicrf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c
index 474d0df84..14298a5f1 100644
--- a/armsrc/legicrf.c
+++ b/armsrc/legicrf.c
@@ -113,7 +113,13 @@ static inline int32_t sample_power(void) {
//
// Note: The demodulator would be drifting (18.9us * 5 != 100us), rx_frame
// has a delay loop that aligns rx_bit calls to the TAG tx timeslots.
+
+// Note: inlining this function would fail with -Os
+#ifdef __OPTIMIZE_SIZE__
+static bool rx_bit(void) {
+#else
static inline bool rx_bit(void) {
+#endif
int32_t power;
for (size_t i = 0; i < 5; ++i) {
From 3e7512a5d5405204aaf899650e92170af4604730 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 17:05:43 +0200
Subject: [PATCH 050/527] armsrc: clarify static vars vs global vars
---
armsrc/appmain.c | 14 +++++++-------
armsrc/appmain.h | 5 ++---
armsrc/cmd.c | 34 +++++++++++++++++-----------------
armsrc/cmd.h | 8 ++++----
armsrc/dbprint.h | 36 ++++++++++++++++++------------------
armsrc/felica.c | 2 +-
armsrc/hitag2.c | 22 +++++++++++-----------
armsrc/hitag2crack.c | 6 +++---
armsrc/hitagS.c | 3 +--
armsrc/iclass.c | 4 ++--
armsrc/iso14443a.c | 10 +++++-----
armsrc/iso14443b.c | 4 ++--
armsrc/lfadc.c | 19 ++++++++++++-------
armsrc/lfadc.h | 2 +-
armsrc/lfops.h | 4 ----
armsrc/lfsampling.c | 2 +-
armsrc/mifaredesfire.c | 2 +-
armsrc/printf.c | 2 +-
armsrc/usart.c | 20 ++++++++++----------
armsrc/usart.h | 4 ++--
20 files changed, 101 insertions(+), 102 deletions(-)
diff --git a/armsrc/appmain.c b/armsrc/appmain.c
index 7cb974cec..87b3dd0df 100644
--- a/armsrc/appmain.c
+++ b/armsrc/appmain.c
@@ -73,7 +73,7 @@ int ToSendMax = -1;
static int ToSendBit;
struct common_area common_area __attribute__((section(".commonarea")));
int button_status = BUTTON_NO_CLICK;
-bool allow_send_wtx = false;
+static bool allow_send_wtx = false;
inline void send_wtx(uint16_t wtx) {
if (allow_send_wtx) {
@@ -385,12 +385,12 @@ static void SendStatus(void) {
static void SendCapabilities(void) {
capabilities_t capabilities;
capabilities.version = CAPABILITIES_VERSION;
- capabilities.via_fpc = reply_via_fpc;
- capabilities.via_usb = reply_via_usb;
+ capabilities.via_fpc = g_reply_via_fpc;
+ capabilities.via_usb = g_reply_via_usb;
capabilities.baudrate = 0; // no real baudrate for USB-CDC
#ifdef WITH_FPC_USART
- if (reply_via_fpc)
- capabilities.baudrate = usart_baudrate;
+ if (g_reply_via_fpc)
+ capabilities.baudrate = g_usart_baudrate;
#endif
#ifdef WITH_FLASH
@@ -701,8 +701,8 @@ static void PacketReceived(PacketCommandNG *packet) {
case CMD_BREAK_LOOP:
break;
case CMD_QUIT_SESSION: {
- reply_via_fpc = false;
- reply_via_usb = false;
+ g_reply_via_fpc = false;
+ g_reply_via_usb = false;
break;
}
// emulator
diff --git a/armsrc/appmain.h b/armsrc/appmain.h
index 8baff4db1..5aece8388 100644
--- a/armsrc/appmain.h
+++ b/armsrc/appmain.h
@@ -13,9 +13,8 @@
#include "common.h"
-extern int rsamples; // = 0;
-extern uint8_t trigger;
-extern bool allow_send_wtx;
+extern int g_rsamples; // = 0;
+extern uint8_t g_trigger;
// ADC Vref = 3300mV, and an (10M+1M):1M voltage divider on the HF input can measure voltages up to 36300 mV
#define MAX_ADC_HF_VOLTAGE 36300
diff --git a/armsrc/cmd.c b/armsrc/cmd.c
index 17534cbf1..b0dc4aef8 100644
--- a/armsrc/cmd.c
+++ b/armsrc/cmd.c
@@ -36,11 +36,11 @@
#include "string.h"
// Flags to tell where to add CRC on sent replies
-bool reply_with_crc_on_usb = false;
-bool reply_with_crc_on_fpc = true;
+bool g_reply_with_crc_on_usb = false;
+bool g_reply_with_crc_on_fpc = true;
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
-bool reply_via_fpc = false;
-bool reply_via_usb = false;
+bool g_reply_via_fpc = false;
+bool g_reply_via_usb = false;
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
PacketResponseOLD txcmd = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
@@ -68,11 +68,11 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *d
int resultusb = PM3_EUNDEF;
// Send frame and make sure all bytes are transmitted
- if (reply_via_usb) {
+ if (g_reply_via_usb) {
resultusb = usb_write((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
}
- if (reply_via_fpc) {
+ if (g_reply_via_fpc) {
#ifdef WITH_FPC_USART_HOST
resultfpc = usart_writebuffer_sync((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
#else
@@ -80,9 +80,9 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *d
#endif
}
// we got two results, let's prioritize the faulty one and USB over FPC.
- if (reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
+ if (g_reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
#ifdef WITH_FPC_USART_HOST
- if (reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
+ if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
#endif
return PM3_SUCCESS;
}
@@ -112,7 +112,7 @@ static int reply_ng_internal(uint16_t cmd, int16_t status, uint8_t *data, size_t
PacketResponseNGPostamble *tx_post = (PacketResponseNGPostamble *)((uint8_t *)&txBufferNG + sizeof(PacketResponseNGPreamble) + len);
// Note: if we send to both FPC & USB, we'll set CRC for both if any of them require CRC
- if ((reply_via_fpc && reply_with_crc_on_fpc) || ((reply_via_usb) && reply_with_crc_on_usb)) {
+ if ((g_reply_via_fpc && g_reply_with_crc_on_fpc) || ((g_reply_via_usb) && g_reply_with_crc_on_usb)) {
uint8_t first, second;
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(PacketResponseNGPreamble) + len, &first, &second);
tx_post->crc = (first << 8) + second;
@@ -127,10 +127,10 @@ static int reply_ng_internal(uint16_t cmd, int16_t status, uint8_t *data, size_t
int resultusb = PM3_EUNDEF;
// Send frame and make sure all bytes are transmitted
- if (reply_via_usb) {
+ if (g_reply_via_usb) {
resultusb = usb_write((uint8_t *)&txBufferNG, txBufferNGLen);
}
- if (reply_via_fpc) {
+ if (g_reply_via_fpc) {
#ifdef WITH_FPC_USART_HOST
resultfpc = usart_writebuffer_sync((uint8_t *)&txBufferNG, txBufferNGLen);
#else
@@ -138,9 +138,9 @@ static int reply_ng_internal(uint16_t cmd, int16_t status, uint8_t *data, size_t
#endif
}
// we got two results, let's prioritize the faulty one and USB over FPC.
- if (reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
+ if (g_reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
#ifdef WITH_FPC_USART_HOST
- if (reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
+ if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
#endif
return PM3_SUCCESS;
}
@@ -216,8 +216,8 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
if ((first << 8) + second != rx->crc)
return PM3_EIO;
}
- reply_via_usb = usb;
- reply_via_fpc = fpc;
+ g_reply_via_usb = usb;
+ g_reply_via_fpc = fpc;
} else { // Old style command
PacketCommandOLD rx_old;
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketCommandNGPreamble));
@@ -225,8 +225,8 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
if (bytes != sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble))
return PM3_EIO;
- reply_via_usb = usb;
- reply_via_fpc = fpc;
+ g_reply_via_usb = usb;
+ g_reply_via_fpc = fpc;
rx->ng = false;
rx->magic = 0;
rx->crc = 0;
diff --git a/armsrc/cmd.h b/armsrc/cmd.h
index e04f397a3..f4ae95ab1 100644
--- a/armsrc/cmd.h
+++ b/armsrc/cmd.h
@@ -37,11 +37,11 @@
#include "pm3_cmd.h"
// Flags to tell where to add CRC on sent replies
-extern bool reply_with_crc_on_usb;
-extern bool reply_with_crc_on_fpc;
+extern bool g_reply_with_crc_on_usb;
+extern bool g_reply_with_crc_on_fpc;
// "Session" flag, to tell via which interface next msgs should be sent: USB and/or FPC USART
-extern bool reply_via_fpc;
-extern bool reply_via_usb;
+extern bool g_reply_via_fpc;
+extern bool g_reply_via_usb;
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
int reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len);
diff --git a/armsrc/dbprint.h b/armsrc/dbprint.h
index 2a8444ef3..993e06289 100644
--- a/armsrc/dbprint.h
+++ b/armsrc/dbprint.h
@@ -15,31 +15,31 @@
#include "ansi.h"
#define Dbprintf_usb(...) {\
- bool tmpfpc = reply_via_fpc;\
- bool tmpusb = reply_via_usb;\
- reply_via_fpc = false;\
- reply_via_usb = true;\
+ bool tmpfpc = g_reply_via_fpc;\
+ bool tmpusb = g_reply_via_usb;\
+ g_reply_via_fpc = false;\
+ g_reply_via_usb = true;\
Dbprintf(__VA_ARGS__);\
- reply_via_fpc = tmpfpc;\
- reply_via_usb = tmpusb;}
+ g_reply_via_fpc = tmpfpc;\
+ g_reply_via_usb = tmpusb;}
#define Dbprintf_fpc(...) {\
- bool tmpfpc = reply_via_fpc;\
- bool tmpusb = reply_via_usb;\
- reply_via_fpc = true;\
- reply_via_usb = false;\
+ bool tmpfpc = g_reply_via_fpc;\
+ bool tmpusb = g_reply_via_usb;\
+ g_reply_via_fpc = true;\
+ g_reply_via_usb = false;\
Dbprintf(__VA_ARGS__);\
- reply_via_fpc = tmpfpc;\
- reply_via_usb = tmpusb;}
+ g_reply_via_fpc = tmpfpc;\
+ g_reply_via_usb = tmpusb;}
#define Dbprintf_all(...) {\
- bool tmpfpc = reply_via_fpc;\
- bool tmpusb = reply_via_usb;\
- reply_via_fpc = true;\
- reply_via_usb = true;\
+ bool tmpfpc = g_reply_via_fpc;\
+ bool tmpusb = g_reply_via_usb;\
+ g_reply_via_fpc = true;\
+ g_reply_via_usb = true;\
Dbprintf(__VA_ARGS__);\
- reply_via_fpc = tmpfpc;\
- reply_via_usb = tmpusb;}
+ g_reply_via_fpc = tmpfpc;\
+ g_reply_via_usb = tmpusb;}
void DbpString(const char *str);
diff --git a/armsrc/felica.c b/armsrc/felica.c
index e72051bdc..f8375f0cc 100644
--- a/armsrc/felica.c
+++ b/armsrc/felica.c
@@ -35,7 +35,7 @@ static uint32_t felica_lasttime_prox2air_start;
static void iso18092_setup(uint8_t fpga_minor_mode);
static uint8_t felica_select_card(felica_card_select_t *card);
static void TransmitFor18092_AsReader(uint8_t *frame, int len, uint32_t *timing, uint8_t power, uint8_t highspeed);
-bool WaitForFelicaReply(uint16_t maxbytes);
+static bool WaitForFelicaReply(uint16_t maxbytes);
static void iso18092_set_timeout(uint32_t timeout) {
felica_timeout = timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER) / (16 * 8) + 2;
diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c
index 03aedc7a1..c22b04e70 100644
--- a/armsrc/hitag2.c
+++ b/armsrc/hitag2.c
@@ -48,8 +48,8 @@ static bool bCrypto;
// Is in auth stage
static bool bAuthenticating;
// Successful password auth
-bool bSelecting;
-bool bCollision;
+static bool bSelecting;
+static bool bCollision;
static bool bPwd;
static bool bSuccessful;
@@ -89,14 +89,14 @@ static uint8_t password[4];
static uint8_t NrAr[8];
static uint8_t key[8];
static uint8_t writedata[4];
-uint8_t logdata_0[4], logdata_1[4];
-uint8_t nonce[4];
-bool key_no;
+static uint8_t logdata_0[4], logdata_1[4];
+static uint8_t nonce[4];
+static bool key_no;
static uint64_t cipher_state;
-int16_t blocknr;
-size_t flipped_bit = 0;
-uint32_t byte_value = 0;
+static int16_t blocknr;
+static size_t flipped_bit = 0;
+static uint32_t byte_value = 0;
static int hitag2_reset(void) {
tag.state = TAG_STATE_RESET;
@@ -997,7 +997,7 @@ void SniffHitag2(void) {
lf_init(false, false);
- logging = false;
+ g_logging = false;
size_t periods = 0;
uint8_t periods_bytes[4];
@@ -1031,8 +1031,8 @@ void SniffHitag2(void) {
// Test if we detected the first reader modulation edge
if (periods != 0) {
- if (logging == false) {
- logging = true;
+ if (g_logging == false) {
+ g_logging = true;
LED_D_ON();
}
}
diff --git a/armsrc/hitag2crack.c b/armsrc/hitag2crack.c
index faf530897..a79c166d6 100644
--- a/armsrc/hitag2crack.c
+++ b/armsrc/hitag2crack.c
@@ -17,9 +17,9 @@
#define READP0CMD "1100000111"
#define ERROR_RESPONSE "F402889C"
-extern const uint8_t Hitag2Sync[5];
-extern bool CryptoActive;
-extern Hitag_State Hitag_Crypto_State;
+static const uint8_t Hitag2Sync[5];
+static bool CryptoActive;
+static Hitag_State Hitag_Crypto_State;
// hitag2_crack implements the first crack algorithm described in the paper,
// Gone In 360 Seconds by Verdult, Garcia and Balasch.
diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c
index 81ed771b4..10c889fa7 100644
--- a/armsrc/hitagS.c
+++ b/armsrc/hitagS.c
@@ -48,8 +48,7 @@ static int temp2 = 0;
static int sof_bits; // number of start-of-frame bits
static uint8_t pwdh0, pwdl0, pwdl1; // password bytes
static uint32_t rnd = 0x74124485; // randomnumber
-size_t blocknr;
-bool end = false;
+static bool end = false;
//#define SENDBIT_TEST
/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3
diff --git a/armsrc/iclass.c b/armsrc/iclass.c
index cca922a29..1e9bb671f 100644
--- a/armsrc/iclass.c
+++ b/armsrc/iclass.c
@@ -1802,7 +1802,7 @@ static void ReaderTransmitIClass_ext(uint8_t *frame, int len, int wait) {
TransmitIClassCommand(ToSend, ToSendMax, &wait);
LED_A_ON();
- LogTrace(frame, len, rsamples, rsamples, NULL, true);
+ LogTrace(frame, len, g_rsamples, g_rsamples, NULL, true);
}
static void ReaderTransmitIClass(uint8_t *frame, int len) {
ReaderTransmitIClass_ext(frame, len, 330);
@@ -1867,7 +1867,7 @@ static int ReaderReceiveIClass(uint8_t *receivedAnswer) {
if (GetIClassAnswer(receivedAnswer, 0, NULL) == false)
return 0;
- LogTrace(receivedAnswer, Demod.len, rsamples, rsamples, NULL, false);
+ LogTrace(receivedAnswer, Demod.len, g_rsamples, g_rsamples, NULL, false);
return Demod.len;
}
diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c
index 1d2ed655a..499932f0a 100644
--- a/armsrc/iso14443a.c
+++ b/armsrc/iso14443a.c
@@ -31,9 +31,9 @@ static uint32_t iso14a_timeout;
// if iso14443a not active - transmit/receive dont try to execute
static bool hf_field_active = false;
-uint8_t colpos = 0;
-int rsamples = 0;
-uint8_t trigger = 0;
+static uint8_t colpos = 0;
+int g_rsamples = 0;
+uint8_t g_trigger = 0;
// the block number for the ISO14443-4 PCB
static uint8_t iso14_pcb_blocknum = 0;
@@ -123,7 +123,7 @@ static uint32_t LastProxToAirDuration;
#define SEC_Z 0xc0
void iso14a_set_trigger(bool enable) {
- trigger = enable;
+ g_trigger = enable;
}
void iso14a_set_timeout(uint32_t timeout) {
@@ -2145,7 +2145,7 @@ void ReaderTransmitBitsPar(uint8_t *frame, uint16_t bits, uint8_t *par, uint32_t
CodeIso14443aBitsAsReaderPar(frame, bits, par);
// Send command to tag
TransmitFor14443a(ToSend, ToSendMax, timing);
- if (trigger) LED_A_ON();
+ if (g_trigger) LED_A_ON();
LogTrace(frame, nbytes(bits), (LastTimeProxToAirStart << 4) + DELAY_ARM2AIR_AS_READER, ((LastTimeProxToAirStart + LastProxToAirDuration) << 4) + DELAY_ARM2AIR_AS_READER, par, true);
}
diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c
index 7aa3e981e..b03e84912 100644
--- a/armsrc/iso14443b.c
+++ b/armsrc/iso14443b.c
@@ -1150,7 +1150,7 @@ static void CodeAndTransmit14443bAsReader(const uint8_t *cmd, int len) {
TransmitFor14443b_AsReader();
- if (trigger) LED_A_ON();
+ if (g_trigger) LED_A_ON();
LogTrace(cmd, len, time_start, GetCountSspClk() - time_start, NULL, true);
}
@@ -1578,7 +1578,7 @@ void RAMFUNC SniffIso14443b(void) {
}
static void iso14b_set_trigger(bool enable) {
- trigger = enable;
+ g_trigger = enable;
}
/*
diff --git a/armsrc/lfadc.c b/armsrc/lfadc.c
index 461a74783..078745dd8 100644
--- a/armsrc/lfadc.c
+++ b/armsrc/lfadc.c
@@ -25,13 +25,18 @@
// T0 = timer/carrier = 1500kHz/125kHz = 1500000/125000 = 6
//#define HITAG_T0 3
+//////////////////////////////////////////////////////////////////////////////
+// Exported global variables
+//////////////////////////////////////////////////////////////////////////////
+
+bool g_logging = true;
+
//////////////////////////////////////////////////////////////////////////////
// Global variables
//////////////////////////////////////////////////////////////////////////////
-bool rising_edge = false;
-bool logging = true;
-bool reader_mode = false;
+static bool rising_edge = false;
+static bool reader_mode = false;
//////////////////////////////////////////////////////////////////////////////
// Auxiliary functions
@@ -90,7 +95,7 @@ static size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
adc_val = AT91C_BASE_SSC->SSC_RHR;
periods++;
- if (logging) logSampleSimple(adc_val);
+ if (g_logging) logSampleSimple(adc_val);
// Only test field changes if state of adc values matter
if (wait == false) {
@@ -120,7 +125,7 @@ static size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
if (periods >= max) return 0;
}
}
- if (logging) logSampleSimple(0xFF);
+ if (g_logging) logSampleSimple(0xFF);
return 0;
}
@@ -223,7 +228,7 @@ void lf_init(bool reader, bool simulate) {
uint32_t bufsize = 10000;
// use malloc
- if (logging) initSampleBufferEx(&bufsize, true);
+ if (g_logging) initSampleBufferEx(&bufsize, true);
lf_sample_mean();
}
@@ -269,7 +274,7 @@ size_t lf_detect_field_drop(size_t max) {
periods++;
volatile uint8_t adc_val = AT91C_BASE_SSC->SSC_RHR;
- if (logging) logSampleSimple(adc_val);
+ if (g_logging) logSampleSimple(adc_val);
if (adc_val == 0) {
rising_edge = false;
diff --git a/armsrc/lfadc.h b/armsrc/lfadc.h
index 2238e2eb5..1c8a4211f 100644
--- a/armsrc/lfadc.h
+++ b/armsrc/lfadc.h
@@ -15,7 +15,7 @@
#include "util.h"
#include "string.h"
-extern bool logging;
+extern bool g_logging;
void lf_sample_mean(void);
bool lf_test_periods(size_t expected, size_t count);
diff --git a/armsrc/lfops.h b/armsrc/lfops.h
index b697cffd1..eb31e54a6 100644
--- a/armsrc/lfops.h
+++ b/armsrc/lfops.h
@@ -15,10 +15,6 @@
#include "pm3_cmd.h" // struct
-extern uint8_t decimation;
-extern uint8_t bits_per_sample ;
-extern bool averaging;
-
void AcquireRawAdcSamples125k(int divisor);
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command);
void ReadTItag(void);
diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c
index cddf9cbbc..feaa45b3d 100644
--- a/armsrc/lfsampling.c
+++ b/armsrc/lfsampling.c
@@ -27,7 +27,7 @@ Default LF config is set to:
samples_to_skip = 0
verbose = YES
*/
-sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, 1} ;
+static sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, 1} ;
void printConfig(void) {
uint32_t d = config.divisor;
diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c
index 57235ba22..e96d6b3d9 100644
--- a/armsrc/mifaredesfire.c
+++ b/armsrc/mifaredesfire.c
@@ -25,7 +25,7 @@
#define RECEIVE_SIZE 64
// the block number for the ISO14443-4 PCB
-uint8_t pcb_blocknum = 0;
+static uint8_t pcb_blocknum = 0;
// Deselect card by sending a s-block. the crc is precalced for speed
static uint8_t deselect_cmd[] = {0xc2, 0xe0, 0xb4};
diff --git a/armsrc/printf.c b/armsrc/printf.c
index 0dffbb037..2d18a9c53 100644
--- a/armsrc/printf.c
+++ b/armsrc/printf.c
@@ -47,7 +47,7 @@ typedef int ssize_t;
#define NBBY 8 /* number of bits in a byte */
-char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
#define hex2ascii(hex) (hex2ascii_data[hex])
#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
diff --git a/armsrc/usart.c b/armsrc/usart.c
index 2062c9441..203572f90 100644
--- a/armsrc/usart.c
+++ b/armsrc/usart.c
@@ -15,8 +15,8 @@ volatile AT91PS_USART pUS1 = AT91C_BASE_US1;
volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_US1;
-uint32_t usart_baudrate = 0;
-uint8_t usart_parity = 0;
+uint32_t g_usart_baudrate = 0;
+uint8_t g_usart_parity = 0;
/*
void usart_close(void) {
// Reset the USART mode
@@ -41,8 +41,8 @@ void usart_close(void) {
static uint8_t us_inbuf1[USART_BUFFLEN];
static uint8_t us_inbuf2[USART_BUFFLEN];
-uint8_t *usart_cur_inbuf = NULL;
-uint16_t usart_cur_inbuf_off = 0;
+static uint8_t *usart_cur_inbuf = NULL;
+static uint16_t usart_cur_inbuf_off = 0;
static uint8_t us_rxfifo[USART_FIFOLEN];
static size_t us_rxfifo_low = 0;
static size_t us_rxfifo_high = 0;
@@ -166,9 +166,9 @@ inline int usart_writebuffer_sync(uint8_t *data, size_t len) {
void usart_init(uint32_t baudrate, uint8_t parity) {
if (baudrate != 0)
- usart_baudrate = baudrate;
+ g_usart_baudrate = baudrate;
if ((parity == 'N') || (parity == 'O') || (parity == 'E'))
- usart_parity = parity;
+ g_usart_parity = parity;
// For a nice detailed sample, interrupt driven but still relevant.
// See https://www.sparkfun.com/datasheets/DevTools/SAM7/at91sam7%20serial%20communications.pdf
@@ -197,7 +197,7 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
AT91C_US_NBSTOP_1_BIT | // 1 stop bit
AT91C_US_CHMODE_NORMAL; // channel mode: normal
- switch (usart_parity) {
+ switch (g_usart_parity) {
case 'N':
mode |= AT91C_US_PAR_NONE; // parity: none
break;
@@ -227,9 +227,9 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
// OVER = 1, -yes we are oversampling
// baudrate == selected clock/8/CD --> this is ours
//
- uint32_t brgr = MCK / (usart_baudrate << 3);
- // doing fp = round((mck / (usart_baudrate << 3) - brgr) * 8) with integers:
- uint32_t fp = ((16 * MCK / (usart_baudrate << 3) - 16 * brgr) + 1) / 2;
+ uint32_t brgr = MCK / (g_usart_baudrate << 3);
+ // doing fp = round((mck / (g_usart_baudrate << 3) - brgr) * 8) with integers:
+ uint32_t fp = ((16 * MCK / (g_usart_baudrate << 3) - 16 * brgr) + 1) / 2;
pUS1->US_BRGR = (fp << 16) | brgr;
diff --git a/armsrc/usart.h b/armsrc/usart.h
index 01ca0d809..5a7dea38f 100644
--- a/armsrc/usart.h
+++ b/armsrc/usart.h
@@ -9,8 +9,8 @@
// Higher baudrates are pointless, only increasing overflow risk
-extern uint32_t usart_baudrate;
-extern uint8_t usart_parity;
+extern uint32_t g_usart_baudrate;
+extern uint8_t g_usart_parity;
void usart_init(uint32_t baudrate, uint8_t parity);
int usart_writebuffer_sync(uint8_t *data, size_t len);
From 47634f555037a80266d5634bef7fc59e6501537b Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 17:15:07 +0200
Subject: [PATCH 051/527] change: remove inline directive in armsrc, since we
are optimizing for size
---
armsrc/desfire_crypto.c | 4 ++--
armsrc/legicrf.c | 13 ++-----------
armsrc/legicrfsim.c | 10 +---------
armsrc/nprintf.c | 12 ++++++------
4 files changed, 11 insertions(+), 28 deletions(-)
diff --git a/armsrc/desfire_crypto.c b/armsrc/desfire_crypto.c
index db543bbe6..cafa98de1 100644
--- a/armsrc/desfire_crypto.c
+++ b/armsrc/desfire_crypto.c
@@ -46,9 +46,9 @@ static mbedtls_des_context ctx;
static mbedtls_des3_context ctx3;
static mbedtls_aes_context actx;
-static inline void update_key_schedules(desfirekey_t key);
+static void update_key_schedules(desfirekey_t key);
-static inline void update_key_schedules(desfirekey_t key) {
+static void update_key_schedules(desfirekey_t key) {
// DES_set_key ((DES_cblock *)key->data, &(key->ks1));
// DES_set_key ((DES_cblock *)(key->data + 8), &(key->ks2));
// if (T_3K3DES == key->type) {
diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c
index 14298a5f1..21b0c0a42 100644
--- a/armsrc/legicrf.c
+++ b/armsrc/legicrf.c
@@ -64,8 +64,7 @@ static uint32_t last_frame_end; /* ts of last bit of previews rx or tx frame */
//-----------------------------------------------------------------------------
// I/O interface abstraction (FPGA -> ARM)
//-----------------------------------------------------------------------------
-
-static inline uint8_t rx_byte_from_fpga(void) {
+static uint8_t rx_byte_from_fpga(void) {
for (;;) {
WDT_HIT();
@@ -93,11 +92,7 @@ static inline uint8_t rx_byte_from_fpga(void) {
// Note: The SSC receiver is never synchronized the calculation may be performed
// on a i/q pair from two subsequent correlations, but does not matter.
// Note: inlining this function would fail with -Os
-#ifdef __OPTIMIZE_SIZE__
static int32_t sample_power(void) {
-#else
-static inline int32_t sample_power(void) {
-#endif
int32_t q = (int8_t)rx_byte_from_fpga();
q = ABS(q);
int32_t i = (int8_t)rx_byte_from_fpga();
@@ -115,11 +110,7 @@ static inline int32_t sample_power(void) {
// has a delay loop that aligns rx_bit calls to the TAG tx timeslots.
// Note: inlining this function would fail with -Os
-#ifdef __OPTIMIZE_SIZE__
static bool rx_bit(void) {
-#else
-static inline bool rx_bit(void) {
-#endif
int32_t power;
for (size_t i = 0; i < 5; ++i) {
@@ -138,7 +129,7 @@ static inline bool rx_bit(void) {
// be circumvented, but the adventage over bitbang would be little.
//-----------------------------------------------------------------------------
-static inline void tx_bit(bool bit) {
+static void tx_bit(bool bit) {
// insert pause
LOW(GPIO_SSC_DOUT);
last_frame_end += RWD_TIME_PAUSE;
diff --git a/armsrc/legicrfsim.c b/armsrc/legicrfsim.c
index e2b06ba9b..35eefc56c 100644
--- a/armsrc/legicrfsim.c
+++ b/armsrc/legicrfsim.c
@@ -66,11 +66,7 @@ static uint32_t last_frame_end; /* ts of last bit of previews rx or tx frame */
// Returns true if a pulse/pause is received within timeout
// Note: inlining this function would fail with -Os
-#ifdef __OPTIMIZE_SIZE__
static bool wait_for(bool value, const uint32_t timeout) {
-#else
-static inline bool wait_for(bool value, const uint32_t timeout) {
-#endif
while ((bool)(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_DIN) != value) {
if (GetCountSspClk() > timeout) {
return false;
@@ -88,7 +84,7 @@ static inline bool wait_for(bool value, const uint32_t timeout) {
// - A bit length >80.2us is a 1
// - A bit length <80.2us is a 0
// - A bit length >148.6us is a code violation
-static inline int8_t rx_bit(void) {
+static int8_t rx_bit(void) {
// backup ts for threshold calculation
uint32_t bit_start = last_frame_end;
@@ -132,11 +128,7 @@ static inline int8_t rx_bit(void) {
// not mandatory but results in a cleaner signal. tx_frame will disable
// the subcarrier when the frame is done.
// Note: inlining this function would fail with -Os
-#ifdef __OPTIMIZE_SIZE__
static void tx_bit(bool bit) {
-#else
-static inline void tx_bit(bool bit) {
-#endif
LED_C_ON();
if (bit) {
diff --git a/armsrc/nprintf.c b/armsrc/nprintf.c
index 645454b4e..1ce3842d3 100644
--- a/armsrc/nprintf.c
+++ b/armsrc/nprintf.c
@@ -127,7 +127,7 @@ typedef struct {
// internal buffer output
-static inline void _out_buffer(char character, void *buffer, size_t idx, size_t maxlen) {
+static void _out_buffer(char character, void *buffer, size_t idx, size_t maxlen) {
if (idx < maxlen) {
((char *)buffer)[idx] = character;
}
@@ -135,7 +135,7 @@ static inline void _out_buffer(char character, void *buffer, size_t idx, size_t
// internal null output
-static inline void _out_null(char character, void *buffer, size_t idx, size_t maxlen) {
+static void _out_null(char character, void *buffer, size_t idx, size_t maxlen) {
(void)character;
(void)buffer;
(void)idx;
@@ -144,7 +144,7 @@ static inline void _out_null(char character, void *buffer, size_t idx, size_t ma
// internal _putchar wrapper
-static inline void _out_char(char character, void *buffer, size_t idx, size_t maxlen) {
+static void _out_char(char character, void *buffer, size_t idx, size_t maxlen) {
(void)buffer;
(void)idx;
(void)maxlen;
@@ -155,7 +155,7 @@ static inline void _out_char(char character, void *buffer, size_t idx, size_t ma
// internal output function wrapper
-static inline void _out_fct(char character, void *buffer, size_t idx, size_t maxlen) {
+static void _out_fct(char character, void *buffer, size_t idx, size_t maxlen) {
(void)idx;
(void)maxlen;
if (character) {
@@ -167,7 +167,7 @@ static inline void _out_fct(char character, void *buffer, size_t idx, size_t max
// internal secure strlen
// \return The length of the string (excluding the terminating 0) limited by 'maxsize'
-static inline unsigned int _strnlen_s(const char *str, size_t maxsize) {
+static unsigned int _strnlen_s(const char *str, size_t maxsize) {
const char *s;
for (s = str; *s && maxsize--; ++s);
return (unsigned int)(s - str);
@@ -176,7 +176,7 @@ static inline unsigned int _strnlen_s(const char *str, size_t maxsize) {
// internal test if char is a digit (0-9)
// \return true if char is a digit
-static inline bool _is_digit(char ch) {
+static bool _is_digit(char ch) {
return (ch >= '0') && (ch <= '9');
}
From 4d355192bf5a51829a651104e757f2954d2c12e5 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 17:16:23 +0200
Subject: [PATCH 052/527] remove inline
---
armsrc/Standalone/hf_colin.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/armsrc/Standalone/hf_colin.c b/armsrc/Standalone/hf_colin.c
index 9752c66c3..d2075f38f 100644
--- a/armsrc/Standalone/hf_colin.c
+++ b/armsrc/Standalone/hf_colin.c
@@ -104,12 +104,7 @@ static const uint8_t is_hex[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-// Note: inlining this function would fail with -Os
-#ifdef __OPTIMIZE_SIZE__
static uint64_t hex2i(const char *s) {
-#else
-static inline uint64_t hex2i(const char *s) {
-#endif
uint64_t val = 0;
if (s == NULL || s[0] == 0)
return 0;
From 9c1cac905b02f2adcd0e3a5591dda2c9bddf2b3b Mon Sep 17 00:00:00 2001
From: FlUxIUS
Date: Tue, 19 May 2020 17:23:46 +0200
Subject: [PATCH 053/527] Somes traces
---
traces/hf_14a_reader.trace | Bin 0 -> 77 bytes
traces/hf_14b_reader.trace | Bin 0 -> 38 bytes
traces/hf_mdes_reader.trace | Bin 0 -> 105 bytes
3 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 traces/hf_14a_reader.trace
create mode 100644 traces/hf_14b_reader.trace
create mode 100644 traces/hf_mdes_reader.trace
diff --git a/traces/hf_14a_reader.trace b/traces/hf_14a_reader.trace
new file mode 100644
index 0000000000000000000000000000000000000000..6bf0ab7b6f37ebe555216a7c1dc43110a927f988
GIT binary patch
literal 77
zcmWHPW?*>0%*YVL(5lS9;K0e$z{22g(Tss%0Vfl~WQB%S7X}6fan^P=2!{Xw
literal 0
HcmV?d00001
diff --git a/traces/hf_mdes_reader.trace b/traces/hf_mdes_reader.trace
new file mode 100644
index 0000000000000000000000000000000000000000..2410bedefa59046dfa959c8259462f35818871d3
GIT binary patch
literal 105
zcmWHPW?*>0%*YVL(5lS9(7?gez{1RM(Tss%0Vfl~WQB%S7X}6fG1i8Kixw|oQMj1O
zz@VVX$uPM9%#T0Y$-p|9f#CoTbA!U40*8ysf%=447#=hj7BjT&14>A-HLyf9FbSVy
F004tW9cTam
literal 0
HcmV?d00001
From b55681077633076e1453ca26758dbec58f0bdbb8 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 17:25:50 +0200
Subject: [PATCH 054/527] armsrc: clarify static vars vs global vars, part 2
---
armsrc/Standalone/hf_colin.c | 16 ++++++++--------
armsrc/Standalone/hf_mattyrun.c | 18 +++++++++---------
armsrc/Standalone/hf_msdsal.c | 2 +-
armsrc/Standalone/lf_em4100emul.c | 8 +++-----
armsrc/Standalone/lf_em4100rswb.c | 12 ++++++------
armsrc/Standalone/lf_em4100rwc.c | 8 ++++----
armsrc/appmain.c | 4 +++-
armsrc/iso14443a.c | 2 +-
armsrc/lfadc.c | 4 ++--
armsrc/lfops.c | 8 ++++----
armsrc/mifarecmd.c | 6 +++---
armsrc/thinfilm.c | 2 +-
12 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/armsrc/Standalone/hf_colin.c b/armsrc/Standalone/hf_colin.c
index d2075f38f..0656d1186 100644
--- a/armsrc/Standalone/hf_colin.c
+++ b/armsrc/Standalone/hf_colin.c
@@ -81,12 +81,12 @@
*/
-uint8_t cjuid[10];
-uint32_t cjcuid;
-iso14a_card_select_t p_card;
-int currline;
-int currfline;
-int curlline;
+static uint8_t cjuid[10];
+static uint32_t cjcuid;
+static iso14a_card_select_t p_card;
+static int currline;
+static int currfline;
+static int curlline;
// TODO : Implement fast read of KEYS like in RFIdea
// also http://ext.delaat.net/rp/2015-2016/p04/report.pdf
@@ -162,7 +162,7 @@ static void scan_keys(const char *str, int len, uint64_t *user_data) {
}
}
-MFC1KSchema Schemas[MAX_SCHEMAS];
+static MFC1KSchema Schemas[MAX_SCHEMAS];
/*MFC1KSchema Noralsy = {
.name = "Noralsy",
@@ -196,7 +196,7 @@ MFC1KSchema InfiHexact = {.name = "Infineon/Hexact",
0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76}};
*/
-int total_schemas = 0;
+static int total_schemas = 0;
static void add_schema(MFC1KSchema *p, MFC1KSchema a, int *schemas_counter) {
if (*schemas_counter < MAX_SCHEMAS) {
diff --git a/armsrc/Standalone/hf_mattyrun.c b/armsrc/Standalone/hf_mattyrun.c
index ae81eb408..1ffa321a3 100644
--- a/armsrc/Standalone/hf_mattyrun.c
+++ b/armsrc/Standalone/hf_mattyrun.c
@@ -49,19 +49,19 @@ on a blank card.
#include "mifaresim.h" // mifare1ksim
#include "mifareutil.h"
-uint8_t uid[10];
-uint32_t cuid;
-iso14a_card_select_t p_card;
+static uint8_t uid[10];
+static uint32_t cuid;
+static iso14a_card_select_t p_card;
/*
Pseudo-configuration block.
*/
-bool printKeys = false; // Prints keys
-bool transferToEml = true; // Transfer keys to emulator memory
-bool ecfill = true; // Fill emulator memory with cards content.
-bool simulation = true; // Simulates an exact copy of the target tag
-bool fillFromEmulator = false; // Dump emulator memory.
-uint8_t stKeyBlock = 20; // Set the quantity of keys in the block.
+static bool printKeys = false; // Prints keys
+static bool transferToEml = true; // Transfer keys to emulator memory
+static bool ecfill = true; // Fill emulator memory with cards content.
+static bool simulation = true; // Simulates an exact copy of the target tag
+static bool fillFromEmulator = false; // Dump emulator memory.
+static uint8_t stKeyBlock = 20; // Set the quantity of keys in the block.
//-----------------------------------------------------------------------------
// Matt's StandAlone mod.
diff --git a/armsrc/Standalone/hf_msdsal.c b/armsrc/Standalone/hf_msdsal.c
index e890818d2..e9f700a01 100644
--- a/armsrc/Standalone/hf_msdsal.c
+++ b/armsrc/Standalone/hf_msdsal.c
@@ -52,7 +52,7 @@ void ModInfo(void) {
* technologies. Be brave enough to share your knowledge & inspire others. Salvador Mendoza.
*/
-uint8_t ppdol [255] = {0x80, 0xA8, 0x00, 0x00, 0x02, 0x83, 0x00}; // Default GET PROCESSING
+static uint8_t ppdol [255] = {0x80, 0xA8, 0x00, 0x00, 0x02, 0x83, 0x00}; // Default GET PROCESSING
static uint8_t treatPDOL(uint8_t *apdu) { //Generate GET PROCESSING
uint8_t plen = 7;
diff --git a/armsrc/Standalone/lf_em4100emul.c b/armsrc/Standalone/lf_em4100emul.c
index 6ad2580a4..e6ac2f6ff 100644
--- a/armsrc/Standalone/lf_em4100emul.c
+++ b/armsrc/Standalone/lf_em4100emul.c
@@ -25,11 +25,9 @@
// low & high - array for storage IDs. Its length must be equal.
// Predefined IDs must be stored in low[].
-// In high[] must be nulls
-uint64_t low[] = {0x565A1140BE, 0x365A398149, 0x5555555555, 0xFFFFFFFFFF};
-uint32_t high[] = {0, 0, 0, 0};
-uint8_t *bba, slots_count;
-int buflen;
+static uint64_t low[] = {0x565A1140BE, 0x365A398149, 0x5555555555, 0xFFFFFFFFFF};
+static uint8_t *bba, slots_count;
+static int buflen;
void ModInfo(void) {
DbpString(" LF EM4100 simulator standalone mode");
diff --git a/armsrc/Standalone/lf_em4100rswb.c b/armsrc/Standalone/lf_em4100rswb.c
index dd9fafd6a..ac470ce29 100644
--- a/armsrc/Standalone/lf_em4100rswb.c
+++ b/armsrc/Standalone/lf_em4100rswb.c
@@ -68,16 +68,16 @@
// Predefined bruteforce speed
// avg: 1s, 1.2s, 1.5s, 2s
-int bruteforceSpeedCurrent = 1;
-int bruteforceSpeed[] = {10, 12, 14, 16};
+static int bruteforceSpeedCurrent = 1;
+static int bruteforceSpeed[] = {10, 12, 14, 16};
// low & high - array for storage IDs. Its length must be equal.
// Predefined IDs must be stored in low[].
// In high[] must be nulls
-uint64_t low[] = {0, 0, 0, 0};
-uint32_t high[] = {0, 0, 0, 0};
-uint8_t *bba;
-int buflen;
+static uint64_t low[] = {0, 0, 0, 0};
+static uint32_t high[] = {0, 0, 0, 0};
+static uint8_t *bba;
+static int buflen;
void ModInfo(void) {
DbpString(" LF EM4100 read/sim/write/brute mode");
diff --git a/armsrc/Standalone/lf_em4100rwc.c b/armsrc/Standalone/lf_em4100rwc.c
index ce96dd824..f69820513 100644
--- a/armsrc/Standalone/lf_em4100rwc.c
+++ b/armsrc/Standalone/lf_em4100rwc.c
@@ -39,10 +39,10 @@
// low & high - array for storage IDs. Its length must be equal.
// Predefined IDs must be stored in low[].
// In high[] must be nulls
-uint64_t low[] = {0x565AF781C7, 0x540053E4E2, 0x1234567890, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-uint32_t high[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-uint8_t *bba, slots_count;
-int buflen;
+static uint64_t low[] = {0x565AF781C7, 0x540053E4E2, 0x1234567890, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static uint32_t high[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static uint8_t *bba, slots_count;
+static int buflen;
void ModInfo(void) {
DbpString(" LF EM4100 read/write/clone mode");
diff --git a/armsrc/appmain.c b/armsrc/appmain.c
index 87b3dd0df..fa9aaf0f6 100644
--- a/armsrc/appmain.c
+++ b/armsrc/appmain.c
@@ -70,9 +70,11 @@
#define TOSEND_BUFFER_SIZE (9*MAX_FRAME_SIZE + 1 + 1 + 2) // 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits
uint8_t ToSend[TOSEND_BUFFER_SIZE];
int ToSendMax = -1;
+
+
static int ToSendBit;
struct common_area common_area __attribute__((section(".commonarea")));
-int button_status = BUTTON_NO_CLICK;
+static int button_status = BUTTON_NO_CLICK;
static bool allow_send_wtx = false;
inline void send_wtx(uint16_t wtx) {
diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c
index 499932f0a..c39576c27 100644
--- a/armsrc/iso14443a.c
+++ b/armsrc/iso14443a.c
@@ -67,7 +67,7 @@ static uint8_t iso14_pcb_blocknum = 0;
#define DELAY_ARM2AIR_AS_READER (4*16 + 8*16 + 8 + 8 + 1)
// The FPGA will report its internal sending delay in
-uint16_t FpgaSendQueueDelay;
+static uint16_t FpgaSendQueueDelay;
// the 5 first bits are the number of bits buffered in mod_sig_buf
// the last three bits are the remaining ticks/2 after the mod_sig_buf shift
#define DELAY_FPGA_QUEUE (FpgaSendQueueDelay<<1)
diff --git a/armsrc/lfadc.c b/armsrc/lfadc.c
index 078745dd8..cec945b20 100644
--- a/armsrc/lfadc.c
+++ b/armsrc/lfadc.c
@@ -51,8 +51,8 @@ bool lf_test_periods(size_t expected, size_t count) {
//////////////////////////////////////////////////////////////////////////////
// Low frequency (LF) adc passthrough functionality
//////////////////////////////////////////////////////////////////////////////
-uint8_t previous_adc_val = 0;
-uint8_t adc_avg = 0;
+static uint8_t previous_adc_val = 0;
+static uint8_t adc_avg = 0;
void lf_sample_mean(void) {
uint8_t periods = 0;
diff --git a/armsrc/lfops.c b/armsrc/lfops.c
index 7eececdc9..9ef3a34a8 100644
--- a/armsrc/lfops.c
+++ b/armsrc/lfops.c
@@ -2289,10 +2289,10 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo) {
#define FWD_CMD_READ 0x9
#define FWD_CMD_DISABLE 0x5
-uint8_t forwardLink_data[64]; //array of forwarded bits
-uint8_t *forward_ptr; //ptr for forward message preparation
-uint8_t fwd_bit_sz; //forwardlink bit counter
-uint8_t *fwd_write_ptr; //forwardlink bit pointer
+static uint8_t forwardLink_data[64]; //array of forwarded bits
+static uint8_t *forward_ptr; //ptr for forward message preparation
+static uint8_t fwd_bit_sz; //forwardlink bit counter
+static uint8_t *fwd_write_ptr; //forwardlink bit pointer
//====================================================================
// prepares command bits
diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c
index 79efc8b9f..b98526726 100644
--- a/armsrc/mifarecmd.c
+++ b/armsrc/mifarecmd.c
@@ -2008,9 +2008,9 @@ out:
// bit 6 - wipe tag.
//-----------------------------------------------------------------------------
// magic uid card generation 1 commands
-uint8_t wupC1[] = { MIFARE_MAGICWUPC1 };
-uint8_t wupC2[] = { MIFARE_MAGICWUPC2 };
-uint8_t wipeC[] = { MIFARE_MAGICWIPEC };
+static uint8_t wupC1[] = { MIFARE_MAGICWUPC1 };
+static uint8_t wupC2[] = { MIFARE_MAGICWUPC2 };
+static uint8_t wipeC[] = { MIFARE_MAGICWIPEC };
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
diff --git a/armsrc/thinfilm.c b/armsrc/thinfilm.c
index d84c2711a..a77a70744 100644
--- a/armsrc/thinfilm.c
+++ b/armsrc/thinfilm.c
@@ -49,7 +49,7 @@ void ReadThinFilm(void) {
#define SEC_D 0xf0
#define SEC_E 0x0f
#define SEC_F 0x00
-uint16_t FpgaSendQueueDelay;
+static uint16_t FpgaSendQueueDelay;
static uint16_t ReadReaderField(void) {
#if defined RDV4
From cb8d589fc4b5ec1a06a9a0d37a5ef029f779ee30 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 17:43:13 +0200
Subject: [PATCH 055/527] armsrc: clarify static vars vs global vars, part 3
---
armsrc/Makefile | 2 +-
armsrc/appmain.c | 6 +++---
armsrc/flashmem.c | 4 ++--
armsrc/flashmem.h | 2 --
armsrc/fpgaloader.c | 4 ++--
armsrc/i2c.c | 2 +-
armsrc/iso14443a.c | 6 +++---
armsrc/lfsampling.c | 4 ++--
armsrc/mifaredesfire.c | 2 +-
client/src/cmdflashmem.c | 2 --
common/legic_prng.c | 2 +-
common/parity.c | 4 ++--
common_arm/usb_cdc.c | 6 +++---
common_fpga/fpga.h | 4 ++--
include/pmflash.h | 3 ---
tools/fpga_compress/fpga_compress.c | 4 ++--
16 files changed, 25 insertions(+), 32 deletions(-)
diff --git a/armsrc/Makefile b/armsrc/Makefile
index 16c6a7f9e..15cfaddfd 100644
--- a/armsrc/Makefile
+++ b/armsrc/Makefile
@@ -157,7 +157,7 @@ version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o
$(info [-] GEN $@)
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
-fpga_version_info.c: $(FPGA_BITSTREAMS) | $(FPGA_COMPRESSOR)
+fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
$(info [-] GEN $@)
$(Q)$(FPGA_COMPRESSOR) -v $(filter %.bit,$^) $@
diff --git a/armsrc/appmain.c b/armsrc/appmain.c
index fa9aaf0f6..40f8c0ad1 100644
--- a/armsrc/appmain.c
+++ b/armsrc/appmain.c
@@ -278,9 +278,9 @@ static void SendVersion(void) {
strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1);
- for (int i = 0; i < fpga_bitstream_num; i++) {
- strncat(VersionString, fpga_version_information[i], sizeof(VersionString) - strlen(VersionString) - 1);
- if (i < fpga_bitstream_num - 1) {
+ for (int i = 0; i < g_fpga_bitstream_num; i++) {
+ strncat(VersionString, g_fpga_version_information[i], sizeof(VersionString) - strlen(VersionString) - 1);
+ if (i < g_fpga_bitstream_num - 1) {
strncat(VersionString, "\n ", sizeof(VersionString) - strlen(VersionString) - 1);
}
}
diff --git a/armsrc/flashmem.c b/armsrc/flashmem.c
index 80f20e105..66b4813e4 100644
--- a/armsrc/flashmem.c
+++ b/armsrc/flashmem.c
@@ -16,8 +16,8 @@
/// Calculates the value of the CSR DLYBCT field given the desired delay (in ns)
#define SPI_DLYBCT(delay, masterClock) ((uint32_t) ((((masterClock) / 1000000) * (delay)) / 32000) << 24)
-
-uint32_t FLASHMEM_SPIBAUDRATE = FLASH_BAUD;
+static uint32_t FLASHMEM_SPIBAUDRATE = FLASH_BAUD;
+#define FASTFLASH (FLASHMEM_SPIBAUDRATE > FLASH_MINFAST)
void FlashmemSetSpiBaudrate(uint32_t baudrate) {
FLASHMEM_SPIBAUDRATE = baudrate;
diff --git a/armsrc/flashmem.h b/armsrc/flashmem.h
index e5a4e0459..54a101ea6 100644
--- a/armsrc/flashmem.h
+++ b/armsrc/flashmem.h
@@ -106,8 +106,6 @@
#define FLASH_FASTBAUD MCK
#define FLASH_MINBAUD FLASH_FASTBAUD
-#define FASTFLASH (FLASHMEM_SPIBAUDRATE > FLASH_MINFAST)
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
void FlashmemSetSpiBaudrate(uint32_t baudrate);
diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c
index a5ca3f6d1..196364d98 100644
--- a/armsrc/fpgaloader.c
+++ b/armsrc/fpgaloader.c
@@ -203,7 +203,7 @@ static int get_from_fpga_combined_stream(z_streamp compressed_fpga_stream, uint8
// 288 bytes from FPGA file 1, followed by 288 bytes from FGPA file 2, etc.
//----------------------------------------------------------------------------
static int get_from_fpga_stream(int bitstream_version, z_streamp compressed_fpga_stream, uint8_t *output_buffer) {
- while ((uncompressed_bytes_cnt / FPGA_INTERLEAVE_SIZE) % fpga_bitstream_num != (bitstream_version - 1)) {
+ while ((uncompressed_bytes_cnt / FPGA_INTERLEAVE_SIZE) % g_fpga_bitstream_num != (bitstream_version - 1)) {
// skip undesired data belonging to other bitstream_versions
get_from_fpga_combined_stream(compressed_fpga_stream, output_buffer);
}
@@ -509,7 +509,7 @@ void SetAdcMuxFor(uint32_t whichGpio) {
void Fpga_print_status(void) {
DbpString(_BLUE_("Currently loaded FPGA image"));
- Dbprintf(" mode....................%s", fpga_version_information[downloaded_bitstream - 1]);
+ Dbprintf(" mode....................%s", g_fpga_version_information[downloaded_bitstream - 1]);
}
int FpgaGetCurrent(void) {
diff --git a/armsrc/i2c.c b/armsrc/i2c.c
index 4a3d0dc08..e3e84690e 100644
--- a/armsrc/i2c.c
+++ b/armsrc/i2c.c
@@ -32,7 +32,7 @@
#define I2C_ERROR "I2C_WaitAck Error"
-volatile unsigned long c;
+static volatile unsigned long c;
// Direct use the loop to delay. 6 instructions loop, Masterclock 48MHz,
// delay=1 is about 200kbps
diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c
index c39576c27..a657dff35 100644
--- a/armsrc/iso14443a.c
+++ b/armsrc/iso14443a.c
@@ -184,7 +184,7 @@ static tUart14a Uart;
// 0011 - a 2 tick wide pause, or a three tick wide pause shifted left
// 0111 - a 2 tick wide pause shifted left
// 1001 - a 2 tick wide pause shifted right
-const bool Mod_Miller_LUT[] = {
+static const bool Mod_Miller_LUT[] = {
false, true, false, true, false, false, false, true,
false, true, false, false, false, false, false, false
};
@@ -351,11 +351,11 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) {
// 8 ticks modulated: A collision. Save the collision position and treat as Sequence D
// Note 1: the bitstream may start at any time. We therefore need to sync.
// Note 2: parameter offset is used to determine the position of the parity bits (required for the anticollision command only)
-tDemod14a Demod;
+static tDemod14a Demod;
// Lookup-Table to decide if 4 raw bits are a modulation.
// We accept three or four "1" in any position
-const bool Mod_Manchester_LUT[] = {
+static const bool Mod_Manchester_LUT[] = {
false, false, false, false, false, false, false, true,
false, false, false, true, false, true, true, true
};
diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c
index feaa45b3d..6365a0967 100644
--- a/armsrc/lfsampling.c
+++ b/armsrc/lfsampling.c
@@ -100,10 +100,10 @@ static void pushBit(BitstreamOut *stream, uint8_t bit) {
}
// Holds bit packed struct of samples.
-BitstreamOut data = {0, 0, 0};
+static BitstreamOut data = {0, 0, 0};
// internal struct to keep track of samples gathered
-sampling_t samples = {0, 0, 0, 0};
+static sampling_t samples = {0, 0, 0, 0};
void initSampleBuffer(uint32_t *sample_size) {
initSampleBufferEx(sample_size, false);
diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c
index e96d6b3d9..d578d026b 100644
--- a/armsrc/mifaredesfire.c
+++ b/armsrc/mifaredesfire.c
@@ -33,7 +33,7 @@ static uint8_t deselect_cmd[] = {0xc2, 0xe0, 0xb4};
/* PCB CID CMD PAYLOAD */
//static uint8_t __res[MAX_FRAME_SIZE];
-struct desfire_key skey = {0};
+static struct desfire_key skey = {0};
static desfirekey_t sessionkey = &skey;
bool InitDesfireCard(void) {
diff --git a/client/src/cmdflashmem.c b/client/src/cmdflashmem.c
index 8d19c3888..debe77089 100644
--- a/client/src/cmdflashmem.c
+++ b/client/src/cmdflashmem.c
@@ -27,8 +27,6 @@
#define FLASH_FASTBAUD MCK
#define FLASH_MINBAUD FLASH_FASTBAUD
-#define FASTFLASH (FLASHMEM_SPIBAUDRATE > FLASH_MINFAST)
-
static int CmdHelp(const char *Cmd);
static int usage_flashmem_spibaud(void) {
diff --git a/common/legic_prng.c b/common/legic_prng.c
index 1447d3b1b..ad16d28b7 100644
--- a/common/legic_prng.c
+++ b/common/legic_prng.c
@@ -12,7 +12,7 @@
// b is 8bit lsfr
// c keeps track on which step the prng is.
// legic_prng_get_bit() = gets a bit muxed from a and b.
-struct lfsr {
+static struct lfsr {
uint8_t a;
uint8_t b;
uint32_t c;
diff --git a/common/parity.c b/common/parity.c
index ce61ad40a..64e034a6d 100644
--- a/common/parity.c
+++ b/common/parity.c
@@ -25,7 +25,7 @@ const uint8_t OddByteParity[256] = {
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
};
-
+/*
const uint8_t EvenByteParity[256] = {
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
@@ -44,4 +44,4 @@ const uint8_t EvenByteParity[256] = {
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
};
-
+*/
diff --git a/common_arm/usb_cdc.c b/common_arm/usb_cdc.c
index c06542252..34400f4d5 100644
--- a/common_arm/usb_cdc.c
+++ b/common_arm/usb_cdc.c
@@ -130,9 +130,9 @@ AT91SAM7S256 USB Device Port
#define SET_CONTROL_LINE_STATE 0x2221
AT91PS_UDP pUdp = AT91C_BASE_UDP;
-uint8_t btConfiguration = 0;
-uint8_t btConnection = 0;
-uint8_t btReceiveBank = AT91C_UDP_RX_DATA_BK0;
+static uint8_t btConfiguration = 0;
+static uint8_t btConnection = 0;
+static uint8_t btReceiveBank = AT91C_UDP_RX_DATA_BK0;
static const char devDescriptor[] = {
/* Device descriptor */
diff --git a/common_fpga/fpga.h b/common_fpga/fpga.h
index 31580d8c9..f1b42ab2b 100644
--- a/common_fpga/fpga.h
+++ b/common_fpga/fpga.h
@@ -17,7 +17,7 @@
#define FPGA_TRACE_SIZE 3072
static const uint8_t bitparse_fixed_header[] = {0x00, 0x09, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x00, 0x00, 0x01};
-extern const int fpga_bitstream_num;
-extern const char *const fpga_version_information[];
+extern const int g_fpga_bitstream_num;
+extern const char *const g_fpga_version_information[];
#endif
diff --git a/include/pmflash.h b/include/pmflash.h
index d61b5647d..4c970a628 100644
--- a/include/pmflash.h
+++ b/include/pmflash.h
@@ -14,9 +14,6 @@
#include "common.h"
-// Flashmem spi baudrate
-extern uint32_t FLASHMEM_SPIBAUDRATE;
-
// RDV40 Section
// 256kb divided into 4k sectors.
//
diff --git a/tools/fpga_compress/fpga_compress.c b/tools/fpga_compress/fpga_compress.c
index 0992c53ca..a99cc3fee 100644
--- a/tools/fpga_compress/fpga_compress.c
+++ b/tools/fpga_compress/fpga_compress.c
@@ -378,8 +378,8 @@ static void print_version_info_preamble(FILE *outfile, int num_infiles) {
fprintf(outfile, "//-----------------------------------------------------------------------------\n");
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 int g_fpga_bitstream_num = %d;\n", num_infiles);
+ fprintf(outfile, "const char *const g_fpga_version_information[%d] = {\n", num_infiles);
}
static int generate_fpga_version_info(FILE *infile[], char *infile_names[], int num_infiles, FILE *outfile) {
From 37ae102e38853331fa69b2efe6dec546f1a90c00 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 19:09:25 +0200
Subject: [PATCH 056/527] LogTrace error msg
---
armsrc/BigBuf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c
index 8ee7cc189..755c88d9c 100644
--- a/armsrc/BigBuf.c
+++ b/armsrc/BigBuf.c
@@ -157,6 +157,7 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
return false;
}
if (timestamp_end - timestamp_start > 0x7FFF) {
+ Dbprintf("Error in LogTrace: duration too long for UINT16: 0x%08x", timestamp_end - timestamp_start);
return false; // duration too long, must be max 15 bits
}
hdr->timestamp = timestamp_start;
From 8509d233d230c83efb39da2ba4d1daeab2e0d8b9 Mon Sep 17 00:00:00 2001
From: grspy
Date: Tue, 19 May 2020 20:49:25 +0300
Subject: [PATCH 057/527] Fix 32-bit time_t compilation error on WIN64
---
client/src/cmdhw.c | 4 ++--
tools/mf_nonce_brute/mf_nonce_brute.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c
index cb48188a0..3b452b492 100644
--- a/client/src/cmdhw.c
+++ b/client/src/cmdhw.c
@@ -661,10 +661,10 @@ void pm3_version(bool verbose, bool oneliner) {
# define PM3HOSTOS " OS:OpenBSD"
#elif defined(__CYGWIN__)
# define PM3HOSTOS " OS:Cygwin"
-#elif defined(_WIN64) | defined(__WIN64__)
+#elif defined(_WIN64) || defined(__WIN64__)
// must be tested before _WIN32
# define PM3HOSTOS " OS:Windows (64b)"
-#elif defined(_WIN32) | defined(__WIN32__)
+#elif defined(_WIN32) || defined(__WIN32__)
# define PM3HOSTOS " OS:Windows (32b)"
#else
# define PM3HOSTOS " OS:unknown"
diff --git a/tools/mf_nonce_brute/mf_nonce_brute.c b/tools/mf_nonce_brute/mf_nonce_brute.c
index 6bc69c3d9..3aaa5a9f3 100644
--- a/tools/mf_nonce_brute/mf_nonce_brute.c
+++ b/tools/mf_nonce_brute/mf_nonce_brute.c
@@ -1,5 +1,7 @@
#define __STDC_FORMAT_MACROS
-#define _USE_32BIT_TIME_T 1
+#if !defined(_WIN64)
+# define _USE_32BIT_TIME_T 1
+#endif
#include
#include
#include
From be42995f8a5bd893feea72bbae1ceec1e7e59f77 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 19 May 2020 20:03:27 +0200
Subject: [PATCH 058/527] Less fantasy in the LogTrace usages regarding
timestamps
---
armsrc/BigBuf.c | 20 ++++++++++++++++----
armsrc/hitag2.c | 2 +-
armsrc/hitagS.c | 14 +++++++-------
armsrc/iso14443b.c | 2 +-
armsrc/iso15693.c | 12 ++++++------
5 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c
index 755c88d9c..07f32239f 100644
--- a/armsrc/BigBuf.c
+++ b/armsrc/BigBuf.c
@@ -156,12 +156,24 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
tracing = false; // don't trace any more
return false;
}
- if (timestamp_end - timestamp_start > 0x7FFF) {
- Dbprintf("Error in LogTrace: duration too long for UINT16: 0x%08x", timestamp_end - timestamp_start);
- return false; // duration too long, must be max 15 bits
+
+ uint32_t duration;
+ if (timestamp_end > timestamp_start) {
+ duration = timestamp_end - timestamp_start;
+ } else {
+ duration = (UINT32_MAX - timestamp_start) + timestamp_end;
}
+
+ if (duration > 0x7FFF) {
+ if (DBGLEVEL >= DBG_DEBUG) {
+ Dbprintf("Error in LogTrace: duration too long for 15 bits encoding: 0x%08x start:0x%08x end:0x%08x", duration, timestamp_start, timestamp_end);
+ Dbprintf("Forcing duration = 0");
+ }
+ duration = 0;
+ }
+
hdr->timestamp = timestamp_start;
- hdr->duration = timestamp_end - timestamp_start;
+ hdr->duration = duration;
hdr->data_len = iLen;
hdr->isResponse = !readerToTag;
traceLen += TRACELOG_HDR_LEN;
diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c
index c22b04e70..cf1aa46c1 100644
--- a/armsrc/hitag2.c
+++ b/armsrc/hitag2.c
@@ -1238,7 +1238,7 @@ void SimulateHitag2(bool tag_mem_supplied, uint8_t *data) {
// Check if frame was captured
if (rxlen > 4) {
- LogTrace(rx, nbytes(rxlen), response, 0, NULL, true);
+ LogTrace(rx, nbytes(rxlen), response, response, NULL, true);
// Process the incoming frame (rx) and prepare the outgoing frame (tx)
hitag2_handle_reader_command(rx, rxlen, tx, &txlen);
diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c
index 10c889fa7..7a49d65cd 100644
--- a/armsrc/hitagS.c
+++ b/armsrc/hitagS.c
@@ -1039,7 +1039,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
// Check if frame was captured
if (rxlen > 0) {
// frame_count++;
- LogTrace(rx, nbytes(rxlen), response, 0, NULL, true);
+ LogTrace(rx, nbytes(rxlen), response, response, NULL, true);
// Disable timer 1 with external trigger to avoid triggers during our own modulation
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
@@ -1281,7 +1281,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
// Check if frame was captured and store it
if (rxlen > 0) {
// frame_count++;
- LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
+ LogTrace(rx, nbytes(rxlen), response, response, NULL, false);
}
// By default reset the transmission buffer
@@ -1410,7 +1410,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
// Add transmitted frame to total count
if (txlen > 0) {
// frame_count++;
- LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
+ LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, HITAG_T_WAIT_2, NULL, true);
}
hitagS_receive_frame(rx, &rxlen, &response);
@@ -1538,7 +1538,7 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
// Check if frame was captured and store it
if (rxlen > 0) {
// frame_count++;
- LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
+ LogTrace(rx, nbytes(rxlen), response, response, NULL, false);
}
//check for valid input
@@ -1625,7 +1625,7 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
// Add transmitted frame to total count
if (txlen > 0) {
// frame_count++;
- LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
+ LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, HITAG_T_WAIT_2, NULL, true);
}
hitagS_receive_frame(rx, &rxlen, &response);
@@ -1732,7 +1732,7 @@ void check_challenges(bool file_given, uint8_t *data) {
// Check if frame was captured and store it
if (rxlen > 0) {
// frame_count++;
- LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
+ LogTrace(rx, nbytes(rxlen), response, response, NULL, false);
}
uint8_t *tx = txbuf;
@@ -1864,7 +1864,7 @@ void check_challenges(bool file_given, uint8_t *data) {
// Add transmitted frame to total count
if (txlen > 0) {
// frame_count++;
- LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
+ LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, HITAG_T_WAIT_2, NULL, true);
}
hitagS_receive_frame(rx, &rxlen, &response);
diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c
index b03e84912..bbca137fc 100644
--- a/armsrc/iso14443b.c
+++ b/armsrc/iso14443b.c
@@ -1152,7 +1152,7 @@ static void CodeAndTransmit14443bAsReader(const uint8_t *cmd, int len) {
if (g_trigger) LED_A_ON();
- LogTrace(cmd, len, time_start, GetCountSspClk() - time_start, NULL, true);
+ LogTrace(cmd, len, time_start, GetCountSspClk(), NULL, true);
}
/* Sends an APDU to the tag
diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c
index d3a0996e6..9dbdd4f94 100644
--- a/armsrc/iso15693.c
+++ b/armsrc/iso15693.c
@@ -431,7 +431,7 @@ static int GetIso15693AnswerFromTag(uint8_t *received, int *elapsed) {
getNext = !getNext;
}
}
- time_stop = GetCountSspClk() - time_0 ;
+ time_stop = GetCountSspClk();
int len = DemodAnswer(received, buf, counter);
LogTrace(received, len, time_0 << 4, time_stop << 4, NULL, false);
BigBuf_free();
@@ -478,7 +478,7 @@ static int GetIso15693AnswerFromSniff(uint8_t *received, int *samples, int *elap
}
}
- time_stop = GetCountSspClk() - time_0;
+ time_stop = GetCountSspClk();
int k = DemodAnswer(received, buf, counter);
LogTrace(received, k, time_0 << 4, time_stop << 4, NULL, false);
return k;
@@ -522,7 +522,7 @@ void AcquireRawAdcSamplesIso15693(void) {
}
- LogTrace(cmd, CMD_ID_RESP, time_start << 4, (GetCountSspClk() - time_start) << 4, NULL, true);
+ LogTrace(cmd, CMD_ID_RESP, time_start << 4, GetCountSspClk() << 4, NULL, true);
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
@@ -723,7 +723,7 @@ static int SendDataTag(uint8_t *send, int sendlen, bool init, int speed, uint8_t
uint32_t time_start = GetCountSspClk();
TransmitTo15693Tag(ToSend, ToSendMax, &t_samples, &wait);
- LogTrace(send, sendlen, time_start << 4, (GetCountSspClk() - time_start) << 4, NULL, true);
+ LogTrace(send, sendlen, time_start << 4, GetCountSspClk() << 4, NULL, true);
// Now wait for a response
if (outdata != NULL) {
@@ -825,7 +825,7 @@ void ReaderIso15693(uint32_t parameter) {
uint8_t cmd[CMD_ID_RESP] = {0};
BuildIdentifyRequest(cmd);
TransmitTo15693Tag(ToSend, ToSendMax, &tsamples, &wait);
- LogTrace(cmd, CMD_ID_RESP, time_start << 4, (GetCountSspClk() - time_start) << 4, NULL, true);
+ LogTrace(cmd, CMD_ID_RESP, time_start << 4, GetCountSspClk() << 4, NULL, true);
// Now wait for a response
answerLen1 = GetIso15693AnswerFromTag(answer1, &elapsed) ;
@@ -906,7 +906,7 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid) {
time_start = GetCountSspClk();
TransmitTo15693Reader(ToSend, ToSendMax, &tsamples, &wait);
- LogTrace(cmd, CMD_INV_RESP, time_start << 4, (GetCountSspClk() - time_start) << 4, NULL, true);
+ LogTrace(cmd, CMD_INV_RESP, time_start << 4, GetCountSspClk() << 4, NULL, true);
if (DBGLEVEL >= DBG_EXTENDED) {
Dbprintf("[+] %d octets read from reader command: %x %x %x %x %x %x %x %x", ans,
From 0c248f76ad34fcb6697ea55a783f6eda8f153b08 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 20:45:48 +0200
Subject: [PATCH 059/527] chg: hf mfdes info - textual
---
client/src/cmdhfmfdes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index 7ef1689cc..dc285d9cf 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -2972,7 +2972,7 @@ static int CmdHF14ADesInfo(const char *Cmd) {
if (major == 1 && minor == 3)
PrintAndLogEx(INFO, "\t1.3 - DESFire Ev1 MF3ICD21/41/81, Support extended APDU commands, EAL4+");
if (major == 1 && minor == 4)
- PrintAndLogEx(INFO, "\t1.4 - DESFire Ev1 MF3ICD21/41/81, EAL4+, N/A (report to iceman!)");
+ PrintAndLogEx(INFO, "\t1.4 - DESFire Ev1 MF3ICD21/41/81, EAL4+");
if (major == 2 && minor == 0)
PrintAndLogEx(INFO, "\t2.0 - DESFire Ev2, Originality check, proximity check, EAL5");
// if (major == 3 && minor == 0)
From 3dd55e2c04bbad599acd7e1c13e3fc0683cfeca2 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 19 May 2020 20:53:52 +0200
Subject: [PATCH 060/527] simpler define
---
tools/mf_nonce_brute/mf_nonce_brute.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/mf_nonce_brute/mf_nonce_brute.c b/tools/mf_nonce_brute/mf_nonce_brute.c
index 3aaa5a9f3..3bd2a6f31 100644
--- a/tools/mf_nonce_brute/mf_nonce_brute.c
+++ b/tools/mf_nonce_brute/mf_nonce_brute.c
@@ -1,7 +1,9 @@
#define __STDC_FORMAT_MACROS
-#if !defined(_WIN64)
+
+#if defined(_WIN32)
# define _USE_32BIT_TIME_T 1
#endif
+
#include
#include
#include
From 8c22ef076b5c3a53bfc8f0039838484caa9fc2ff Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 08:58:28 +0200
Subject: [PATCH 061/527] expanded from u16 -> u32 for keys to be loaded
---
client/src/cmdflashmem.c | 14 +++++++++++++-
client/src/cmdhficlass.c | 41 ++++++++++++++++++++--------------------
client/src/cmdhficlass.h | 8 ++++----
client/src/cmdhfmf.c | 8 ++++----
client/src/cmdhfmfdes.c | 30 ++++++++++++++++++-----------
client/src/cmdhfmfp.c | 9 +++++----
client/src/cmdlft55xx.c | 4 ++--
client/src/fileutils.c | 10 +++++-----
client/src/fileutils.h | 6 +++---
9 files changed, 76 insertions(+), 54 deletions(-)
diff --git a/client/src/cmdflashmem.c b/client/src/cmdflashmem.c
index debe77089..e1761a81b 100644
--- a/client/src/cmdflashmem.c
+++ b/client/src/cmdflashmem.c
@@ -168,7 +168,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
return PM3_EINVARG;
}
size_t datalen = 0;
- uint16_t keycount = 0;
+ uint32_t keycount = 0;
int res = 0;
uint8_t *data = calloc(FLASH_MEM_MAX_SIZE, sizeof(uint8_t));
@@ -180,6 +180,10 @@ static int CmdFlashMemLoad(const char *Cmd) {
free(data);
return PM3_EFILE;
}
+ // limited space on flash mem
+ if (keycount > 0xFFFF)
+ keycount &= 0xFFFF;
+
data[0] = (keycount >> 0) & 0xFF;
data[1] = (keycount >> 8) & 0xFF;
datalen += 2;
@@ -191,6 +195,10 @@ static int CmdFlashMemLoad(const char *Cmd) {
free(data);
return PM3_EFILE;
}
+ // limited space on flash mem
+ if (keycount > 0xFFFF)
+ keycount &= 0xFFFF;
+
data[0] = (keycount >> 0) & 0xFF;
data[1] = (keycount >> 8) & 0xFF;
datalen += 2;
@@ -202,6 +210,10 @@ static int CmdFlashMemLoad(const char *Cmd) {
free(data);
return PM3_EFILE;
}
+ // limited space on flash mem
+ if (keycount > 0xFFFF)
+ keycount &= 0xFFFF;
+
data[0] = (keycount >> 0) & 0xFF;
data[1] = (keycount >> 8) & 0xFF;
datalen += 2;
diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c
index 73b9a6b18..61aea9de6 100644
--- a/client/src/cmdhficlass.c
+++ b/client/src/cmdhficlass.c
@@ -2411,17 +2411,6 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
}
if (errors) return usage_hf_iclass_chk();
-
- uint8_t *keyBlock = NULL;
- uint16_t keycount = 0;
-
- // load keys
- int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
- if (res != PM3_SUCCESS || keycount == 0) {
- free(keyBlock);
- return res;
- }
-
// Get CSN / UID and CCNR
PrintAndLogEx(SUCCESS, "Reading tag CSN");
for (uint8_t i = 0; i < ICLASS_AUTH_RETRY && !got_csn; i++) {
@@ -2436,6 +2425,16 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
return PM3_ESOFT;
}
+ uint8_t *keyBlock = NULL;
+ uint32_t keycount = 0;
+
+ // load keys
+ int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
+ if (res != PM3_SUCCESS || keycount == 0) {
+ free(keyBlock);
+ return res;
+ }
+
pre = calloc(keycount, sizeof(iclass_premac_t));
if (!pre) {
DropField();
@@ -2678,7 +2677,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
PrintAndLogEx(SUCCESS, "MAC_TAG | %s", sprint_hex(MAC_TAG, sizeof(MAC_TAG)));
uint8_t *keyBlock = NULL;
- uint16_t keycount = 0;
+ uint32_t keycount = 0;
// load keys
int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
@@ -2737,11 +2736,12 @@ static int CmdHFiClassLookUp(const char *Cmd) {
}
// precalc diversified keys and their MAC
-void GenerateMacFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_premac_t *list) {
+void GenerateMacFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, uint32_t keycnt, iclass_premac_t *list) {
uint8_t key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t div_key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- for (int i = 0; i < keycnt; i++) {
+//iceman: threading
+ for (uint32_t i = 0; i < keycnt; i++) {
memcpy(key, keys + 8 * i, 8);
@@ -2754,11 +2754,12 @@ void GenerateMacFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite,
}
}
-void GenerateMacKeyFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_prekey_t *list) {
+void GenerateMacKeyFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, uint32_t keycnt, iclass_prekey_t *list) {
uint8_t div_key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- for (int i = 0; i < keycnt; i++) {
+//iceman: threading
+ for (uint32_t i = 0; i < keycnt; i++) {
memcpy(list[i].key, keys + 8 * i, 8);
@@ -2774,13 +2775,13 @@ void GenerateMacKeyFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elit
}
// print diversified keys
-void PrintPreCalcMac(uint8_t *keys, int keycnt, iclass_premac_t *pre_list) {
+void PrintPreCalcMac(uint8_t *keys, uint32_t keycnt, iclass_premac_t *pre_list) {
- iclass_prekey_t *b = calloc(keycnt, sizeof(iclass_prekey_t));
+ iclass_prekey_t *b = calloc(keycnt, sizeof(iclass_prekey_t));
if (!b)
return;
- for (int i = 0; i < keycnt; i++) {
+ for (uint32_t i = 0; i < keycnt; i++) {
memcpy(b[i].key, keys + 8 * i, 8);
memcpy(b[i].mac, pre_list[i].mac, 4);
}
@@ -2788,7 +2789,7 @@ void PrintPreCalcMac(uint8_t *keys, int keycnt, iclass_premac_t *pre_list) {
free(b);
}
-void PrintPreCalc(iclass_prekey_t *list, int itemcnt) {
+void PrintPreCalc(iclass_prekey_t *list, uint32_t itemcnt) {
PrintAndLogEx(NORMAL, "-----+------------------+---------");
PrintAndLogEx(NORMAL, "#key | key | mac");
PrintAndLogEx(NORMAL, "-----+------------------+---------");
diff --git a/client/src/cmdhficlass.h b/client/src/cmdhficlass.h
index 73304d4d0..53880d647 100644
--- a/client/src/cmdhficlass.h
+++ b/client/src/cmdhficlass.h
@@ -33,8 +33,8 @@ int readIclass(bool loop, bool verbose);
void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize);
void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite);
-void GenerateMacFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_premac_t *list);
-void GenerateMacKeyFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_prekey_t *list);
-void PrintPreCalcMac(uint8_t *keys, int keycnt, iclass_premac_t *pre_list);
-void PrintPreCalc(iclass_prekey_t *list, int itemcnt);
+void GenerateMacFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, uint32_t keycnt, iclass_premac_t *list);
+void GenerateMacKeyFrom(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, uint32_t keycnt, iclass_prekey_t *list);
+void PrintPreCalcMac(uint8_t *keys, uint32_t keycnt, iclass_premac_t *pre_list);
+void PrintPreCalc(iclass_prekey_t *list, uint32_t itemcnt);
#endif
diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c
index 0a11a8a25..560ed0a16 100644
--- a/client/src/cmdhfmf.c
+++ b/client/src/cmdhfmf.c
@@ -1904,7 +1904,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
bool calibrate = true;
// Attack key storage variables
uint8_t *keyBlock = NULL;
- uint16_t key_cnt = 0;
+ uint32_t key_cnt = 0;
sector_t *e_sector;
uint8_t sectors_cnt = MIFARE_1K_MAXSECTOR;
int block_cnt = MIFARE_1K_MAXBLOCK;
@@ -2169,7 +2169,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
for (int j = 0; j < 2; j++) {
// Check if the key is known
if (e_sector[i].foundKey[j] == 0) {
- for (int k = 0; k < key_cnt; k++) {
+ for (uint32_t k = 0; k < key_cnt; k++) {
printf(".");
fflush(stdout);
if (mfCheckKeys(FirstBlockOfSector(i), j, true, 1, (keyBlock + (6 * k)), &key64) == PM3_SUCCESS) {
@@ -2186,13 +2186,13 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
fflush(stdout);
} else {
- int chunksize = key_cnt > (PM3_CMD_DATA_SIZE / 6) ? (PM3_CMD_DATA_SIZE / 6) : key_cnt;
+ uint32_t chunksize = key_cnt > (PM3_CMD_DATA_SIZE / 6) ? (PM3_CMD_DATA_SIZE / 6) : key_cnt;
bool firstChunk = true, lastChunk = false;
for (uint8_t strategy = 1; strategy < 3; strategy++) {
PrintAndLogEx(INFO, "running strategy %u", strategy);
// main keychunk loop
- for (int i = 0; i < key_cnt; i += chunksize) {
+ for (uint32_t i = 0; i < key_cnt; i += chunksize) {
if (kbd_enter_pressed()) {
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index dc285d9cf..7dd07655b 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -3561,7 +3561,11 @@ static int CmdHF14ADesAuth(const char *Cmd) {
return PM3_SUCCESS;
}
-static void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t *aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t *k3kkeyListLen, uint32_t *startPattern) {
+static void DesFill2bPattern(
+ uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t *deskeyListLen,
+ uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t *aeskeyListLen,
+ uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t *k3kkeyListLen, uint32_t *startPattern) {
+
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
if (*deskeyListLen != MAX_KEYS_LIST_LEN) {
deskeyList[*deskeyListLen][0] = (pt >> 8) & 0xff;
@@ -3598,7 +3602,11 @@ static void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *d
(*startPattern)++;
}
-static int AuthCheckDesfire(uint8_t *aid, uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t k3kkeyListLen, uint8_t foundKeys[4][0xE][24 + 1], bool *result) {
+static int AuthCheckDesfire(uint8_t *aid,
+ uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t deskeyListLen,
+ uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t aeskeyListLen,
+ uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t k3kkeyListLen,
+ uint8_t foundKeys[4][0xE][24 + 1], bool *result) {
uint32_t curaid = (aid[0] & 0xFF) + ((aid[1] & 0xFF) << 8) + ((aid[2] & 0xFF) << 16);
@@ -3689,7 +3697,7 @@ static int AuthCheckDesfire(uint8_t *aid, uint8_t deskeyList[MAX_KEYS_LIST_LEN][
if (usedkeys[keyno] == 1 && foundKeys[0][keyno][0] == 0) {
- for (int curkey = 0; curkey < deskeyListLen; curkey++) {
+ for (uint32_t curkey = 0; curkey < deskeyListLen; curkey++) {
payload.keylen = 8;
memcpy(payload.key, deskeyList[curkey], 8);
@@ -3728,7 +3736,7 @@ static int AuthCheckDesfire(uint8_t *aid, uint8_t deskeyList[MAX_KEYS_LIST_LEN][
if (usedkeys[keyno] == 1 && foundKeys[1][keyno][0] == 0) {
- for (int curkey = 0; curkey < aeskeyListLen; curkey++) {
+ for (uint32_t curkey = 0; curkey < aeskeyListLen; curkey++) {
payload.keylen = 16;
memcpy(payload.key, aeskeyList[curkey], 16);
@@ -3767,7 +3775,7 @@ static int AuthCheckDesfire(uint8_t *aid, uint8_t deskeyList[MAX_KEYS_LIST_LEN][
if (usedkeys[keyno] == 1 && foundKeys[2][keyno][0] == 0) {
- for (int curkey = 0; curkey < aeskeyListLen; curkey++) {
+ for (uint32_t curkey = 0; curkey < aeskeyListLen; curkey++) {
payload.keylen = 16;
memcpy(payload.key, aeskeyList[curkey], 16);
@@ -3806,7 +3814,7 @@ static int AuthCheckDesfire(uint8_t *aid, uint8_t deskeyList[MAX_KEYS_LIST_LEN][
if (usedkeys[keyno] == 1 && foundKeys[3][keyno][0] == 0) {
- for (int curkey = 0; curkey < k3kkeyListLen; curkey++) {
+ for (uint32_t curkey = 0; curkey < k3kkeyListLen; curkey++) {
payload.keylen = 24;
memcpy(payload.key, k3kkeyList[curkey], 24);
payload.mode = MFDES_AUTH_ISO;
@@ -3846,9 +3854,9 @@ static int CmdHF14aDesChk(const char *Cmd) {
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8] = {{0}};
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16] = {{0}};
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][MAX_KEY_LEN] = {{0}};
- size_t deskeyListLen = 0;
- size_t aeskeyListLen = 0;
- size_t k3kkeyListLen = 0;
+ uint32_t deskeyListLen = 0;
+ uint32_t aeskeyListLen = 0;
+ uint32_t k3kkeyListLen = 0;
uint8_t foundKeys[4][0xE][24 + 1] = {{{0}}};
CLIParserInit("hf mfdes chk",
@@ -3972,7 +3980,7 @@ static int CmdHF14aDesChk(const char *Cmd) {
// dictionary mode
size_t endFilePosition = 0;
if (dict_filenamelen) {
- uint16_t keycnt = 0;
+ uint32_t keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, deskeyList, sizeof(deskeyList), NULL, 8, &keycnt, 0, &endFilePosition, true);
deskeyListLen = keycnt;
if (endFilePosition)
@@ -4049,7 +4057,7 @@ static int CmdHF14aDesChk(const char *Cmd) {
if (dict_filenamelen && endFilePosition) {
if (!verbose)
printf("d");
- uint16_t keycnt = 0;
+ uint32_t keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, deskeyList, sizeof(deskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
deskeyListLen = keycnt;
keycnt = 0;
diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c
index bc6854b26..27c606203 100644
--- a/client/src/cmdhfmfp.c
+++ b/client/src/cmdhfmfp.c
@@ -1027,7 +1027,7 @@ static int MFPKeyCheck(uint8_t startSector, uint8_t endSector, uint8_t startKeyA
return PM3_SUCCESS;
}
-static void Fill2bPattern(uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], size_t *keyListLen, uint32_t *startPattern) {
+static void Fill2bPattern(uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], uint32_t *keyListLen, uint32_t *startPattern) {
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
keyList[*keyListLen][0] = (pt >> 8) & 0xff;
keyList[*keyListLen][1] = pt & 0xff;
@@ -1045,7 +1045,7 @@ static void Fill2bPattern(uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], size_
static int CmdHFMFPChk(const char *Cmd) {
int res;
uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN] = {{0}};
- size_t keyListLen = 0;
+ uint32_t keyListLen = 0;
uint8_t foundKeys[2][64][AES_KEY_LEN + 1] = {{{0}}};
CLIParserInit("hf mfp chk",
@@ -1149,6 +1149,7 @@ static int CmdHFMFPChk(const char *Cmd) {
uint8_t endKeyAB = 1;
if (keyA && !keyB)
endKeyAB = 0;
+
if (!keyA && keyB)
startKeyAB = 1;
@@ -1170,7 +1171,7 @@ static int CmdHFMFPChk(const char *Cmd) {
// dictionary mode
size_t endFilePosition = 0;
if (dict_filenamelen) {
- uint16_t keycnt = 0;
+ uint32_t keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), NULL, 16, &keycnt, 0, &endFilePosition, true);
keyListLen = keycnt;
if (endFilePosition)
@@ -1210,7 +1211,7 @@ static int CmdHFMFPChk(const char *Cmd) {
if (dict_filenamelen && endFilePosition) {
if (!verbose)
printf("d");
- uint16_t keycnt = 0;
+ uint32_t keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
keyListLen = keycnt;
continue;
diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c
index 572a07549..9b54aef8f 100644
--- a/client/src/cmdlft55xx.c
+++ b/client/src/cmdlft55xx.c
@@ -3045,7 +3045,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
}
if (use_pwd_file) {
- uint16_t keycount = 0;
+ uint32_t keycount = 0;
int res = loadFileDICTIONARY_safe(filename, (void **) &keyBlock, 4, &keycount);
if (res != PM3_SUCCESS || keycount == 0 || keyBlock == NULL) {
@@ -3056,7 +3056,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
return PM3_ESOFT;
}
- for (uint16_t c = 0; c < keycount; ++c) {
+ for (uint32_t c = 0; c < keycount; ++c) {
if (!session.pm3_present) {
PrintAndLogEx(WARNING, "Device offline\n");
diff --git a/client/src/fileutils.c b/client/src/fileutils.c
index ac9196e4c..4e5573747 100644
--- a/client/src/fileutils.c
+++ b/client/src/fileutils.c
@@ -996,7 +996,7 @@ out:
return retval;
}
-int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, uint8_t keylen, uint16_t *keycnt) {
+int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, uint8_t keylen, uint32_t *keycnt) {
// t5577 == 4bytes
// mifare == 6 bytes
// mf plus == 16 bytes
@@ -1009,7 +1009,7 @@ int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, u
return loadFileDICTIONARYEx(preferredName, data, 0, datalen, keylen, keycnt, 0, NULL, true);
}
-int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, uint8_t keylen, uint16_t *keycnt,
+int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, uint8_t keylen, uint32_t *keycnt,
size_t startFilePosition, size_t *endFilePosition, bool verbose) {
if (data == NULL) return PM3_EINVARG;
@@ -1025,7 +1025,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
keylen <<= 1;
char line[255];
- uint16_t vkeycnt = 0;
+ uint32_t vkeycnt = 0;
size_t counter = 0;
int retval = PM3_SUCCESS;
@@ -1097,7 +1097,7 @@ out:
return retval;
}
-int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint16_t *keycnt) {
+int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint32_t *keycnt) {
int retval = PM3_SUCCESS;
@@ -1141,7 +1141,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
while (fgets(line, sizeof(line), f)) {
// check if we have enough space (if not allocate more)
- if ((((size_t)(*keycnt)) * (keylen >> 1)) >= mem_size) {
+ if ((*keycnt * (keylen >> 1)) >= mem_size) {
mem_size += block_size;
*pdata = realloc(*pdata, mem_size);
diff --git a/client/src/fileutils.h b/client/src/fileutils.h
index 2f55a3c1a..603144e67 100644
--- a/client/src/fileutils.h
+++ b/client/src/fileutils.h
@@ -210,7 +210,7 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
* @param keycnt key count that lays in data. may be NULL
* @return 0 for ok, 1 for failz
*/
-int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, uint8_t keylen, uint16_t *keycnt);
+int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, uint8_t keylen, uint32_t *keycnt);
/**
* @brief Utility function to load data from a DICTIONARY textfile. This method takes a preferred name.
@@ -228,7 +228,7 @@ int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, u
* @param verbose print messages if true
* @return 0 for ok, 1 for failz
*/
-int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, uint8_t keylen, uint16_t *keycnt,
+int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, uint8_t keylen, uint32_t *keycnt,
size_t startFilePosition, size_t *endFilePosition, bool verbose);
/**
@@ -240,7 +240,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
* @param keylen the number of bytes a key per row is
* @return 0 for ok, 1 for failz
*/
-int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint16_t *keycnt);
+int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint32_t *keycnt);
/**
* @brief Utility function to check and convert old mfu dump format to new
From 97a94903b08cfb3bce2d6b7634b8ad14218ad0fd Mon Sep 17 00:00:00 2001
From: Iceman
Date: Wed, 20 May 2020 09:46:49 +0200
Subject: [PATCH 062/527] Update termux_notes.md
---
doc/termux_notes.md | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/doc/termux_notes.md b/doc/termux_notes.md
index 6b3eb132c..168e13803 100644
--- a/doc/termux_notes.md
+++ b/doc/termux_notes.md
@@ -1,6 +1,23 @@
+
# Proxmark 3 on Android
+## Table of Contents
+ * [ Requirements ](#requirements)
+ * [ Notes ](#notes)
+ * [ Tested setups ](#tested-setups)
+ * [ Setup ](#setup)
+ * [ Setting up Termux ](#setting-up-termux)
+ * [ Install Proxmark3 package ](#install-proxmark3-package)
+ * [ USB_ACM ](#usb_acm)
+ * [ Enable the driver ](#enable-the-driver)
+ * [ Building the kernel ](#building-the-kernel)
+ * [ Flashing the kernel ](#flashing-the-kernel)
+ * [ Testing ](#testing)
+ * [ Troubleshooting ](#troubleshooting)
+
## Requirements
+^[Top](#top)
+
- Android phone
- Kernel with one of:
- USB_ACM driver
@@ -10,11 +27,13 @@
- [Termux](https://play.google.com/store/apps/details?id=com.termux)
## Notes
+^[Top](#top)
From official Proxmark3 wiki:
> In any case, you would need a USB-C to A or USB-OTG cable to connect Proxmark3 to your Android device. Some Android devices may not supply enough power (USB-OTG = 100mA), and need a USB Y-cable and external battery, otherwise they will get strange failures.
ref : https://github.com/Proxmark/proxmark3/wiki/android
## Tested setups
+^[Top](#top)
- OnePlus 5 (arm64, USB-C)
@@ -45,9 +64,17 @@ ref : https://github.com/Proxmark/proxmark3/wiki/android
## Setup
+^[Top](#top)
+
### Setting up Termux
+^[Top](#top)
+
Install [Termux](https://play.google.com/store/apps/details?id=com.termux) and start it
+
+
### Install Proxmark3 package
+^[Top](#top)
+
Run the following commands:
```
pkg install proxmark3 tsu
@@ -61,18 +88,28 @@ make clean && make client
```
### USB_ACM
+^[Top](#top)
+
You need the `USB_ACM` driver enabled and working to communicate with the Proxmark3. To see if it's working, run `tsudo ls /dev/tty*` and it should list `/dev/ttyACM0` (or similar). If you see this, congratulations, skip this step!
#### Enable the driver
+^[Top](#top)
+
If your kernel has module loading enabled, you should be able to build the module separately and load it on your system without any changes. Otherwise, grab your kernel sources and edit your build config to include `CONFIG_USB_ACM=y`. On the tested kernel, this was under: `android_kernel_oneplus_msm8998/arch/arm64/configs/omni_oneplus5_defconfig`
#### Building the kernel
+^[Top](#top)
+
If using a custom kernel, refer to the build instructions provided by its maintainer. Otherwise, follow the standard Linux kernel build procedure
#### Flashing the kernel
+^[Top](#top)
+
You can flash the kernel however it suits you. On the tested device, this was achieved using [TWRP](https://twrp.me/), the most popular custom recovery
### Testing
+^[Top](#top)
+
Open Termux and start the Proxmark3 client:
```
tsudo proxmark3/client/proxmark3 /dev/ttyACM0
@@ -80,5 +117,7 @@ tsudo proxmark3/client/proxmark3 /dev/ttyACM0
Everything should work just like if it was your PC!
### Troubleshooting
+^[Top](#top)
+
- `dmesg | grep usb` - useful debug info
- `/proc/config.gz` - contains your kernel's build configuration. Look for `CONFIG_USB_ACM`, which should be enabled
From ce0247cf8693f527450d0e55ae0ea56bf79d2b53 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Wed, 20 May 2020 09:48:12 +0200
Subject: [PATCH 063/527] Update termux_notes.md
---
doc/termux_notes.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/doc/termux_notes.md b/doc/termux_notes.md
index 168e13803..1b1ccc75c 100644
--- a/doc/termux_notes.md
+++ b/doc/termux_notes.md
@@ -1,10 +1,14 @@
# Proxmark 3 on Android
-
## Table of Contents
* [ Requirements ](#requirements)
* [ Notes ](#notes)
* [ Tested setups ](#tested-setups)
+ * OnePlus 5 (arm64, USB-C)
+ * Nexus 5X (arm64, USB-C)
+ * Xiaomi Mi Mix 2S (arm64, USB-C)
+ * OnePlus 5T (arm64, USB-C)
+ * Samsung Galaxy Tab S2 (arm64, MicroUSB)
* [ Setup ](#setup)
* [ Setting up Termux ](#setting-up-termux)
* [ Install Proxmark3 package ](#install-proxmark3-package)
From 1a90fa90d64e051a10d520c83f9e338aa5d45f18 Mon Sep 17 00:00:00 2001
From: dxl <64101226@qq.com>
Date: Wed, 20 May 2020 16:05:58 +0800
Subject: [PATCH 064/527] work directory supported.
---
client/android/pm3_main.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/client/android/pm3_main.c b/client/android/pm3_main.c
index 6855856ab..b1e388cce 100644
--- a/client/android/pm3_main.c
+++ b/client/android/pm3_main.c
@@ -53,6 +53,14 @@ const char *get_my_executable_path(void) {
}
const char *get_my_executable_directory(void) {
+ if (my_executable_directory != NULL) free(my_executable_directory);
+ char buf[1024];
+ // get current work directory
+ getcwd(buf, sizeof(buf));
+ // add / to end.
+ sprintf(buf, "%s%s", buf, PATHSEP);
+ // create on global
+ my_executable_directory = strdup(buf);
return my_executable_directory;
}
@@ -95,7 +103,7 @@ jint sendCMD(JNIEnv *env, jobject instance, jstring cmd_) {
}
// display on new line
PrintAndLogEx(NORMAL, "\n");
- char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0));
+ char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0));
int ret = CommandReceived(cmd);
if (ret == 99) {
// exit / quit
@@ -110,7 +118,7 @@ jint sendCMD(JNIEnv *env, jobject instance, jstring cmd_) {
* Is client running!
* */
jboolean isExecuting(JNIEnv *env, jobject instance) {
- return (jboolean)((jboolean) conn.run);
+ return (jboolean) ((jboolean) conn.run);
}
/*
@@ -123,7 +131,7 @@ jboolean testPm3(JNIEnv *env, jobject instance) {
return false;
}
bool ret2 = TestProxmark() == PM3_SUCCESS;
- return (jboolean)(ret1 && ret2);
+ return (jboolean) (ret1 && ret2);
}
/*
@@ -148,21 +156,21 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
}
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
JNINativeMethod methods[] = {
- {"startExecute", "(Ljava/lang/String;)I", (void *) sendCMD},
- {"stopExecute", "()V", (void *) stopPm3},
- {"isExecuting", "()Z", (void *) isExecuting}
+ {"startExecute", "(Ljava/lang/String;)I", (void *) sendCMD},
+ {"stopExecute", "()V", (void *) stopPm3},
+ {"isExecuting", "()Z", (void *) isExecuting}
};
JNINativeMethod methods1[] = {
- {"testPm3", "()Z", (void *) testPm3},
- {"closePm3", "()V", stopPm3}
+ {"testPm3", "()Z", (void *) testPm3},
+ {"closePm3", "()V", stopPm3}
};
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) !=
- JNI_OK) {
+ JNI_OK) {
return -1;
}
if ((*jniEnv)->RegisterNatives(jniEnv, clz_test, methods1,
sizeof(methods1) / sizeof(methods1[0])) !=
- JNI_OK) {
+ JNI_OK) {
return -1;
}
(*jniEnv)->DeleteLocalRef(jniEnv, clazz);
From 6bb47f355fc963a074ecf375aac5316fb2c026f5 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Wed, 20 May 2020 10:24:20 +0200
Subject: [PATCH 065/527] Update README.md
---
README.md | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 1c4cdaf83..1c7eb891c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# RRG / Iceman repo - Proxmark3
+
+
| Releases | Linux & OSX CI | Windows CI | Coverity |
| ------------------- |:-------------------:| -------------------:| -------------------:|
| [](https://github.com/RfidResearchGroup/proxmark3/releases/latest) | [](https://travis-ci.org/RfidResearchGroup/proxmark3) | [](https://ci.appveyor.com/project/RfidResearchGroup/proxmark3/branch/master) | [](https://scan.coverity.com/projects/proxmark3-rrg-iceman-repo)|
@@ -23,6 +25,7 @@
## Notes / helpful documents
+
| Notes |||
| ------------------- |:-------------------:| -------------------:|
|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
@@ -31,6 +34,8 @@
|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
+
+
## Build for non-RDV4 Proxmark3 platforms
In order to build this repo for other Proxmark3 platforms we urge you to read [Advanced compilation parameters](/doc/md/Use_of_Proxmark/4_Advanced-compilation-parameters.md)
@@ -52,14 +57,22 @@ On the software side: quite a lot, see the [Changelog file](CHANGELOG.md).
This repo compiles nicely on
- Proxspace v3.x
- - Windows/mingw environment with Qt5.6.1 & GCC 4.8
- - Ubuntu 1604, 1804, 1904, 2004
+ - [latest release v3.4](https://github.com/Gator96100/ProxSpace/releases)
+ - Windows/mingw environment with Qt5.6.1 & GCC 4.9
+ - Ubuntu 1604 -> 2004
- ParrotOS, Gentoo, Pentoo, Kali, Nethunter, Archlinux, Fedora, Debian
- - Rasbian Pi, Jetson Nano,
- Android / Termux
- Mac OS X / Homebrew
- WSL, WSL2 (Windows subsystem linux) on Windows 10
- Docker container
+ - [ RRG / Iceman repo based ubuntu 18.04 container ](https://hub.docker.com/r/secopsconsult/proxmark3)
+ - [ Iceman fork based container v1.7 ](https://hub.docker.com/r/iceman1001/proxmark3/)
+
+Hardware to run client on
+ - PC
+ - Andriod
+ - Rasbian Pi
+ - Jetson Nano
The [public roadmap](https://github.com/RfidResearchGroup/proxmark3/wiki/Public-Roadmap) is an excellent start to read if you are interesting in contributing.
@@ -67,6 +80,20 @@ The [public roadmap](https://github.com/RfidResearchGroup/proxmark3/wiki/Public-
We usually merge your contributions fast since we do like the idea of getting a functionality in the Proxmark3 and weed out the bugs afterwards.
+## Issues & Troubleshooting
+Please search the [issues](https://github.com/rfidresearchgroup/proxmark3/issues) page here and see if your issue is listed in the first instance. Next place to visit is the [Proxmark Forum](http://www.proxmark.org/forum/index.php). Learn to search it well and finally Google / duckduckgo is your friend :) You will find many blogposts, youtube videos, tweets, reddit
+
+Read the [Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md) guide to weed out most known problems.
+
+Offical channels
+ - [Proxmark3 IRC channel](http://webchat.freenode.net/?channels=#proxmark3)
+ - [Proxmark3 sub reddit](https://www.reddit.com/r/proxmark3/)
+ - [Twitter](https://twitter.com/proxmark3/)
+
+ _no discord or slack channel_
+
+Iceman has quite a few videos on his [youtube channel](https://www.youtube.com/c/ChrisHerrmann1001)
+
## Cheat sheet
Thanks to Alex Dibs, you can enjoy a [command cheat sheet](/doc/cheatsheet.md)
@@ -85,13 +112,6 @@ The separation from official Proxmark3 repo gives us a lot of freedom to create
The official PM3-GUI from Gaucho will not work.
The new universal GUI will work. [Proxmark3 Universal GUI](https://github.com/burma69/PM3UniversalGUI) Almost, change needed in order to show helptext when client isn't connected to a device.
-## Issues
-
-Please see the [Proxmark Forum](http://www.proxmark.org/forum/index.php) and see if your issue is listed in the first instance Google is your friend :) Questions will be answered via the forum by Iceman and the team.
-
-Read the [Troubleshooting](/doc/md/Installation_Instructions/Troubleshooting.md) guide to weed out most known problems.
-
-
## The end
- July 2018 [@herrmann1001](https://mobile.twitter.com/herrmann1001)
From 04158fddb6e98f5b34c534e131662ce572aacd4b Mon Sep 17 00:00:00 2001
From: Iceman
Date: Wed, 20 May 2020 10:25:00 +0200
Subject: [PATCH 066/527] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 1c7eb891c..261d65e0b 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,7 @@ Hardware to run client on
- Rasbian Pi
- Jetson Nano
+## Roadmap
The [public roadmap](https://github.com/RfidResearchGroup/proxmark3/wiki/Public-Roadmap) is an excellent start to read if you are interesting in contributing.
> 👉 **Remember!** If you intend to contribute to the code, please read the [coding style notes](HACKING.md) first.
From e9d06e0ec5d128327334be27f76e82dad6489dd2 Mon Sep 17 00:00:00 2001
From: dxl <64101226@qq.com>
Date: Wed, 20 May 2020 16:33:21 +0800
Subject: [PATCH 067/527] Follow naming conventions.
---
client/android/pm3_main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/client/android/pm3_main.c b/client/android/pm3_main.c
index b1e388cce..d35ae25fc 100644
--- a/client/android/pm3_main.c
+++ b/client/android/pm3_main.c
@@ -45,23 +45,23 @@ int push_cmdscriptfile(char *path, bool stayafter) {
return PM3_SUCCESS;
}
-static char *my_executable_path = NULL;
-static char *my_executable_directory = NULL;
+static char *g_android_my_executable_path = NULL;
+static char *g_android_my_executable_directory = NULL;
const char *get_my_executable_path(void) {
- return my_executable_path;
+ return g_android_my_executable_path;
}
const char *get_my_executable_directory(void) {
- if (my_executable_directory != NULL) free(my_executable_directory);
+ if (g_android_my_executable_directory != NULL) free(g_android_my_executable_directory);
char buf[1024];
// get current work directory
getcwd(buf, sizeof(buf));
// add / to end.
sprintf(buf, "%s%s", buf, PATHSEP);
// create on global
- my_executable_directory = strdup(buf);
- return my_executable_directory;
+ g_android_my_executable_directory = strdup(buf);
+ return g_android_my_executable_directory;
}
static void set_my_executable_path(void) {
From b6d764aec9dd3c89bf9c2c3c3dbaa3145b6802dd Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 11:13:21 +0200
Subject: [PATCH 068/527] Add: 'lf fdx demod' - decoding of Bio-Thermo lf tag.
Thanks to Rosco! See Destron Fearing LifeChip with Bio-Thermo technology and
http://www.proxmark.org/forum/viewtopic.php?pid=38984#p38984
---
client/src/cmdlffdx.c | 66 +-
traces/lf_fdx_biothermo.pm3 | 10000 ++++++++++++++++++++++++++++++++++
2 files changed, 10047 insertions(+), 19 deletions(-)
create mode 100644 traces/lf_fdx_biothermo.pm3
diff --git a/client/src/cmdlffdx.c b/client/src/cmdlffdx.c
index 93420ac28..def872fde 100644
--- a/client/src/cmdlffdx.c
+++ b/client/src/cmdlffdx.c
@@ -62,6 +62,7 @@ static int usage_lf_fdx_clone(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf fdx clone 999 112233");
+ PrintAndLogEx(NORMAL, " lf fdx clone 999 112233 16a");
return PM3_SUCCESS;
}
@@ -78,19 +79,34 @@ static int usage_lf_fdx_sim(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf fdx sim 999 112233");
+ PrintAndLogEx(NORMAL, " lf fdx sim 999 112233 16a");
return PM3_SUCCESS;
}
// clearing the topbit needed for the preambl detection.
-static void verify_values(uint64_t *animalid, uint32_t *countryid) {
+static void verify_values(uint64_t *animalid, uint32_t *countryid, uint32_t *extended) {
if ((*animalid & 0x3FFFFFFFFF) != *animalid) {
*animalid &= 0x3FFFFFFFFF;
- PrintAndLogEx(INFO, "Animal ID Truncated to 38bits: %"PRIx64, *animalid);
+ PrintAndLogEx(INFO, "Animal ID truncated to 38bits: " _YELLOW_("%"PRIx64), *animalid);
}
if ((*countryid & 0x3ff) != *countryid) {
*countryid &= 0x3ff;
- PrintAndLogEx(INFO, "Country ID Truncated to 10bits: %03d", *countryid);
+ PrintAndLogEx(INFO, "Country ID truncated to 10bits:" _YELLOW_("%03d"), *countryid);
}
+ if ((*extended & 0xfff) != *extended) {
+ *extended &= 0xfff;
+ PrintAndLogEx(INFO, "Extended truncated to 24bits: " _YELLOW_("0x%03X"), *extended);
+ }
+}
+
+static inline uint32_t bitcount(uint32_t a) {
+#if defined __GNUC__
+ return __builtin_popcountl(a);
+#else
+ a = a - ((a >> 1) & 0x55555555);
+ a = (a & 0x33333333) + ((a >> 2) & 0x33333333);
+ return (((a + (a >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
+#endif
}
// FDX-B ISO11784/85 demod (aka animal tag) BIPHASE, inverted, rf/32, with preamble of 00000000001 (128bits)
@@ -187,9 +203,7 @@ static int CmdFDXBdemodBI(const char *Cmd) {
//see ASKDemod for what args are accepted
//almost the same demod as cmddata.c/CmdFDXBdemodBI
-static int CmdFdxDemod(const char *Cmd) {
- (void)Cmd; // Cmd is not used so far
-
+int demodFDX(void) {
//Differential Biphase / di-phase (inverted biphase)
//get binary from ask wave
if (ASKbiphaseDemod("0 32 1 100", false) != PM3_SUCCESS) {
@@ -234,8 +248,8 @@ static int CmdFdxDemod(const char *Cmd) {
num_to_bytes(rawid, 8, raw);
PrintAndLogEx(SUCCESS, "\nFDX-B / ISO 11784/5 Animal Tag ID Found: Raw : %s", sprint_hex(raw, 8));
- PrintAndLogEx(SUCCESS, "Animal ID %04u-%012" PRIu64, countryCode, NationalCode);
- PrintAndLogEx(SUCCESS, "National Code %012" PRIu64 " (0x%" PRIx64 ")", NationalCode, NationalCode);
+ PrintAndLogEx(SUCCESS, "Animal ID " _GREEN_("%04u-%012"PRIu64), countryCode, NationalCode);
+ PrintAndLogEx(SUCCESS, "National Code " _GREEN_("%012" PRIu64) " (0x%" PRIx64 ")", NationalCode, NationalCode);
PrintAndLogEx(SUCCESS, "Country Code %04u", countryCode);
PrintAndLogEx(SUCCESS, "Reserved/RFU %u (0x04%X)", reservedCode, reservedCode);
PrintAndLogEx(SUCCESS, "Animal Tag %s", animalBit ? _YELLOW_("True") : "False");
@@ -243,7 +257,7 @@ static int CmdFdxDemod(const char *Cmd) {
uint8_t c[] = {0, 0};
compute_crc(CRC_11784, raw, sizeof(raw), &c[0], &c[1]);
- PrintAndLogEx(SUCCESS, "CRC-16 0x%04X [%s] ", crc, (crc == (c[1] << 8 | c[0])) ? _GREEN_("OK") : _RED_("Fail"));
+ PrintAndLogEx(SUCCESS, "CRC-16 0x%04X (%s) ", crc, (crc == (c[1] << 8 | c[0])) ? _GREEN_("ok") : _RED_("fail"));
if (g_debugMode) {
PrintAndLogEx(DEBUG, "Start marker %d; Size %zu", preambleIndex, size);
@@ -251,12 +265,30 @@ static int CmdFdxDemod(const char *Cmd) {
PrintAndLogEx(DEBUG, "DEBUG bin stream:\n%s", bin);
}
+ uint8_t bt_par = (extended & 0x100) >> 8;
+ uint8_t bt_temperature = extended & 0xff;
+ uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1;
+ uint8_t is_bt_temperature = (bt_calc_parity == bt_par) && !(extended & 0xe00) ;
+
+ if (is_bt_temperature) {
+ float bt_F = 74 + bt_temperature * 0.2;
+ float bt_C = (bt_F - 32) / 1.8;
+ PrintAndLogEx(NORMAL, "");
+ PrintAndLogEx(SUCCESS, "Bio-Thermo detected");
+ PrintAndLogEx(INFO, " temperature " _GREEN_("%.1f")" F / " _GREEN_("%.1f") " C", bt_F, bt_C);
+ }
+
// set block 0 for later
//g_DemodConfig = T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT;
return PM3_SUCCESS;
}
+static int CmdFdxDemod(const char *Cmd) {
+ (void)Cmd; // Cmd is not used so far
+ return demodFDX();
+}
+
static int CmdFdxRead(const char *Cmd) {
lf_read(false, 10000);
return CmdFdxDemod(Cmd);
@@ -272,9 +304,9 @@ static int CmdFdxClone(const char *Cmd) {
countryid = param_get32ex(Cmd, 0, 0, 10);
animalid = param_get64ex(Cmd, 1, 0, 10);
- extended = param_get32ex(Cmd, 2, 0, 10);
+ extended = param_get32ex(Cmd, 2, 0, 16);
- verify_values(&animalid, &countryid);
+ verify_values(&animalid, &countryid, &extended);
uint8_t *bits = calloc(128, sizeof(uint8_t));
@@ -298,7 +330,7 @@ static int CmdFdxClone(const char *Cmd) {
free(bits);
- PrintAndLogEx(INFO, "Preparing to clone FDX-B to T55x7 with animal ID: %04u-%"PRIu64, countryid, animalid);
+ PrintAndLogEx(INFO, "Preparing to clone FDX-B to T55x7 with animal ID: " _GREEN_("%04u-%"PRIu64)" (extended 0x%X)", countryid, animalid, extended);
print_blocks(blocks, ARRAYLEN(blocks));
int res = clone_t55xx_tag(blocks, ARRAYLEN(blocks));
@@ -316,11 +348,11 @@ static int CmdFdxSim(const char *Cmd) {
countryid = param_get32ex(Cmd, 0, 0, 10);
animalid = param_get64ex(Cmd, 1, 0, 10);
- extended = param_get32ex(Cmd, 2, 0, 10);
+ extended = param_get32ex(Cmd, 2, 0, 16);
- verify_values(&animalid, &countryid);
+ verify_values(&animalid, &countryid, &extended);
- PrintAndLogEx(SUCCESS, "Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid);
+ PrintAndLogEx(SUCCESS, "Simulating FDX-B animal ID: " _GREEN_("%04u-%"PRIu64)" (extended 0x%X)", countryid, animalid, extended);
//getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits)
uint8_t *bits = calloc(128, sizeof(uint8_t));
@@ -389,10 +421,6 @@ int detectFDXB(uint8_t *dest, size_t *size) {
return (int)startIdx;
}
-int demodFDX(void) {
- return CmdFdxDemod("");
-}
-
int getFDXBits(uint64_t national_id, uint16_t country, uint8_t is_animal, uint8_t is_extended, uint32_t extended, uint8_t *bits) {
// add preamble ten 0x00 and one 0x01
diff --git a/traces/lf_fdx_biothermo.pm3 b/traces/lf_fdx_biothermo.pm3
new file mode 100644
index 000000000..77f390f2f
--- /dev/null
+++ b/traces/lf_fdx_biothermo.pm3
@@ -0,0 +1,10000 @@
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-111
+-104
+-98
+-91
+-84
+-77
+-71
+-67
+-63
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+110
+102
+94
+89
+84
+77
+70
+-14
+-113
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-115
+-108
+-100
+-92
+-84
+-79
+-75
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+116
+108
+102
+95
+87
+80
+75
+71
+-13
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-121
+-114
+-107
+-99
+-91
+-86
+-81
+-75
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+118
+109
+101
+93
+87
+82
+75
+69
+-15
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-115
+-108
+-100
+-91
+-84
+-79
+-75
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+115
+-1
+-108
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-9
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-18
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+112
+104
+96
+88
+82
+77
+73
+66
+61
+56
+-26
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-59
+67
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+64
+-47
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-26
+97
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-112
+-104
+-98
+-92
+-85
+-78
+-74
+-69
+-64
+107
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+109
+102
+96
+89
+81
+75
+70
+-13
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-55
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-24
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-110
+-103
+-97
+-91
+-84
+-77
+-71
+-68
+-64
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+4
+-103
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-9
+114
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+83
+-29
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+110
+103
+97
+90
+83
+76
+72
+68
+63
+57
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-117
+-109
+-102
+-93
+-86
+-81
+-76
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+110
+101
+94
+88
+80
+74
+69
+-14
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-58
+67
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+68
+-43
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-114
+-105
+-99
+-93
+-86
+-79
+-74
+-70
+-65
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+5
+-103
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+83
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+112
+104
+96
+88
+82
+78
+72
+66
+61
+58
+-25
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-117
+-109
+-101
+-93
+-86
+-81
+-76
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+108
+101
+94
+86
+80
+75
+69
+-16
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-59
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+70
+-41
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-114
+-107
+-99
+-91
+-84
+-79
+-75
+-70
+-64
+107
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+4
+-104
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+123
+113
+105
+98
+93
+86
+79
+73
+67
+64
+59
+-26
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-61
+66
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-116
+-108
+-99
+-91
+-86
+-80
+-75
+-69
+-63
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+113
+105
+95
+88
+83
+77
+70
+-15
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+70
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+69
+-40
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-113
+-105
+-99
+-93
+-86
+-79
+-73
+-69
+-65
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+110
+102
+94
+88
+83
+77
+70
+-15
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-58
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+69
+-42
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-36
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-113
+-103
+-97
+-91
+-85
+-78
+-71
+-66
+-62
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+3
+-105
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-8
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-18
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+103
+96
+88
+82
+77
+72
+66
+61
+57
+-25
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-60
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+70
+-40
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-24
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-112
+-105
+-98
+-90
+-83
+-78
+-73
+-68
+-62
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+103
+95
+87
+81
+77
+72
+-13
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+68
+-41
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-113
+-103
+-97
+-91
+-85
+-78
+-72
+-67
+-64
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+3
+-104
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-8
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+122
+112
+104
+98
+90
+83
+77
+73
+67
+62
+58
+-24
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-117
+-107
+-100
+-94
+-88
+-81
+-74
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+115
+1
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-12
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+121
+113
+106
+99
+91
+84
+78
+74
+68
+62
+58
+-25
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-59
+67
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-42
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-114
+-105
+-98
+-92
+-86
+-78
+-74
+-70
+-64
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+111
+103
+94
+88
+83
+78
+71
+-15
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-58
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-115
+-106
+-98
+-92
+-86
+-80
+-72
+-68
+-64
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+110
+101
+94
+89
+84
+77
+70
+-15
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-57
+70
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+65
+-46
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-121
+-114
+-106
+-99
+-90
+-84
+-79
+-74
+-69
+-63
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+109
+102
+96
+90
+83
+76
+71
+-13
+-112
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-115
+-108
+-100
+-91
+-85
+-80
+-75
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+113
+-1
+-108
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-9
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+83
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+121
+111
+102
+95
+90
+84
+77
+71
+67
+63
+58
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-61
+66
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-43
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-119
+-110
+-104
+-97
+-90
+-82
+-76
+-72
+-68
+-63
+107
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+4
+-103
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-18
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+110
+103
+97
+91
+84
+77
+71
+67
+63
+57
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-117
+-109
+-102
+-93
+-86
+-81
+-76
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+124
+116
+109
+102
+93
+86
+80
+76
+70
+-15
+-116
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-114
+-106
+-100
+-94
+-86
+-79
+-73
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+115
+0
+-107
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+103
+97
+90
+83
+76
+71
+67
+62
+57
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-117
+-109
+-101
+-93
+-86
+-81
+-76
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+118
+109
+100
+92
+86
+81
+76
+69
+-16
+-116
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-115
+-106
+-99
+-93
+-87
+-79
+-74
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+124
+118
+110
+101
+93
+86
+81
+76
+70
+-14
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-116
+-108
+-98
+-92
+-87
+-80
+-73
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+124
+116
+108
+102
+94
+86
+79
+75
+71
+-14
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+65
+-45
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+99
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-112
+-103
+-97
+-91
+-85
+-78
+-71
+-67
+-64
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+2
+-104
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-9
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+83
+-29
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+121
+111
+102
+95
+89
+84
+77
+71
+66
+62
+59
+-25
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-117
+-107
+-100
+-94
+-88
+-81
+-74
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+115
+1
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+113
+104
+96
+89
+84
+78
+72
+66
+62
+58
+-26
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-62
+65
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-24
+99
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-113
+-105
+-97
+-88
+-83
+-78
+-73
+-66
+-61
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+111
+104
+96
+88
+81
+76
+72
+-12
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-116
+-107
+-98
+-91
+-86
+-80
+-74
+97
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+116
+2
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+113
+106
+98
+90
+84
+79
+73
+67
+62
+59
+-24
+-123
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-59
+65
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-43
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-26
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-113
+-105
+-97
+-89
+-83
+-78
+-73
+-67
+-61
+108
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+104
+96
+89
+81
+76
+72
+-12
+-113
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-115
+-106
+-98
+-92
+-86
+-80
+-74
+97
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+116
+2
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+111
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+123
+114
+105
+97
+91
+86
+80
+73
+67
+63
+60
+-24
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-60
+65
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-115
+-106
+-98
+-90
+-83
+-76
+-72
+-68
+-63
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+2
+-105
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-8
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+122
+115
+107
+99
+91
+84
+79
+75
+69
+63
+58
+-24
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-126
+-118
+-108
+-99
+-93
+-87
+-81
+-76
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+113
+-1
+-108
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+122
+112
+104
+98
+92
+86
+78
+72
+67
+63
+58
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-115
+-108
+-100
+-93
+-88
+-82
+-75
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+113
+-1
+-108
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+111
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+82
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-36
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+110
+102
+97
+89
+82
+76
+72
+66
+61
+57
+-26
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-60
+65
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-26
+98
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-119
+-111
+-104
+-97
+-89
+-82
+-76
+-72
+-67
+-62
+108
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+4
+-104
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+114
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+111
+102
+95
+89
+84
+77
+71
+66
+63
+58
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-116
+-109
+-102
+-95
+-87
+-80
+-75
+93
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+113
+-2
+-109
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-9
+114
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+104
+95
+87
+82
+77
+71
+65
+61
+58
+-26
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-62
+64
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-114
+-105
+-98
+-92
+-86
+-79
+-72
+-67
+-64
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+110
+104
+96
+88
+81
+76
+72
+-13
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-115
+-106
+-98
+-91
+-86
+-80
+-74
+-67
+-63
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+5
+-102
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+113
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+122
+113
+105
+98
+92
+84
+78
+73
+69
+64
+58
+-26
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-116
+-109
+-101
+-92
+-86
+-81
+-76
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+114
+1
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+112
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+121
+114
+106
+97
+90
+86
+80
+73
+68
+65
+60
+-25
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-117
+-109
+-101
+-93
+-86
+-80
+-76
+93
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+115
+1
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-10
+111
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+113
+106
+98
+90
+84
+78
+74
+69
+63
+58
+-25
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-126
+-117
+-108
+-99
+-92
+-87
+-81
+-76
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+107
+101
+93
+86
+80
+75
+69
+-16
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-57
+70
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-26
+97
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-18
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+75
+-37
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-112
+-106
+-98
+-90
+-83
+-77
+-73
+-68
+-62
+107
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+5
+-103
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-8
+114
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-31
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-33
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+111
+104
+96
+88
+82
+77
+72
+66
+61
+57
+-26
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-61
+64
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-111
+-104
+-99
+-92
+-85
+-79
+-75
+-69
+-63
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+120
+110
+101
+94
+88
+83
+77
+70
+-15
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-114
+-107
+-100
+-91
+-84
+-78
+-74
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+108
+100
+94
+87
+80
+74
+70
+-14
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+68
+-43
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-26
+99
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-111
+-104
+-98
+-91
+-83
+-76
+-71
+-67
+-63
+107
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+109
+101
+94
+89
+82
+75
+70
+-13
+-113
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-116
+-107
+-99
+-91
+-85
+-80
+-75
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+117
+110
+101
+93
+86
+81
+76
+70
+-15
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-122
+-114
+-107
+-100
+-92
+-84
+-78
+-74
+95
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+115
+106
+100
+94
+87
+80
+74
+69
+-14
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-116
+-107
+-98
+-91
+-86
+-80
+-75
+96
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+114
+0
+-107
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-11
+111
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+82
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+79
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+102
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+111
+103
+97
+90
+83
+77
+72
+68
+64
+58
+-26
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-61
+66
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+65
+-46
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-23
+100
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-36
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-19
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+80
+-32
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-120
+-111
+-104
+-98
+-91
+-84
+-76
+-71
+-67
+-63
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+111
+102
+94
+88
+82
+78
+71
+-15
+-115
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-57
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+67
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-24
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-121
+-112
+-103
+-96
+-90
+-85
+-79
+-72
+-66
+-62
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+3
+-105
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-7
+114
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-31
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-18
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+119
+111
+103
+98
+90
+83
+76
+71
+67
+63
+57
+-27
+-126
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-117
+-109
+-102
+-93
+-86
+-81
+-76
+93
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+125
+118
+109
+100
+92
+86
+81
+76
+69
+-15
+-116
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-59
+67
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+70
+-41
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-113
+-104
+-98
+-92
+-85
+-78
+-72
+-68
+-64
+105
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+4
+-103
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-6
+117
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+81
+-30
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+77
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-20
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+118
+109
+102
+96
+89
+82
+75
+72
+67
+61
+56
+-27
+-125
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-125
+-117
+-109
+-101
+-92
+-85
+-80
+-76
+94
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+124
+115
+107
+101
+94
+87
+80
+75
+70
+-13
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+68
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-43
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-123
+-115
+-108
+-100
+-91
+-86
+-81
+-75
+-68
+-64
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+2
+-106
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-8
+115
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+121
+113
+106
+99
+91
+84
+78
+74
+69
+64
+58
+-26
+-124
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-61
+66
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+66
+-44
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-114
+-106
+-100
+-93
+-85
+-79
+-74
+-69
+-64
+106
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+109
+103
+96
+89
+81
+76
+71
+-12
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-56
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+69
+-41
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-124
+-115
+-105
+-97
+-91
+-86
+-80
+-73
+-67
+-63
+104
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+117
+109
+103
+95
+88
+81
+76
+72
+-13
+-114
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-55
+69
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+68
+-42
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-25
+99
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+78
+-34
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+103
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-35
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-21
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+126
+76
+-36
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-127
+-22
+101
+126
+126
+126
+126
+126
+126
+126
+126
+126
From bf5604808dbce0829f125f1e2ed135a3d0acc90c Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 11:13:46 +0200
Subject: [PATCH 069/527] add regression test for biothermo
---
pm3test.sh | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/pm3test.sh b/pm3test.sh
index 27a7619b8..3bd7ae3a8 100755
--- a/pm3test.sh
+++ b/pm3test.sh
@@ -116,19 +116,21 @@ while true; do
if ! CheckExecute "trace load/list x" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list x 1;'" "0.0101840425"; then break; fi
echo -e "\n${C_BLUE}Testing LF:${C_NC}"
- if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
- if ! CheckExecute "lf EM410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
- if ! CheckExecute "lf VISA2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
- if ! CheckExecute "lf AWID test" "$PM3BIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
- if ! CheckExecute "lf SECURAKEY test" "$PM3BIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
- if ! CheckExecute "lf NEXWATCH test" "$PM3BIN -c 'data load traces/quadrakey-521512301.pm3;lf search 1 '" "NexWatch ID found"; then break; fi
- if ! CheckExecute "lf KERI test" "$PM3BIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
- if ! CheckExecute "lf HID Prox test" "$PM3BIN -c 'data load traces/hid-proxCardII-05512-11432784-1.pm3;lf search 1'" "HID Prox ID found"; then break; fi
- if ! CheckExecute "lf PARADOX test" "$PM3BIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
- if ! CheckExecute "lf PAC test" "$PM3BIN -c 'data load traces/pac-8E4C058E.pm3;lf search 1'" "PAC/Stanley ID found"; then break; fi
- if ! CheckExecute "lf VIKING test" "$PM3BIN -c 'data load traces/Transit999-best.pm3;lf search 1'" "Viking ID found"; then break; fi
- if ! CheckExecute "lf FDX-B test" "$PM3BIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
- if ! CheckExecute "lf INDALA test" "$PM3BIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
+ if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
+ if ! CheckExecute "lf EM410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
+ if ! CheckExecute "lf VISA2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
+ if ! CheckExecute "lf AWID test" "$PM3BIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
+ if ! CheckExecute "lf SECURAKEY test" "$PM3BIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
+ if ! CheckExecute "lf NEXWATCH test" "$PM3BIN -c 'data load traces/quadrakey-521512301.pm3;lf search 1 '" "NexWatch ID found"; then break; fi
+ if ! CheckExecute "lf KERI test" "$PM3BIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
+ if ! CheckExecute "lf HID Prox test" "$PM3BIN -c 'data load traces/hid-proxCardII-05512-11432784-1.pm3;lf search 1'" "HID Prox ID found"; then break; fi
+ if ! CheckExecute "lf PARADOX test" "$PM3BIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
+ if ! CheckExecute "lf PAC test" "$PM3BIN -c 'data load traces/pac-8E4C058E.pm3;lf search 1'" "PAC/Stanley ID found"; then break; fi
+ if ! CheckExecute "lf VIKING test" "$PM3BIN -c 'data load traces/Transit999-best.pm3;lf search 1'" "Viking ID found"; then break; fi
+ if ! CheckExecute "lf FDX-B test" "$PM3BIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
+ if ! CheckExecute "lf INDALA test" "$PM3BIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
+ if ! CheckExecute "lf FDX/BioThermo test" "$PM3BIN -c 'data load traces/lf_fdx_biothermo.pm3; lf fdx demo'" "95.2 F / 35.1 C"; then break; fi
+
echo -e "\n${C_BLUE}Testing HF:${C_NC}"
if ! CheckExecute "hf mf offline text" "$PM3BIN -c 'hf mf'" "at_enc"; then break; fi
From a31c20753f7d33980860dfd799b659f5854d622a Mon Sep 17 00:00:00 2001
From: Iceman
Date: Wed, 20 May 2020 11:19:50 +0200
Subject: [PATCH 070/527] Update README.md
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 261d65e0b..8222032f2 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@ This repo compiles nicely on
- Windows/mingw environment with Qt5.6.1 & GCC 4.9
- Ubuntu 1604 -> 2004
- ParrotOS, Gentoo, Pentoo, Kali, Nethunter, Archlinux, Fedora, Debian
+ - Rasbian
- Android / Termux
- Mac OS X / Homebrew
- WSL, WSL2 (Windows subsystem linux) on Windows 10
@@ -70,8 +71,8 @@ This repo compiles nicely on
Hardware to run client on
- PC
- - Andriod
- - Rasbian Pi
+ - Android
+ - Raspberry Pi & Raspberry Pi Zero
- Jetson Nano
## Roadmap
From 56bde131109e3aa228127febb78158fefd78971f Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 14:15:35 +0200
Subject: [PATCH 071/527] format string
---
client/src/cmdhfmfdes.c | 6 +++---
client/src/cmdhfmfp.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index 7dd07655b..c8bf75424 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -4002,21 +4002,21 @@ static int CmdHF14aDesChk(const char *Cmd) {
PrintAndLogEx(ERR, "Aes key list is empty. Nothing to check.");
return PM3_EINVARG;
} else {
- PrintAndLogEx(INFO, "Loaded " _YELLOW_("%zu") " aes keys", aeskeyListLen);
+ PrintAndLogEx(INFO, "Loaded " _YELLOW_("%"PRIu32) " aes keys", aeskeyListLen);
}
if (deskeyListLen == 0) {
PrintAndLogEx(ERR, "Des key list is empty. Nothing to check.");
return PM3_EINVARG;
} else {
- PrintAndLogEx(INFO, "Loaded " _YELLOW_("%zu") " des keys", deskeyListLen);
+ PrintAndLogEx(INFO, "Loaded " _YELLOW_("%"PRIu32) " des keys", deskeyListLen);
}
if (k3kkeyListLen == 0) {
PrintAndLogEx(ERR, "K3k key list is empty. Nothing to check.");
return PM3_EINVARG;
} else {
- PrintAndLogEx(INFO, "Loaded " _YELLOW_("%zu") " k3kdes keys", k3kkeyListLen);
+ PrintAndLogEx(INFO, "Loaded " _YELLOW_("%"PRIu32) " k3kdes keys", k3kkeyListLen);
}
if (!verbose)
diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c
index 27c606203..b3c8e5c22 100644
--- a/client/src/cmdhfmfp.c
+++ b/client/src/cmdhfmfp.c
@@ -1191,7 +1191,7 @@ static int CmdHFMFPChk(const char *Cmd) {
PrintAndLogEx(ERR, "Key list is empty. Nothing to check.");
return PM3_EINVARG;
} else {
- PrintAndLogEx(INFO, "Loaded " _YELLOW_("%zu") " keys", keyListLen);
+ PrintAndLogEx(INFO, "Loaded " _YELLOW_("%"PRIu32) " keys", keyListLen);
}
if (!verbose)
From 8792314609fd1d71b83e4caf54f0de47afba0ba2 Mon Sep 17 00:00:00 2001
From: FlUxIUS
Date: Wed, 20 May 2020 15:59:06 +0200
Subject: [PATCH 072/527] Oyster MDES trace
---
traces/hf_mdes_oyster_reader.trace | Bin 0 -> 203 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 traces/hf_mdes_oyster_reader.trace
diff --git a/traces/hf_mdes_oyster_reader.trace b/traces/hf_mdes_oyster_reader.trace
new file mode 100644
index 0000000000000000000000000000000000000000..ef42bf4d69272fcb8036143a982663bc945f5fdc
GIT binary patch
literal 203
zcmWHPW?*>0%*YVLaM29L3Jij=F6P2mft@f`>qG_y2TrC27v=*OmoP9a;ACQ$tkBT9
ziGhJZoVB5YrB_9D!^K)g1_ez{hRFqBe%7wF46Lge84mC=H>lh&dvI|dBUs;5puRJV
zV0}jF)(z_%F1~~4n_2+opZYS9fmMcyfq{>?LE%q3*X
QI2zbW%Nv;*m_BR-0MgDlU;qFB
literal 0
HcmV?d00001
From f79df08f26a6afd04f17a96341c9b3a67f4516ae Mon Sep 17 00:00:00 2001
From: FlUxIUS
Date: Wed, 20 May 2020 16:09:05 +0200
Subject: [PATCH 073/527] Adding HF 15 traces
---
traces/hf_15_reader.trace | Bin 0 -> 36 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 traces/hf_15_reader.trace
diff --git a/traces/hf_15_reader.trace b/traces/hf_15_reader.trace
new file mode 100644
index 0000000000000000000000000000000000000000..e3ea16c2b2bbc2d2e5b2ccb115b9873efc33fce5
GIT binary patch
literal 36
qcmXreWMC-ZWo1xfWcbF#u)&N02zVM87@HF+?PfHvKe%GdzyJVun+O&F
literal 0
HcmV?d00001
From b22ea6f8469a6772163cdc8de520d8ad4b219079 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 18:28:10 +0200
Subject: [PATCH 074/527] fix: matty_run eloadcard
---
armsrc/Standalone/hf_mattyrun.c | 266 +++++++++++++++++++++++---------
1 file changed, 189 insertions(+), 77 deletions(-)
diff --git a/armsrc/Standalone/hf_mattyrun.c b/armsrc/Standalone/hf_mattyrun.c
index 1ffa321a3..e6e099d7c 100644
--- a/armsrc/Standalone/hf_mattyrun.c
+++ b/armsrc/Standalone/hf_mattyrun.c
@@ -53,15 +53,12 @@ static uint8_t uid[10];
static uint32_t cuid;
static iso14a_card_select_t p_card;
-/*
- Pseudo-configuration block.
-*/
+// Pseudo-configuration block.
static bool printKeys = false; // Prints keys
static bool transferToEml = true; // Transfer keys to emulator memory
static bool ecfill = true; // Fill emulator memory with cards content.
static bool simulation = true; // Simulates an exact copy of the target tag
static bool fillFromEmulator = false; // Dump emulator memory.
-static uint8_t stKeyBlock = 20; // Set the quantity of keys in the block.
//-----------------------------------------------------------------------------
// Matt's StandAlone mod.
@@ -179,7 +176,8 @@ static int saMifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_
/* the chk function is a piwi’ed(tm) check that will try all keys for
a particular sector. also no tracing no dbg */
-static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, uint8_t keyCount, uint8_t *datain, uint64_t *key) {
+static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace,
+ uint8_t keyCount, uint8_t *datain, uint64_t *key) {
DBGLEVEL = DBG_NONE;
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
set_tracing(false);
@@ -188,13 +186,15 @@ static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, ui
struct Crypto1State *pcs;
pcs = &mpcs;
- for (int i = 0; i < keyCount; ++i) {
+ int retval = -1;
+
+ for (uint8_t i = 0; i < keyCount; i++) {
/* no need for anticollision. just verify tag is still here */
// if (!iso14443a_fast_select_card(cjuid, 0)) {
if (!iso14443a_select_card(uid, &p_card, &cuid, true, 0, true)) {
DbprintfEx(FLAG_NEWLINE, "FATAL : E_MF_LOSTTAG");
- return -1;
+ break;
}
uint64_t ui64Key = bytes_to_num(datain + i * 6, 6);
@@ -205,45 +205,111 @@ static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, ui
SpinDelayUs(AUTHENTICATION_TIMEOUT);
continue;
}
- crypto1_deinit(pcs);
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
*key = ui64Key;
- return i;
+ retval = i;
+ break;
}
crypto1_deinit(pcs);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-
- return -1;
+ return retval;
}
+/* Abusive microgain on original MifareECardLoad :
+ * - *datain used as error return
+ * - tracing is falsed
+ */
+static int saMifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
+ DBGLEVEL = DBG_NONE;
+
+ uint8_t numSectors = numofsectors;
+ uint8_t keyType = keytype;
+
+ struct Crypto1State mpcs = {0, 0};
+ struct Crypto1State *pcs;
+ pcs = &mpcs;
+
+ uint8_t dataoutbuf[16];
+ uint8_t dataoutbuf2[16];
+
+ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
+ clear_trace();
+ set_tracing(false);
+
+ int retval = PM3_SUCCESS;
+
+ if (!iso14443a_select_card(uid, &p_card, &cuid, true, 0, true)) {
+ retval = PM3_ESOFT;
+ DbprintfEx(FLAG_RAWPRINT, "Can't select card");
+ goto out;
+ }
+
+ for (uint8_t s = 0; s < numSectors; s++) {
+ uint64_t ui64Key = emlGetKey(s, keyType);
+ if (s == 0) {
+ if (mifare_classic_auth(pcs, cuid, FirstBlockOfSector(s), keyType, ui64Key, AUTH_FIRST)) {
+ retval = PM3_ESOFT;
+ break;
+ }
+ } else {
+ if (mifare_classic_auth(pcs, cuid, FirstBlockOfSector(s), keyType, ui64Key, AUTH_NESTED)) {
+ retval = PM3_ESOFT;
+ break;
+ }
+ }
+
+ // failure to read one block, skips to next sector.
+ for (uint8_t blockNo = 0; blockNo < NumBlocksPerSector(s); blockNo++) {
+ if (mifare_classic_readblock(pcs, cuid, FirstBlockOfSector(s) + blockNo, dataoutbuf)) {
+ retval = PM3_ESOFT;
+ break;
+ };
+
+ if (blockNo < NumBlocksPerSector(s) - 1) {
+ emlSetMem(dataoutbuf, FirstBlockOfSector(s) + blockNo, 1);
+ } else {
+ // sector trailer, keep the keys, set only the AC
+ emlGetMem(dataoutbuf2, FirstBlockOfSector(s) + blockNo, 1);
+ memcpy(&dataoutbuf2[6], &dataoutbuf[6], 4);
+ emlSetMem(dataoutbuf2, FirstBlockOfSector(s) + blockNo, 1);
+ }
+ }
+ }
+
+ int res = mifare_classic_halt(pcs, cuid);
+ (void)res;
+
+out:
+ crypto1_deinit(pcs);
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+ return retval;
+}
+
+
void ModInfo(void) {
DbpString(" HF Mifare sniff/clone - aka MattyRun (Matías A. Ré Medina)");
}
+/*
+ It will check if the keys from the attacked tag are a subset from
+ the hardcoded set of keys inside of the ARM. If this is the case
+ then it will load the keys into the emulator memory and also the
+ content of the victim tag, to finally simulate it.
+
+ Alternatively, it can be dumped into a blank card.
+
+ This source code has been tested only in Mifare 1k.
+
+ If you're using the proxmark connected to a device that has an OS, and you're not using the proxmark3 client to see the debug
+ messages, you MUST uncomment usb_disable().
+*/
void RunMod(void) {
StandAloneMode();
- Dbprintf(">> Matty mifare chk/dump/sim a.k.a MattyRun Started <<");
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
-
- /*
- It will check if the keys from the attacked tag are a subset from
- the hardcoded set of keys inside of the ARM. If this is the case
- then it will load the keys into the emulator memory and also the
- content of the victim tag, to finally simulate it.
-
- Alternatively, it can be dumped into a blank card.
-
- This source code has been tested only in Mifare 1k.
-
- If you're using the proxmark connected to a device that has an OS, and you're not using the proxmark3 client to see the debug
- messages, you MUST uncomment usb_disable().
- */
+ Dbprintf(">> Matty mifare chk/dump/sim a.k.a MattyRun Started <<");
// Comment this line below if you want to see debug messages.
// usb_disable();
-
-
uint16_t mifare_size = 1024; // Mifare 1k (only 1k supported for now)
uint8_t sectorSize = 64; // 1k's sector size is 64 bytes.
uint8_t blockNo = 3; // Security block is number 3 for each sector.
@@ -252,9 +318,7 @@ void RunMod(void) {
uint8_t *keyBlock; // Where the keys will be held in memory.
bool keyFound = false;
- /*
- Set of keys to be used.
- */
+ // Set of keys to be used.
uint64_t mfKeys[] = {
0xffffffffffff, // Default key
0x000000000000, // Blank key
@@ -269,22 +333,73 @@ void RunMod(void) {
0xa0478cc39091,
0x533cb6c723f6,
0x8fd0a4f256e9,
+ 0x484558414354, // INFINEONON A / 0F SEC B / INTRATONE / HEXACT...
+ 0x414c41524f4e, // ALARON NORALSY
+ 0x424c41524f4e, // BLARON NORALSY
+ 0x4a6352684677, // COMELIT A General Key / 08 [2] 004
+ 0x536653644c65, // COMELIT B General Key / 08 [2] 004
+ 0x8829da9daf76, // URMET CAPTIV IF A => ALL A/B / BTICINO
+ 0x314B49474956, // "1KIGIV" VIGIK'S SERVICE BADGE A KEY
+ 0x021209197591, // BTCINO UNDETERMINED SPREAKD 0x01->0x13 key
+ 0x010203040506, // VIGIK's B Derivative
+ 0xa22ae129c013, // INFINEON B 00
+ 0x49fae4e3849f, // INFINEON B 01
+ 0x38fcf33072e0, // INFINEON B 02
+ 0x8ad5517b4b18, // INFINEON B 03
+ 0x509359f131b1, // INFINEON B 04
+ 0x6c78928e1317, // INFINEON B 05
+ 0xaa0720018738, // INFINEON B 06
+ 0xa6cac2886412, // INFINEON B 07
+ 0x62d0c424ed8e, // INFINEON B 08
+ 0xe64a986a5d94, // INFINEON B 09
+ 0x8fa1d601d0a2, // INFINEON B 0A
+ 0x89347350bd36, // INFINEON B 0B
+ 0x66d2b7dc39ef, // INFINEON B 0C
+ 0x6bc1e1ae547d, // INFINEON B 0D
+ 0x22729a9bd40f, // INFINEON B 0E
+ 0xd2ece8b9395e, // lib / Nat Bieb
+ 0x1494E81663D7, // # NSCP default key
+ 0x569369c5a0e5, // # kiev
+ 0x632193be1c3c, // # kiev
+ 0x644672bd4afe, // # kiev
+ 0x8fe644038790, // # kiev
+ 0x9de89e070277, // # kiev
+ 0xb5ff67cba951, // # kiev / ov-chipkaart
+ 0xeff603e1efe9, // # kiev
+ 0xf14ee7cae863, // # kiev
+ 0xfc00018778f7, // # Västtrafiken KeyA, RKF ÖstgötaTrafiken KeyA
+ 0x0297927c0f77, // # Västtrafiken KeyA
+ 0x54726176656c, // # Västtrafiken KeyA
+ 0x00000ffe2488, // # Västtrafiken KeyB
+ 0x776974687573, // # Västtrafiken KeyB
+ 0xee0042f88840, // # Västtrafiken KeyB
+ 0x26940b21ff5d, // # RKF SLKeyA
+ 0xa64598a77478, // # RKF SLKeyA
+ 0x5c598c9c58b5, // # RKF SLKeyB
+ 0xe4d2770a89be, // # RKF SLKeyB
+ 0x722bfcc5375f, // # RKF RejskortDanmark KeyA
+ 0xf1d83f964314, // # RKF RejskortDanmark KeyB
+ 0x505249564141, // # RKF JOJOPRIVAKeyA
+ 0x505249564142, // # RKF JOJOPRIVAKeyB
+ 0x47524f555041, // # RKF JOJOGROUPKeyA
+ 0x47524f555042, // # RKF JOJOGROUPKeyB
+ 0x434f4d4d4f41, // # RKF JOJOGROUPKeyA
+ 0x434f4d4d4f42, // # RKF JOJOGROUPKeyB
+ 0x4b0b20107ccb, // # TNP3xxx
};
/*
This part allocates the byte representation of the
keys in keyBlock's memory space .
*/
- keyBlock = BigBuf_malloc(stKeyBlock * 6);
+ keyBlock = BigBuf_malloc(ARRAYLEN(mfKeys) * 6);
int mfKeysCnt = ARRAYLEN(mfKeys);
for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) {
num_to_bytes(mfKeys[mfKeyCounter], 6, (uint8_t *)(keyBlock + mfKeyCounter * 6));
}
- /*
- Pretty print of the keys to be checked.
- */
+ // Pretty print of the keys to be checked.
if (printKeys) {
Dbprintf("[+] Printing mf keys");
for (uint8_t keycnt = 0; keycnt < mfKeysCnt; keycnt++)
@@ -301,18 +416,19 @@ void RunMod(void) {
*/
bool validKey[2][40];
uint8_t foundKey[2][40][6];
- for (uint16_t t = 0; t < 2; t++) {
+ for (uint8_t i = 0; i < 2; i++) {
for (uint16_t sectorNo = 0; sectorNo < sectorsCnt; sectorNo++) {
- validKey[t][sectorNo] = false;
- for (uint16_t i = 0; i < 6; i++) {
- foundKey[t][sectorNo][i] = 0xff;
- }
+ validKey[i][sectorNo] = false;
+ foundKey[i][sectorNo][0] = 0xFF;
+ foundKey[i][sectorNo][1] = 0xFF;
+ foundKey[i][sectorNo][2] = 0xFF;
+ foundKey[i][sectorNo][3] = 0xFF;
+ foundKey[i][sectorNo][4] = 0xFF;
+ foundKey[i][sectorNo][5] = 0xFF;
}
}
- /*
- Iterates through each sector checking if there is a correct key.
- */
+ // Iterates through each sector checking if there is a correct key.
bool err = 0;
bool allKeysFound = true;
uint32_t size = mfKeysCnt;
@@ -324,7 +440,7 @@ void RunMod(void) {
int key = saMifareChkKeys(block, type, true, size, &keyBlock[0], &key64);
if (key == -1) {
LED(LED_RED, 50);
- Dbprintf("\t✕ Key not found for this sector!");
+ Dbprintf("\t [✕] Key not found for this sector!");
allKeysFound = false;
// break;
} else if (key == -2) {
@@ -334,7 +450,7 @@ void RunMod(void) {
num_to_bytes(key64, 6, foundKey[type][sec]);
validKey[type][sec] = true;
keyFound = true;
- Dbprintf("\t✓ Found valid key: [%02x%02x%02x%02x%02x%02x]\n",
+ Dbprintf("\t [✓] Found valid key: [%02x%02x%02x%02x%02x%02x]\n",
(keyBlock + 6 * key)[0], (keyBlock + 6 * key)[1], (keyBlock + 6 * key)[2],
(keyBlock + 6 * key)[3], (keyBlock + 6 * key)[4], (keyBlock + 6 * key)[5]
);
@@ -371,8 +487,9 @@ void RunMod(void) {
emlClearMem();
uint8_t mblock[16];
- for (uint16_t sectorNo = 0; sectorNo < sectorsCnt; sectorNo++) {
+ for (uint8_t sectorNo = 0; sectorNo < sectorsCnt; sectorNo++) {
if (validKey[0][sectorNo] || validKey[1][sectorNo]) {
+
emlGetMem(mblock, FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 1); // data, block num, blocks count (max 4)
for (uint16_t t = 0; t < 2; t++) {
if (validKey[t][sectorNo]) {
@@ -382,47 +499,40 @@ void RunMod(void) {
emlSetMem(mblock, FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 1);
}
}
- Dbprintf("\t✓ Found keys have been transferred to the emulator memory.");
+
+ Dbprintf("\t [✓] Found keys have been transferred to the emulator memory.");
+
if (ecfill) {
int filled;
Dbprintf("\tFilling in with key A.");
- filled = MifareECardLoad(sectorsCnt, 0);
+
+ filled = saMifareECardLoad(sectorsCnt, 0);
if (filled != PM3_SUCCESS) {
- Dbprintf("\t✕ Failed filling with A.");
- }
-
- Dbprintf("\tFilling in with key B.");
- filled = MifareECardLoad(sectorsCnt, 1);
- if (filled != PM3_SUCCESS) {
- Dbprintf("\t✕ Failed filling with B.");
+
+ Dbprintf("\t [✕] Failed filling with A.");
+ Dbprintf("\tFilling in with key B.");
+ filled = saMifareECardLoad(sectorsCnt, 1);
+ if (filled != PM3_SUCCESS) {
+ Dbprintf("\t [✕] Failed filling with B.");
+ }
}
if ((filled == PM3_SUCCESS) && simulation) {
- Dbprintf("\t✓ Emulator memory filled, simulation started.");
+ Dbprintf("\t [✓] Emulator memory filled, simulation started.");
// This will tell the fpga to emulate using previous keys and current target tag content.
Dbprintf("\t Press button to abort simulation at anytime.");
LED_B_ON(); // green
- // assuming arg0==0, use hardcoded uid 0xdeadbeaf
- uint16_t simflags;
- switch (p_card.uidlen) {
- case 10:
- simflags = FLAG_10B_UID_IN_DATA;
- break;
- case 7:
- simflags = FLAG_7B_UID_IN_DATA;
- break;
- default:
- simflags = FLAG_4B_UID_IN_DATA;
- break;
- }
- Mifare1ksim(simflags | FLAG_MF_1K, 0, uid, 0, 0);
- LED_B_OFF();
- /*
- Needs further testing.
- */
+ uint16_t simflags = FLAG_UID_IN_EMUL | FLAG_MF_1K;
+
+ SpinOff(1000);
+ Mifare1ksim(simflags, 0, uid, 0, 0);
+ LED_B_OFF();
+ Dbprintf("\t [✓] Simulation ended");
+
+ // Needs further testing.
if (fillFromEmulator) {
uint8_t retry = 5;
Dbprintf("\t Trying to dump into blank card.");
@@ -457,8 +567,10 @@ void RunMod(void) {
}
}
- } else if (filled != PM3_SUCCESS) {
- Dbprintf("\t✕ Emulator memory could not be filled due to errors.");
+ }
+
+ if (filled != PM3_SUCCESS) {
+ Dbprintf("\t [✕] Emulator memory could not be filled due to errors.");
LED_C_ON();
}
}
From 30be05ec3f0269fb45ad8d5e400a6887704d97e8 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 18:28:43 +0200
Subject: [PATCH 075/527] chg: removed debugstatements, the code doesnt use
them
---
armsrc/Standalone/hf_colin.c | 125 +++++++++++++----------------------
1 file changed, 45 insertions(+), 80 deletions(-)
diff --git a/armsrc/Standalone/hf_colin.c b/armsrc/Standalone/hf_colin.c
index 0656d1186..ba5c21cab 100644
--- a/armsrc/Standalone/hf_colin.c
+++ b/armsrc/Standalone/hf_colin.c
@@ -232,14 +232,6 @@ static void cjSetCursLeft(void) {
static void cjTabulize(void) { DbprintfEx(FLAG_RAWPRINT, "\t\t\t"); }
-/*
-void cjPrintKey(uint64_t key, uint8_t *foundKey, uint16_t sectorNo, uint8_t type) {
- char tosendkey[13];
- sprintf(tosendkey, "%02x%02x%02x%02x%02x%02x", foundKey[0], foundKey[1], foundKey[2], foundKey[3], foundKey[4],
-foundKey[5]); cjSetCursRight(); DbprintfEx(FLAG_NEWLINE, "SEC: %02x | KEY : %s | TYP: %d", sectorNo, tosendkey, type);
-}
-*/
-
static char *ReadSchemasFromSPIFFS(char *filename) {
SpinOff(0);
@@ -292,6 +284,7 @@ static void ReadLastTagFromFlash(void) {
// this one will handle filetype (symlink or not) and resolving by itself
rdv40_spiffs_read_as_filetype((char *)HFCOLIN_LASTTAG_SYMLINK, (uint8_t *)mem, len, RDV40_SPIFFS_SAFETY_SAFE);
+ // copy 64blocks (16bytes) starting w block0, to emulator mem.
emlSetMem(mem, 0, 64);
DbprintfEx(FLAG_NEWLINE, "[OK] Last tag recovered from FLASHMEM set to emulator");
@@ -330,16 +323,22 @@ void WriteTagToFlash(uint32_t uid, size_t size) {
return;
}
-void ModInfo(void) { DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)"); }
+void ModInfo(void) {
+ DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)");
+}
void RunMod(void) {
StandAloneMode();
+ FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
+ Dbprintf(">> HF Mifare ultra fast sniff/sim/clone a.k.a VIGIKPWN Started <<");
+ // turn off all debugging.
+ DBGLEVEL = DBG_NONE;
+
// add_schema(Schemas, Noralsy, &total_schemas);
// add_schema(Schemas, InfiHexact, &total_schemas);
// add_schema_from_json_in_spiffs((char *)HFCOLIN_URMETCAPTIVE_JSON);
// add_schema(Schemas, UrmetCaptive, &total_schemas);
- FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
currline = 20;
curlline = 20;
@@ -386,11 +385,11 @@ void RunMod(void) {
ACCBITS : 796788[00]+VALUE
*/
-//----------------------------
+// ----------------------------
// Set of keys to be used.
// This should cover ~98% of
// French VIGIK system @2017
-//----------------------------
+// ----------------------------
const uint64_t mfKeys[] = {
0xffffffffffff, // TRANSPORTS
@@ -459,7 +458,6 @@ void RunMod(void) {
bool err = 0;
bool trapped = 0;
bool allKeysFound = true;
-
uint32_t size = mfKeysCnt;
// banner:
@@ -487,7 +485,7 @@ failtag:
SpinOff(50);
LED_A_ON();
uint8_t ticker = 0;
- // while (!BUTTON_PRESS() && !iso14443a_select_card(cjuid, NULL, &cjcuid, true, 0, true))
+
while (!iso14443a_select_card(cjuid, &p_card, &cjcuid, true, 0, true)) {
WDT_HIT();
@@ -505,8 +503,8 @@ failtag:
}
SpinOff(50);
-
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+
vtsend_cursor_position_restore(NULL);
DbprintfEx(FLAG_NEWLINE, "\t\t\t%s[ GOT a Tag ! ]%s", _XGREEN_, _XWHITE_);
cjSetCursLeft();
@@ -534,7 +532,7 @@ failtag:
uint32_t start_time = GetTickCount();
uint32_t delta_time = 0;
- //---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
// WE SHOULD FIND A WAY TO GET UID TO AVOID THIS "TESTRUN"
// --------------------------------------------------------
// + HERE IS TO BE THOUGHT AS ONLY A KEY SHOULD BE CHECK
@@ -544,7 +542,7 @@ failtag:
// `-+ THEN FILL EMULATOR WITH B KEEY
// `-+ THEN EMULATOR WITH CARD WITH B KEY
// `-+ IF IT HAS FAILED OF ANY OF SORT THEN WE ARE MARRON LIKE POMALO.
- //----------------------------------------------------------------------------
+ // ----------------------------------------------------------------------------
// AN EVEN BETTER IMPLEMENTATION IS TO CHECK EVERY KEY FOR SECTOR 0 KEY A
// THEN IF FOUND CHECK THE SAME KEY FOR NEXT SECTOR ONLY KEY A
// THEN IF FAIL CHECK EVERY SECTOR A KEY FOR EVERY OTHER KEY BUT NOT THE BLOCK
@@ -558,7 +556,7 @@ failtag:
// DERIVATION
// THEN IF B KEY IS NOT OF THIS SCHEME CHECK EVERY REMAINING B KEYED SECTOR
// WITH EVERY REMAINING KEYS, BUT DISCARDING ANY DEFAULT TRANSPORT KEYS.
- //-----------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------
// also we could avoid first UID check for every block
// then let's expose this optimal case of well known vigik schemes :
@@ -625,7 +623,6 @@ failtag:
break;
}
}
-
/* etc etc for testing schemes quick schemes */
}
}
@@ -641,7 +638,7 @@ failtag:
return;
}
- /* Settings keys to emulator */
+ // Settings keys to emulator
emlClearMem();
uint8_t mblock[16];
for (uint8_t sectorNo = 0; sectorNo < sectorsCnt; sectorNo++) {
@@ -655,7 +652,7 @@ failtag:
DbprintfEx(FLAG_NEWLINE, "%s>>%s Setting Keys->Emulator MEM...[%sOK%s]", _XYELLOW_, _XWHITE_, _XGREEN_, _XWHITE_);
- /* filling TAG to emulator */
+ // filling TAG to emulator
int filled;
cjSetCursLeft();
@@ -666,11 +663,10 @@ failtag:
DbprintfEx(FLAG_NEWLINE, "%s>>%s W_FAILURE ! %sTrying fallback B keys....", _XRED_, _XORANGE_, _XWHITE_);
- /* no trace, no dbg */
+ // no trace, no dbg
filled = e_MifareECardLoad(sectorsCnt, 1);
if (filled != PM3_SUCCESS) {
cjSetCursLeft();
-
DbprintfEx(FLAG_NEWLINE, "FATAL:EML_FALLBACKFILL_B");
SpinErr(LED_C, 100, 8);
SpinOff(100);
@@ -717,10 +713,9 @@ readysim:
SpinOff(100);
LED_C_ON();
- DBGLEVEL = DBG_NONE;
-
- //uint16_t flags=0;
- /*switch (p_card.uidlen) {
+ /*
+ uint16_t flags = 0;
+ switch (p_card.uidlen) {
case 10:
flags = FLAG_10B_UID_IN_DATA;
break;
@@ -733,19 +728,18 @@ readysim:
default:
flags = FLAG_UID_IN_EMUL;
break;
- }*/
-
+ }
// Use UID, SAK, ATQA from EMUL, if uid not defined
- // if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
- //flags |= FLAG_UID_IN_EMUL;
- //}
- //flags |= FLAG_MF_1K;
- //if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
- // flags |= FLAG_UID_IN_EMUL;
- //}
- //flags = 0x10;
- uint16_t flags = 0;
- flags = 16;
+ if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
+ flags |= FLAG_UID_IN_EMUL;
+ }
+ flags |= FLAG_MF_1K;
+ if ((flags & (FLAG_4B_UID_IN_DATA | FLAG_7B_UID_IN_DATA | FLAG_10B_UID_IN_DATA)) == 0) {
+ flags |= FLAG_UID_IN_EMUL;
+ }
+ flags = 0x10;
+ */
+ uint16_t flags = FLAG_UID_IN_EMUL;
DbprintfEx(FLAG_NEWLINE, "\n\n\n\n\n\n\n\nn\n\nn\n\n\nflags: %d (0x%02x)", flags, flags);
cjSetCursLeft();
SpinOff(1000);
@@ -789,8 +783,6 @@ readysim:
* - tracing is falsed
*/
int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
- DBGLEVEL = DBG_NONE;
-
uint8_t numSectors = numofsectors;
uint8_t keyType = keytype;
@@ -802,7 +794,6 @@ int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
uint8_t dataoutbuf2[16];
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
-
clear_trace();
set_tracing(false);
@@ -810,24 +801,17 @@ int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
if (!iso14443a_select_card(cjuid, &p_card, &cjcuid, true, 0, true)) {
isOK = false;
- if (DBGLEVEL >= 1)
- DbprintfEx(FLAG_RAWPRINT, "Can't select card");
}
for (uint8_t s = 0; isOK && s < numSectors; s++) {
uint64_t ui64Key = emlGetKey(s, keyType);
if (s == 0) {
if (isOK && mifare_classic_auth(pcs, cjcuid, FirstBlockOfSector(s), keyType, ui64Key, AUTH_FIRST)) {
-
- if (DBGLEVEL >= 1)
- DbprintfEx(FLAG_NEWLINE, "Sector[%2d]. Auth error", s);
break;
}
} else {
if (isOK && mifare_classic_auth(pcs, cjcuid, FirstBlockOfSector(s), keyType, ui64Key, AUTH_NESTED)) {
isOK = false;
- if (DBGLEVEL >= 1)
- DbprintfEx(FLAG_NEWLINE, "Sector[%2d]. Auth nested error", s);
break;
}
}
@@ -835,8 +819,6 @@ int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
for (uint8_t blockNo = 0; isOK && blockNo < NumBlocksPerSector(s); blockNo++) {
if (isOK && mifare_classic_readblock(pcs, cjcuid, FirstBlockOfSector(s) + blockNo, dataoutbuf)) {
isOK = false;
- if (DBGLEVEL >= 1)
- DbprintfEx(FLAG_NEWLINE, "Error reading sector %2d block %2d", s, blockNo);
break;
};
if (isOK) {
@@ -852,23 +834,18 @@ int e_MifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
}
}
- if (mifare_classic_halt(pcs, cjcuid)) {
- if (DBGLEVEL >= 1)
- DbprintfEx(FLAG_NEWLINE, "Halt error");
- };
+ int res = mifare_classic_halt(pcs, cjcuid);
+ (void)res;
crypto1_deinit(pcs);
-
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-
return (isOK) ? PM3_SUCCESS : PM3_EUNDEF;
}
/* the chk function is a piwi'ed(tm) check that will try all keys for
a particular sector. also no tracing no dbg */
-int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, uint8_t keyCount, uint8_t *datain,
- uint64_t *key) {
- DBGLEVEL = DBG_NONE;
+int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace,
+ uint8_t keyCount, uint8_t *datain, uint64_t *key) {
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
set_tracing(false);
@@ -876,14 +853,16 @@ int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, ui
struct Crypto1State *pcs;
pcs = &mpcs;
- for (int i = 0; i < keyCount; ++i) {
+ int retval = -1;
+
+ for (uint8_t i = 0; i < keyCount; i++) {
/* no need for anticollision. just verify tag is still here */
// if (!iso14443a_fast_select_card(cjuid, 0)) {
if (!iso14443a_select_card(cjuid, &p_card, &cjcuid, true, 0, true)) {
cjSetCursLeft();
DbprintfEx(FLAG_NEWLINE, "%sFATAL%s : E_MF_LOSTTAG", _XRED_, _XWHITE_);
- return -1;
+ break;
}
uint64_t ui64Key = bytes_to_num(datain + i * 6, 6);
@@ -894,15 +873,13 @@ int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace, ui
SpinDelayUs(AUTHENTICATION_TIMEOUT);
continue;
}
- crypto1_deinit(pcs);
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
*key = ui64Key;
- return i;
+ retval = i;
+ break;
}
crypto1_deinit(pcs);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-
- return -1;
+ return retval;
}
void saMifareMakeTag(void) {
@@ -920,7 +897,6 @@ void saMifareMakeTag(void) {
int flags = 0;
for (int blockNum = 0; blockNum < 16 * 4; blockNum++) {
uint8_t mblock[16];
- // cnt = 0;
emlGetMem(mblock, blockNum, 1);
// switch on field and send magic sequence
if (blockNum == 0)
@@ -935,21 +911,15 @@ void saMifareMakeTag(void) {
flags = 0x04 + 0x10;
if (saMifareCSetBlock(0, flags & 0xFE, blockNum, mblock)) {
- //&& cnt <= retry) {
- // cnt++;
cjSetCursFRight();
if (currfline > 53) {
currfline = 54;
}
DbprintfEx(FLAG_NEWLINE, "Block :%02x %sOK%s", blockNum, _XGREEN_, _XWHITE_);
- // DbprintfEx(FLAG_RAWPRINT,"FATAL:E_MF_CHINESECOOK_NORICE");
- // cfail=1;
- // return;
continue;
} else {
cjSetCursLeft();
cjSetCursLeft();
-
DbprintfEx(FLAG_NEWLINE, "`--> %sFAIL%s : CHN_FAIL_BLK_%02x_NOK", _XRED_, _XWHITE_, blockNum);
cjSetCursFRight();
DbprintfEx(FLAG_NEWLINE, "%s>>>>%s STOP AT %02x", _XRED_, _XWHITE_, blockNum);
@@ -957,14 +927,9 @@ void saMifareMakeTag(void) {
break;
}
cjSetCursFRight();
-
DbprintfEx(FLAG_NEWLINE, "%s>>>>>>>> END <<<<<<<<%s", _XYELLOW_, _XWHITE_);
- // break;
- /*if (cfail == 1) {
- DbprintfEx(FLAG_RAWPRINT,"FATAL: E_MF_HARA_KIRI_\r\n");
- break;
- } */
}
+
if (cfail == 0) {
SpinUp(50);
SpinUp(50);
From 35886fab91b5fa6a87a1ef2e81badb6bc5cf2fdc Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 18:30:41 +0200
Subject: [PATCH 076/527] chg: must have a default return value
---
armsrc/mifarecmd.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c
index b98526726..ef1a15864 100644
--- a/armsrc/mifarecmd.c
+++ b/armsrc/mifarecmd.c
@@ -1940,7 +1940,7 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
clear_trace();
set_tracing(true);
- int retval;
+ int retval = PM3_SUCCESS;
if (!iso14443a_select_card(uid, NULL, &cuid, true, 0, true)) {
retval = PM3_ESOFT;
@@ -1952,8 +1952,9 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
uint64_t ui64Key = emlGetKey(sectorNo, keytype);
if (sectorNo == 0) {
if (mifare_classic_auth(pcs, cuid, FirstBlockOfSector(sectorNo), keytype, ui64Key, AUTH_FIRST)) {
+ retval = PM3_ESOFT;
if (DBGLEVEL > DBG_ERROR) Dbprintf("Sector[%2d]. Auth error", sectorNo);
- break;
+ goto out;
}
} else {
if (mifare_classic_auth(pcs, cuid, FirstBlockOfSector(sectorNo), keytype, ui64Key, AUTH_NESTED)) {
@@ -1979,10 +1980,8 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
}
}
- if (mifare_classic_halt(pcs, cuid)) {
- if (DBGLEVEL > DBG_ERROR)
- Dbprintf("Halt error");
- }
+ int res = mifare_classic_halt(pcs, cuid);
+ (void)res;
if (DBGLEVEL >= DBG_INFO) DbpString("Emulator fill sectors finished");
From 15ccb34535b0aa9603124506cf4c4d1ff4dc433b Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 13:28:37 +0200
Subject: [PATCH 077/527] Add -Wconversion in EXTRACFLAGS
---
Makefile.defs | 1 +
client/deps/tinycbor/Makefile | 2 +-
common_arm/Makefile.common | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile.defs b/Makefile.defs
index be504caa9..8ad2e319f 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -63,6 +63,7 @@ endif
EXTRACFLAGS =
EXTRACFLAGS += -Wunused-parameter -Wno-error=unused-parameter
EXTRACFLAGS += -Wsign-compare -Wno-error=sign-compare
+EXTRACFLAGS += -Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion
# unknown to clang or old gcc:
# First we activate Wextra then we explicitly list those we know about
diff --git a/client/deps/tinycbor/Makefile b/client/deps/tinycbor/Makefile
index 4de65aa7f..b50c1584f 100644
--- a/client/deps/tinycbor/Makefile
+++ b/client/deps/tinycbor/Makefile
@@ -1,7 +1,7 @@
MYSRCPATHS =
MYINCLUDES =
# Strange errors on Mingw when compiling with C99
-MYCFLAGS = -Wno-bad-function-cast -Wno-redundant-decls -Wno-incompatible-pointer-types-discards-qualifiers -Wno-discarded-qualifiers -Wno-unknown-warning-option -Wno-maybe-uninitialized
+MYCFLAGS = -Wno-bad-function-cast -Wno-redundant-decls -Wno-incompatible-pointer-types-discards-qualifiers -Wno-discarded-qualifiers -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-conversion
MYDEFS =
MYSRCS = \
cborencoder.c \
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 81f2b0131..8b5836e73 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -61,6 +61,7 @@ EXTRACFLAGS += -Wunused-parameter -Wno-error=unused-parameter
EXTRACFLAGS += -Wswitch-enum -Wno-error=switch-enum
EXTRACFLAGS += -Wsign-compare -Wno-error=sign-compare
EXTRACFLAGS += -Wold-style-definition -Wno-error=old-style-definition
+EXTRACFLAGS += -Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion
# unknown to clang or old gcc:
# First we activate Wextra then we explicitly list those we know about
From c87afd0b7d3881a468a5809aeba7ef7b366c5691 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 13:38:39 +0200
Subject: [PATCH 078/527] trace load: err if offline mode
---
client/src/cmdtrace.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c
index 43d84c3f3..4df4ee0c0 100644
--- a/client/src/cmdtrace.c
+++ b/client/src/cmdtrace.c
@@ -33,7 +33,7 @@ static int usage_trace_list(void) {
PrintAndLogEx(NORMAL, " c - mark CRC bytes");
PrintAndLogEx(NORMAL, " x - show hexdump to convert to pcap(ng) or to import into Wireshark using encapsulation type \"ISO 14443\"");
PrintAndLogEx(NORMAL, " syntax to use: `text2pcap -t \"%%S.\" -l 264 -n `");
- PrintAndLogEx(NORMAL, " <0|1> - use data from Tracebuffer, if not set, try reading data from tag.");
+ PrintAndLogEx(NORMAL, " <0|1> - use data from Tracebuffer, if not set, try to collect a trace from Proxmark3 device.");
PrintAndLogEx(NORMAL, "Supported values:");
PrintAndLogEx(NORMAL, " raw - just show raw data without annotations");
PrintAndLogEx(NORMAL, " 14a - interpret data as iso14443a communications");
@@ -593,6 +593,10 @@ int CmdTraceList(const char *Cmd) {
if (isOnline) {
+ if (!IfPm3Present()) {
+ PrintAndLogEx(FAILED, "You requested a trace upload in offline mode, consider using parameter '1' for working from Tracebuffer");
+ return PM3_EINVARG;
+ }
// reserve some space.
if (g_trace)
free(g_trace);
From b770cfd51c9fea5fb88caa30681c9db19d020f43 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 19:22:17 +0200
Subject: [PATCH 079/527] le24toh is uint32_t
---
client/src/cmdhfmfdes.c | 22 ++++++++++++----------
common/commonutil.c | 2 +-
common/commonutil.h | 2 +-
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index c8bf75424..a39bd85c0 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -1482,8 +1482,8 @@ static int handler_desfire_writedata(mfdes_data_t *data, MFDES_FILE_TYPE_T type)
*/
if (data->fileno > 0x1F) return PM3_EINVARG;
- int datatowrite = le24toh(data->length);
- int offset = le24toh(data->offset);
+ uint32_t datatowrite = le24toh(data->length);
+ uint32_t offset = le24toh(data->offset);
int datasize;
int pos = 0;
int recvlen = 0;
@@ -1496,7 +1496,8 @@ static int handler_desfire_writedata(mfdes_data_t *data, MFDES_FILE_TYPE_T type)
apdu.data = tmp;
if (type == MFDES_RECORD_FILE) apdu.INS = MFDES_WRITE_RECORD;
- while (datatowrite > 0) {
+ while (datatowrite) {
+
if (datatowrite > 52)
datasize = 52;
else
@@ -2319,7 +2320,8 @@ static int CmdHF14ADesReadData(const char *Cmd) {
memcpy(ft.length, filesize, 3);
ft.fileno = _fileno[0];
- int bytestoread = le24toh(filesize);
+ uint32_t bytestoread = le24toh(filesize);
+ bytestoread &= 0xFFFFFF;
if (bytestoread == 0)
bytestoread = 0xFFFFFF;
@@ -2332,8 +2334,8 @@ static int CmdHF14ADesReadData(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Successfully read data from file %d:", ft.fileno);
PrintAndLogEx(NORMAL, "\nOffset | Data | Ascii");
PrintAndLogEx(NORMAL, "----------------------------------------------------------------------------");
- int len = le24toh(ft.length);
- for (int i = 0; i < len; i += 16) {
+ uint32_t len = le24toh(ft.length);
+ for (uint32_t i = 0; i < len; i += 16) {
PrintAndLogEx(NORMAL, "%02d/0x%02X | %s| %s", i, i, sprint_hex(&ft.data[i], len > 16 ? 16 : len), sprint_ascii(&ft.data[i], len > 16 ? 16 : len));
}
} else {
@@ -3246,8 +3248,8 @@ static int CmdHF14ADesDump(const char *Cmd) {
if (res == PM3_SUCCESS) {
PrintAndLogEx(NORMAL, "\nOffset | Data | Ascii");
PrintAndLogEx(NORMAL, "----------------------------------------------------------------------------");
- int len = le24toh(fdata.length);
- for (int n = 0; n < len; n += 16) {
+ uint32_t len = le24toh(fdata.length);
+ for (uint32_t n = 0; n < len; n += 16) {
PrintAndLogEx(NORMAL, "%02d/0x%02X | %s| %s", n, n, sprint_hex(&fdata.data[n], len > 16 ? 16 : len), sprint_ascii(&fdata.data[n], len > 16 ? 16 : len));
}
} else {
@@ -3299,8 +3301,8 @@ static int CmdHF14ADesDump(const char *Cmd) {
if (res == PM3_SUCCESS) {
PrintAndLogEx(NORMAL, "\nOffset | Data | Ascii");
PrintAndLogEx(NORMAL, "----------------------------------------------------------------------------");
- int len = le24toh(fdata.length);
- for (int n = 0; n < len; n += 16) {
+ uint32_t len = le24toh(fdata.length);
+ for (uint32_t n = 0; n < len; n += 16) {
PrintAndLogEx(NORMAL, "%02d/0x%02X | %s| %s", n, n, sprint_hex(&fdata.data[n], len > 16 ? 16 : len), sprint_ascii(&fdata.data[n], len > 16 ? 16 : len));
}
} else {
diff --git a/common/commonutil.c b/common/commonutil.c
index 3ff2b4eb4..f831d744d 100644
--- a/common/commonutil.c
+++ b/common/commonutil.c
@@ -83,7 +83,7 @@ void lsl(uint8_t *data, size_t len) {
data[len - 1] <<= 1;
}
-int32_t le24toh(uint8_t data[3]) {
+uint32_t le24toh(uint8_t data[3]) {
return (data[2] << 16) | (data[1] << 8) | data[0];
}
diff --git a/common/commonutil.h b/common/commonutil.h
index a22486fff..0f3dc0065 100644
--- a/common/commonutil.h
+++ b/common/commonutil.h
@@ -50,7 +50,7 @@ uint64_t bytes_to_num(uint8_t *src, size_t len);
void rol(uint8_t *data, const size_t len);
void lsl(uint8_t *data, size_t len);
-int32_t le24toh(uint8_t data[3]);
+uint32_t le24toh(uint8_t data[3]);
void htole24(uint32_t val, uint8_t data[3]);
#endif
From eb7ef65f22f46c1a270fc332bc19bd8f8e041aa8 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 20 May 2020 19:52:22 +0200
Subject: [PATCH 080/527] chg: 'lf nexwatch clone' - only use 12bytes
---
client/src/cmdlfnexwatch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/cmdlfnexwatch.c b/client/src/cmdlfnexwatch.c
index f8b75594c..fbf2d55eb 100644
--- a/client/src/cmdlfnexwatch.c
+++ b/client/src/cmdlfnexwatch.c
@@ -281,7 +281,7 @@ static int CmdNexWatchClone(const char *Cmd) {
int datalen = 0;
uint8_t magic = 0xBE;
uint32_t cn = 0;
- uint8_t rawhex[16] = {0x56, 0};
+ uint8_t rawhex[12] = {0x56, 0};
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
switch (tolower(param_getchar(Cmd, cmdp))) {
From 86ba6c8330a3847d35bca14f8ea5c35191c847a6 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 14:02:47 +0200
Subject: [PATCH 081/527] Add "make release"
---
Makefile | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/Makefile b/Makefile
index 2ba15fb0c..9f77d3d30 100644
--- a/Makefile
+++ b/Makefile
@@ -236,5 +236,22 @@ endif
# @find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \
# -exec grep -lP '\\t' {} \;
+release: VERSION="v4.$(shell git log --oneline master | wc -l)"
+release:
+ # Preparing a commit for release tagging, to be reverted after tagging.
+ @echo "# - Tag: $(VERSION)"
+ # - Removing -Werror...
+ @find . \( -path "./Makefile.defs" -or -path "./client/Makefile" -or -path "./common_arm/Makefile.common" -or -path "./tools/hitag2crack/*/Makefile" \) -exec sed -i 's/ -Werror//' {} \;
+ @find . \( -path "./client/deps/*.cmake" -or -path "./client/CMakeLists.txt" \) -exec sed -i 's/ -Werror//' {} \;
+ # - Changing banner...
+ @sed -i "s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION)\"/" client/src/proxmark3.c
+ @echo -n "# ";grep "^#define BANNERMSG3" client/src/proxmark3.c
+ # - Committing...
+ @git commit -a -m "Release $(VERSION)"
+ # - Tagging...
+ @git tag -a -m "Release $(VERSION)" $(VERSION)
+ # - Reverting...
+ @git revert --no-edit HEAD
+
# Dummy target to test for GNU make availability
_test:
From ef586c2a41fac3a151eb5e157e30b41dcea3f136 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 15:53:47 +0200
Subject: [PATCH 082/527] version info also for client, still cmake to do
---
armsrc/appmain.c | 5 ++--
armsrc/util.c | 34 ------------------------
armsrc/util.h | 1 -
client/Makefile | 10 +++++--
client/src/cmdhw.c | 9 +++++--
common/commonutil.c | 34 ++++++++++++++++++++++++
common/commonutil.h | 3 +++
{common_arm => common}/default_version.c | 2 +-
include/common.h | 10 +++++++
include/proxmark3_arm.h | 10 +------
tools/mkversion.pl | 2 +-
tools/mkversion.sh | 2 +-
12 files changed, 69 insertions(+), 53 deletions(-)
rename {common_arm => common}/default_version.c (93%)
diff --git a/armsrc/appmain.c b/armsrc/appmain.c
index 40f8c0ad1..a3d5c3d2f 100644
--- a/armsrc/appmain.c
+++ b/armsrc/appmain.c
@@ -244,8 +244,7 @@ void ReadMem(int addr) {
Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x", addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
-/* osimage version information is linked in */
-extern struct version_information version_information;
+/* osimage version information is linked in, cf commonutil.h */
/* bootrom version information is pointed to from _bootphase1_version_pointer */
extern char *_bootphase1_version_pointer, _flash_start, _flash_end, __data_src_start__;
static void SendVersion(void) {
@@ -265,10 +264,12 @@ static void SendVersion(void) {
} else {
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
+ strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1);
}
FormatVersionInformation(temp, sizeof(temp), " os: ", &version_information);
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
+ strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1);
#if defined(__clang__)
strncat(VersionString, " compiled with Clang/LLVM "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1);
diff --git a/armsrc/util.c b/armsrc/util.c
index ccff567eb..443c9e5f4 100644
--- a/armsrc/util.c
+++ b/armsrc/util.c
@@ -289,40 +289,6 @@ int BUTTON_HELD(int ms) {
return BUTTON_ERROR;
}
-/* Similar to FpgaGatherVersion this formats stored version information
- * into a string representation. It takes a pointer to the struct version_information,
- * verifies the magic properties, then stores a formatted string, prefixed by
- * prefix in dst.
- */
-void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information) {
- struct version_information *v = (struct version_information *)version_information;
- dst[0] = 0;
- strncat(dst, prefix, len - 1);
- if (v->magic != VERSION_INFORMATION_MAGIC) {
- strncat(dst, "Missing/Invalid version information\n", len - strlen(dst) - 1);
- return;
- }
- if (v->versionversion != 1) {
- strncat(dst, "Version information not understood\n", len - strlen(dst) - 1);
- return;
- }
- if (!v->present) {
- strncat(dst, "Version information not available\n", len - strlen(dst) - 1);
- return;
- }
-
- strncat(dst, v->gitversion, len - strlen(dst) - 1);
- if (v->clean == 0) {
- strncat(dst, "-unclean", len - strlen(dst) - 1);
- } else if (v->clean == 2) {
- strncat(dst, "-suspect", len - strlen(dst) - 1);
- }
-
- strncat(dst, " ", len - strlen(dst) - 1);
- strncat(dst, v->buildtime, len - strlen(dst) - 1);
- strncat(dst, "\n", len - strlen(dst) - 1);
-}
-
bool data_available(void) {
#ifdef WITH_FPC_USART_HOST
return usb_poll_validate_length() || (usart_rxdata_available() > 0);
diff --git a/armsrc/util.h b/armsrc/util.h
index 06c4e024e..c6523a813 100644
--- a/armsrc/util.h
+++ b/armsrc/util.h
@@ -91,7 +91,6 @@ void SpinUp(uint32_t speed);
int BUTTON_CLICKED(int ms);
int BUTTON_HELD(int ms);
-void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information);
bool data_available(void);
#endif
diff --git a/client/Makefile b/client/Makefile
index ad2f5aa75..59685656b 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -179,7 +179,8 @@ CORESRCS = uart/uart_posix.c \
scandir.c \
crc16.c \
crc32.c \
- comms.c
+ comms.c \
+ version.c
CMDSRCS = crapto1/crapto1.c \
crapto1/crypto1.c \
@@ -308,7 +309,7 @@ CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
BINS = proxmark3
-CLEAN = $(BINS) src/*.moc.cpp src/ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
+CLEAN = $(BINS) src/version.c src/*.moc.cpp src/ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
# transition: cleaning also old path stuff
CLEAN += flasher *.moc.cpp ui/ui_overlays.h
@@ -426,6 +427,11 @@ zlib:
.PHONY: all clean install uninstall tarbin liblua jansson tinycbor reveng hardnested amiibo cliparser whereami mbedtls zlib
+# version.c should be remade on every compilation
+src/version.c: default_version.c
+ $(info [=] GEN $@)
+ $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
+
# easy printing of MAKE VARIABLES
print-%: ; @echo $* = $($*)
diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c
index 3b452b492..45e56ba49 100644
--- a/client/src/cmdhw.c
+++ b/client/src/cmdhw.c
@@ -20,6 +20,7 @@
#include "ui.h"
#include "cmdhw.h"
#include "cmddata.h"
+#include "commonutil.h"
static int CmdHelp(const char *Cmd);
@@ -688,7 +689,9 @@ void pm3_version(bool verbose, bool oneliner) {
if (oneliner) {
// For "proxmark3 -v", simple printf, avoid logging
- printf("Client: RRG/Iceman compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH "\n");
+ char temp[PM3_CMD_DATA_SIZE - 12]; // same limit as for ARM image
+ FormatVersionInformation(temp, sizeof(temp), "Client: ", &version_information);
+ printf("%s compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH "\n", temp);
return;
}
@@ -701,9 +704,11 @@ void pm3_version(bool verbose, bool oneliner) {
SendCommandNG(CMD_VERSION, NULL, 0);
if (WaitForResponseTimeout(CMD_VERSION, &resp, 1000)) {
+ char temp[PM3_CMD_DATA_SIZE - 12]; // same limit as for ARM image
PrintAndLogEx(NORMAL, "\n " _YELLOW_("[ Proxmark3 RFID instrument ]"));
PrintAndLogEx(NORMAL, "\n " _YELLOW_("[ CLIENT ]"));
- PrintAndLogEx(NORMAL, " client: RRG/Iceman"); // TODO version info?
+ FormatVersionInformation(temp, sizeof(temp), " client: ", &version_information);
+ PrintAndLogEx(NORMAL, "%s", temp);
PrintAndLogEx(NORMAL, " compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH);
if (IfPm3Flash() == false && IfPm3Smartcard() == false && IfPm3FpcUsartHost() == false) {
diff --git a/common/commonutil.c b/common/commonutil.c
index f831d744d..14f2d58e5 100644
--- a/common/commonutil.c
+++ b/common/commonutil.c
@@ -8,6 +8,40 @@
// Utility functions used in many places, not specific to any piece of code.
//-----------------------------------------------------------------------------
#include "commonutil.h"
+#include
+
+/* Similar to FpgaGatherVersion this formats stored version information
+ * into a string representation. It takes a pointer to the struct version_information,
+ * verifies the magic properties, then stores a formatted string, prefixed by
+ * prefix in dst.
+ */
+void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_info) {
+ struct version_information *v = (struct version_information *)version_info;
+ dst[0] = 0;
+ strncat(dst, prefix, len - 1);
+ if (v->magic != VERSION_INFORMATION_MAGIC) {
+ strncat(dst, "Missing/Invalid version information", len - strlen(dst) - 1);
+ return;
+ }
+ if (v->versionversion != 1) {
+ strncat(dst, "Version information not understood", len - strlen(dst) - 1);
+ return;
+ }
+ if (!v->present) {
+ strncat(dst, "Version information not available", len - strlen(dst) - 1);
+ return;
+ }
+
+ strncat(dst, v->gitversion, len - strlen(dst) - 1);
+ if (v->clean == 0) {
+ strncat(dst, "-unclean", len - strlen(dst) - 1);
+ } else if (v->clean == 2) {
+ strncat(dst, "-suspect", len - strlen(dst) - 1);
+ }
+
+ strncat(dst, " ", len - strlen(dst) - 1);
+ strncat(dst, v->buildtime, len - strlen(dst) - 1);
+}
/*
ref http://www.csm.ornl.gov/~dunigan/crc.html
diff --git a/common/commonutil.h b/common/commonutil.h
index 0f3dc0065..fdd2ac065 100644
--- a/common/commonutil.h
+++ b/common/commonutil.h
@@ -41,6 +41,9 @@
# define NTIME(n) for (int _index = 0; _index < n; _index++)
#endif
+extern struct version_information version_information;
+void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_info);
+
uint32_t reflect(uint32_t v, int b); // used in crc.c ...
uint8_t reflect8(uint8_t b); // dedicated 8bit reversal
uint16_t reflect16(uint16_t b); // dedicated 16bit reversal
diff --git a/common_arm/default_version.c b/common/default_version.c
similarity index 93%
rename from common_arm/default_version.c
rename to common/default_version.c
index b4b8ae17d..e04c88d2a 100644
--- a/common_arm/default_version.c
+++ b/common/default_version.c
@@ -1,4 +1,4 @@
-#include "proxmark3_arm.h"
+#include "common.h"
/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
const struct version_information __attribute__((section(".version_information"))) version_information = {
VERSION_INFORMATION_MAGIC,
diff --git a/include/common.h b/include/common.h
index e7d6bba90..d52e40f10 100644
--- a/include/common.h
+++ b/include/common.h
@@ -36,6 +36,16 @@
#define PACKED __attribute__((packed))
+#define VERSION_INFORMATION_MAGIC 0x56334d50 // "PM3V"
+struct version_information {
+ int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */
+ char versionversion; /* Must be 1 */
+ char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */
+ char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */
+ char gitversion[50]; /* String with the git revision */
+ char buildtime[30]; /* string with the build time */
+} PACKED;
+
// debug
#define DBG_NONE 0 // no messages
#define DBG_ERROR 1 // errors only
diff --git a/include/proxmark3_arm.h b/include/proxmark3_arm.h
index 3ea80da9d..de3ae9caa 100644
--- a/include/proxmark3_arm.h
+++ b/include/proxmark3_arm.h
@@ -115,15 +115,7 @@
//NVDD goes LOW when USB is attached.
#define USB_ATTACHED() !((AT91C_BASE_PIOA->PIO_PDSR & GPIO_NVDD_ON) == GPIO_NVDD_ON)
-#define VERSION_INFORMATION_MAGIC 0x56334d50 // "PM3V"
-struct version_information {
- int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */
- char versionversion; /* Must be 1 */
- char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */
- char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */
- char gitversion[50]; /* String with the git revision */
- char buildtime[30]; /* string with the build time */
-} PACKED;
+// VERSION_INFORMATION is now in common.h
#define COMMON_AREA_MAGIC 0x43334d50 // "PM3C"
#define COMMON_AREA_COMMAND_NONE 0
diff --git a/tools/mkversion.pl b/tools/mkversion.pl
index 95a794697..eecacbd72 100644
--- a/tools/mkversion.pl
+++ b/tools/mkversion.pl
@@ -64,7 +64,7 @@ $fullgitinfo =~ s/(\s)//g;
$fullgitinfo = substr $fullgitinfo, 0, 49;
print <
Date: Wed, 20 May 2020 18:12:41 +0200
Subject: [PATCH 083/527] Makefile: wrap sh and perl calls
---
Makefile.defs | 2 ++
armsrc/Makefile | 2 +-
bootrom/Makefile | 2 +-
client/Makefile | 2 +-
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 8ad2e319f..d206611d3 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -24,6 +24,8 @@ CROSS ?= arm-none-eabi-
CC = gcc
CXX = g++
LD = g++
+SH = sh
+PERL = perl
PATHSEP=/
PREFIX ?= /usr/local
diff --git a/armsrc/Makefile b/armsrc/Makefile
index 15cfaddfd..bc0fbc74b 100644
--- a/armsrc/Makefile
+++ b/armsrc/Makefile
@@ -155,7 +155,7 @@ showinfo:
# version.c should be remade on every time fullimage.stage1.elf should be remade
version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
$(info [-] GEN $@)
- $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
$(info [-] GEN $@)
diff --git a/bootrom/Makefile b/bootrom/Makefile
index 676bd9a05..f6cf18174 100644
--- a/bootrom/Makefile
+++ b/bootrom/Makefile
@@ -39,7 +39,7 @@ OBJS = $(OBJDIR)/bootrom.s19
# version.c should be remade on every compilation
version.c: default_version.c
$(info [=] GEN $@)
- $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
all: showinfo $(OBJS)
diff --git a/client/Makefile b/client/Makefile
index 59685656b..33810b09b 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -430,7 +430,7 @@ zlib:
# version.c should be remade on every compilation
src/version.c: default_version.c
$(info [=] GEN $@)
- $(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@
# easy printing of MAKE VARIABLES
print-%: ; @echo $* = $($*)
From 88ae955673353fe92f8d1425712fcb1423278477 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 19:07:46 +0200
Subject: [PATCH 084/527] version.c in cmake
---
client/CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 07d2abb40..a56ea5a9a 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -176,8 +176,15 @@ set (TARGET_SOURCES
src/util.c
src/wiegand_formats.c
src/wiegand_formatutils.c
+ ${CMAKE_BINARY_DIR}/version.c
)
+add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/version.c
+ COMMAND sh ${CMAKE_SOURCE_DIR}/../tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version.c || perl ${CMAKE_SOURCE_DIR}/../tools/mkversion.pl > ${CMAKE_BINARY_DIR}/version.c || ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../common/default_version.c ${CMAKE_BINARY_DIR}/version.c
+ DEPENDS ${CMAKE_SOURCE_DIR}/../common/default_version.c
+)
+
set(ADDITIONAL_SRC "")
set(ADDITIONAL_LNK "")
From 7033927176259b15393412fd7d0e4f3bd9bd0c02 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 19:37:05 +0200
Subject: [PATCH 085/527] Add RELEASE_NAME
---
Makefile | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 9f77d3d30..6b0a6cb76 100644
--- a/Makefile
+++ b/Makefile
@@ -170,7 +170,7 @@ tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin
# detect if there were changes in the platform definitions, requiring a clean
cleanifplatformchanged:
-ifeq ($(PLATFORM_CHANGED), true)
+ifeq ($(PLATFORM_CHANGED),true)
$(info [!] Platform definitions changed, cleaning bootrom/armsrc/recovery first...)
$(Q)$(MAKE) --no-print-directory -C bootrom clean
$(Q)$(MAKE) --no-print-directory -C armsrc clean
@@ -239,17 +239,21 @@ endif
release: VERSION="v4.$(shell git log --oneline master | wc -l)"
release:
# Preparing a commit for release tagging, to be reverted after tagging.
- @echo "# - Tag: $(VERSION)"
+ @echo "# - Release Tag: $(VERSION)"
+ifeq ($(RELEASE_NAME),)
+ $(error "!!! missing RELEASE_NAME")
+endif
+ @echo "# - Release Name: $(RELEASE_NAME)"
# - Removing -Werror...
@find . \( -path "./Makefile.defs" -or -path "./client/Makefile" -or -path "./common_arm/Makefile.common" -or -path "./tools/hitag2crack/*/Makefile" \) -exec sed -i 's/ -Werror//' {} \;
@find . \( -path "./client/deps/*.cmake" -or -path "./client/CMakeLists.txt" \) -exec sed -i 's/ -Werror//' {} \;
# - Changing banner...
- @sed -i "s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION)\"/" client/src/proxmark3.c
+ @sed -i "s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION) - $(RELEASE_NAME)\"/" client/src/proxmark3.c
@echo -n "# ";grep "^#define BANNERMSG3" client/src/proxmark3.c
# - Committing...
- @git commit -a -m "Release $(VERSION)"
+ @git commit -a -m "Release $(VERSION) - $(RELEASE_NAME)"
# - Tagging...
- @git tag -a -m "Release $(VERSION)" $(VERSION)
+ @git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
# - Reverting...
@git revert --no-edit HEAD
From 577380ae48c3261d36b79763df80974915248c77 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 19:48:39 +0200
Subject: [PATCH 086/527] color ARM/FPGA version sections
---
armsrc/appmain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/armsrc/appmain.c b/armsrc/appmain.c
index a3d5c3d2f..3793182ce 100644
--- a/armsrc/appmain.c
+++ b/armsrc/appmain.c
@@ -257,7 +257,7 @@ static void SendVersion(void) {
*/
char *bootrom_version = *(char **)&_bootphase1_version_pointer;
- strncat(VersionString, " [ ARM ]\n", sizeof(VersionString) - strlen(VersionString) - 1);
+ strncat(VersionString, " "_YELLOW_("[ ARM ]")"\n", sizeof(VersionString) - strlen(VersionString) - 1);
if (bootrom_version < &_flash_start || bootrom_version >= &_flash_end) {
strcat(VersionString, "bootrom version information appears invalid\n");
@@ -277,7 +277,7 @@ static void SendVersion(void) {
strncat(VersionString, " compiled with GCC "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1);
#endif
- strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1);
+ strncat(VersionString, "\n "_YELLOW_("[ FPGA ]")"\n ", sizeof(VersionString) - strlen(VersionString) - 1);
for (int i = 0; i < g_fpga_bitstream_num; i++) {
strncat(VersionString, g_fpga_version_information[i], sizeof(VersionString) - strlen(VersionString) - 1);
From e2a20631c7e016a3fe86f99aea9942c33423efee Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 20:54:37 +0200
Subject: [PATCH 087/527] remove section version_information for client
---
armsrc/Makefile | 1 -
common/default_version.c | 8 +++++++-
common_arm/Makefile.common | 2 +-
tools/mkversion.pl | 8 +++++++-
tools/mkversion.sh | 8 +++++++-
5 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/armsrc/Makefile b/armsrc/Makefile
index bc0fbc74b..60b23c9f7 100644
--- a/armsrc/Makefile
+++ b/armsrc/Makefile
@@ -20,7 +20,6 @@ endif
#in the next section to remove that particular feature from compilation.
# NO space,TABs after the "\" sign.
APP_CFLAGS = $(PLATFORM_DEFS) \
- -DON_DEVICE \
-fno-strict-aliasing -ffunction-sections -fdata-sections
SRC_LF = lfops.c lfsampling.c pcf7931.c lfdemod.c lfadc.c
diff --git a/common/default_version.c b/common/default_version.c
index e04c88d2a..0f42590e8 100644
--- a/common/default_version.c
+++ b/common/default_version.c
@@ -1,6 +1,12 @@
#include "common.h"
/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
-const struct version_information __attribute__((section(".version_information"))) version_information = {
+#ifndef ON_DEVICE
+#define SECTVERSINFO
+#else
+#define SECTVERSINFO __attribute__((section(".version_information")))
+#endif
+
+const struct version_information SECTVERSINFO version_information = {
VERSION_INFORMATION_MAGIC,
1, /* version 1 */
0, /* version information not present */
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 8b5836e73..e2c3ae3bc 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -90,7 +90,7 @@ ifeq ($(NOERROR),1)
endif
CFLAGS ?= $(DEFCFLAGS)
-CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 $(APP_CFLAGS)
+CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 -DON_DEVICE $(APP_CFLAGS)
LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -Wl,--build-id=none -n
LIBS = -lgcc
diff --git a/tools/mkversion.pl b/tools/mkversion.pl
index eecacbd72..0d8b9de29 100644
--- a/tools/mkversion.pl
+++ b/tools/mkversion.pl
@@ -66,7 +66,13 @@ $fullgitinfo = substr $fullgitinfo, 0, 49;
print <
Date: Wed, 20 May 2020 21:39:49 +0200
Subject: [PATCH 088/527] Remove coffee to prepare release
---
client/src/proxmark3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 07d777a2c..1e2be44ba 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -32,7 +32,7 @@
// Used to enable/disable use of preferences json file
#define USE_PREFERENCE_FILE
-#define BANNERMSG1 " :snowflake: iceman@icesql.net :coffee:"
+#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
#define BANNERMSG3 "pre-release v4.0"
From c956314a99180aac8b20ab02fb84ba9fa7834ae8 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 20 May 2020 21:53:47 +0200
Subject: [PATCH 089/527] fix mistake
---
client/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/Makefile b/client/Makefile
index 33810b09b..79943d8fa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -430,7 +430,7 @@ zlib:
# version.c should be remade on every compilation
src/version.c: default_version.c
$(info [=] GEN $@)
- $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
# easy printing of MAKE VARIABLES
print-%: ; @echo $* = $($*)
From d74ad9d0ea073b033e3e033b8a8110fdfe9909a9 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 09:04:46 +0200
Subject: [PATCH 090/527] changelog updates
---
CHANGELOG.md | 122 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 115 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d67785eb2..90c6dccb3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,13 +3,120 @@ 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]
+
+## [ice coffee.4.][2020-05-21]
+ - Updated documentation (@doegox, @iceman1001)
+ - Change `pm3test.sh` - more regression tests to (@doegox, @iceman1001)
+ - Change `hf 15 dump` - now supports basic json format (@iceman1001)
+ - Change Test and fix many `-Wxxxxxx` warnings [compiler trials] (@doegox)
+ - Fix COVERITY warnings [compiler trials] (@doegox, @iceman1001)
+ - Fix CPPCHECKER warnings [compiler trials] (@doegox, @iceman1001)
+ - Fix CLANG warnings [compiler trials] (@doegox)
+ - Change, stricter warnings [compiler trials] (@doegox)
+ - Change, remove section version_information for client (@doegox)
+ - Change, Add RELEASE_NAME (@doegox)
+ - Change, version info also for client (@doegox)
+ - Added `make release` (@doegox)
+ - Change `trace load` - err if offline mode (@doegox)
+ - Fix `standalone mode matty_run` eloadcard (@iceman1001)
+ - Added, HF 15 traces (@FlUxIUS)
+ - Fix, follow naming conventions [android] (@dxl)
+ - Change, work directory supported [android] (@dxl)
+ - Added `lf fdx demod` - decoding of Bio-Thermo lf tag. Thanks to Rosco! (@iceman1001)
+ - Fix, 32-bit time_t compilation error on [WIN64] (@grspy)
+ - Change, LogTrace error msg (@doegox)
+ - Change, remove inline [compiler trials] (@iceman1001)
+ - Change, adding execute/home/current working directory functions to lua (<@iceman1001)
+ - Change, fix max duration in LogTrace (@doegox)
+ - Change, first attempt for trace log header (@iceman1001)
+ - Change, pm3.sh, attempt to detect BT dongle when udevadm is not available (@doegox)
+ - Change, pm3.sh, test access to /dev/ttyXXX files as prerequisite for [linux] (@doegox)
+ - iclass bf: avoid slowdown (@doegox)
+ - Change, pm3tests.sh, shellcheck (@doegox)
+ - Change, pm3.sh, shellcheck (@doegox)
+ - Change, pm3.sh, err msgs on stderr (@doegox)
+ - Change, pm3.sh, textual and --list with no device, exit 1 (@doegox)
+ - Change, pm3.sh, without udev: change detection routine (@doegox)
+ - Change, pm3.sh, alternative if udevadm is not available [termux] (@doegox)
+ - Change `makefiles` - allow to skip pthread [termux] (@doegox)
+ - Change `script run test_t55x7` - enabled param to swap modulation to test (@iceman1001)
+ - Add mf_nonce_brute from https://github.com/@iceman1001/mf_nonce_brute and merge to pm3 Makefile (@doegox)
+ - Change `lf indala demod` - more lenient size check (@iceman1001)
+ - Change clarify BUTTON macro usages (@doegox)
+ - Change fix REV macros & hitagS (@doegox)
+ - Change, `hf iclass loclass` -removed printvar function (@iceman1001)
+ - Change, clock can be negative (@iceman1001)
+ - Change `data tune` (@doegox)
+ - fancy timers (@doegox)
+ - Change, copied from pm3 repo (@iceman1001)
+ - Change psk demodualtion, keep starting samples to easily find the zero init bit (@iceman1001)
+ - Change use machine/endian.h with osx (Jamie Fiedler)
+ - Fix 2 issues in proxendian.h (@doegox)
+ - Fix issue #729. Avoid stalling on non-rdv4 when polling for FeliCa without card in proximity (@doegox)
+ - Change `lf nexwatch demod` - lenient demod sizes (@iceman1001)
+ - Change `lf nexwath sim/clone` - now supports 88bit format direct. (@iceman1001)
+ - Rewrited `standalone mode lf_em4100rwc `, added card bruteforce mode. (Dmitriy Loginoov)
+ - Change `data load` - color (@iceman1001)
+ - Change appveyor verbose (@doegox)
+ - Change `lf nexwatch demod` - now detects type, and show parity /chksum (@iceman1001)
+ - Change `lfsampling` - interruptible only when logging not yet triggered (@doegox)
+ - Change `lf keri demod - more leanient when it comes to bits (@iceman1001)
+ - fix, proper filtering of RL markers (@doegox)
+ - Change, clean deps [compiler trials] (@doegox)
+ - Change, remove c99 restrictions [compiler trials] (@doegox)
+ - Added tracelog file for hf mfu sniff or a ntag (@iceman1001)
+ - Change `trace list` - different alloc (@iceman1001)
+ - Change, convert OLD -> MIX (@iceman1001)
+ - Change `trace list` - adjust messages (@iceman1001)
+ - Fix a mem corruption in `trace load/list` (@doegox)
+ - Change, rework banners (@doegox)
+ - Change, Let's see if the prompt suffixed spaces are still needed.(@doegox)
+ - Fix colored readline prompt bug (@doegox)
+ - Change, simpler ul_print_type (@doegox)
+ - Fix cmake for reveng [compiler trials] (@doegox)
+ - Change, hook reveng outputs to pm3 machinery, add regression test (@doegox)
+ - Change, cmake android: add backslashes for host compatibility [compiler trials](@doegox)
+ - Change, Translation some comments from Chinese to English. [android] (@dxl)
+ - Change, cmake android: use common cmake files for deps [android] (@doegox)
+ - Fix, proper way to fix reveng getopt bug(@doegox)
+ - Change, cmake deps: add prefix pm3rrg_rdv4_ [compiler trials] (@doegox)
+ - Change, cmake deps: add -fPIC so they can be integrated in a pm3 shared lib [compiler trials] (@doegox)
+ - Change, platform adaptation [android] (@dxl)
+ - Change, don't mix ifdef and defined [android] (@dxl)
+ - fix `trace list`- too short array for explanation (@iceman1001)
+ - Change, check for sim module fw file (@iceman1001)
+ - Change, rpi aling warning [compiler trials] (@iceman1001)
+ - Change, more LF demodulation tests (@iceman1001)
+ - Change, update whereami and avoid compiling unnneded troublesome parts [compiler trials] (@doegox)
+ - Change, rework C includes in C++ [compiler trials] (@doegox)
+ - Change, leanient parsing of tcp:/bt:/socket: vars (@iceman1001)
+ - Change, add bluetooth group to `make accessrights` (@iceman1001)
+ - Change, `Makefile` - fix PKG_CONFIG_ENV (@uli)
+ - Change, `f sim` - now only fills until bigbuffer is full (@iceman1001)
+ - Change, `hf mf hardnested` - don't drop field when in test mode (@doegox)
+ - Change, `lf sim` - better to return err on faulty offset, thanks @iceman (@doegox)
+ - Change, `lf sim` - fix offset of last packet (@doegox)
+ - Change, `client Makefile` - make sure to rebuild deps when needed [compiler trials](@doegox)
+ - Change, silent err if dbus absent [linux] (@doegox)
+ - Change, `pm3.sh` - for direct bt devices (@doegox)
+ - Change, `pm3.sh` - moved WSL/PS3.x bt native to be tested first. Since call to Win32_serialport crashes it. (@iceman1001)
+ - Change, `pm3.sh` - Bt dongle, bt direct listing of serial ports on WSL and PS3.x, now using powershell.exe since wmic is deprecated (@iceman1001)
+ - Change, remove libsndfile (@doegox)
+ - Change, enforce PACKED structs [compiler trials] (@iceman1001)
+ - Change, adjust number of threads according to cpu (@iceman1001)
+ - Change, `hitag2crack` compile flags(@doegox)
+ - Change, msdsal fix bug after var de-shadowing (@doegox)
+ - Change, lighter msg for loading prefs, json will anyway always tell the filename (@doegox)
+ - Change, make sure colors and emoji are disabled when not on TTY (@doegox)
+ - Added `pref` command. PM3 client now support user preferences saved to a json file. (@mwalker33)
+ - Added native support for Bluetooth in client [linux] (@doegox)
- Added `LF_EM4100RSWB` (based on `LF_EM4100RWC`) standalone mode to read/sim/clone/brute EM4100 cards (@Monster1024)
- Added `HF_MSDSAL` standalone mode which read and emulate Visa EMV cards (@Netxing)
- - Added Mifare Ultralight tear off experiment (@cintainfinita and @fukmar)
+ - Added `hf mfu tear` - Mifare Ultralight tear off experiment (@cintainfinitam, @fukmar)
- Added Mifare Desfire Read/Write/Create files/records/values functionality and several fixes to `hf mfdes` (@bkerler)
- Added CreateStdFile command to Mifare `hf mfdes` (@bkerler)
- Rework des/3des/3k3des/aes auth. Port to mbedtls crypto library on device (@bkerler)
- - Port 'hf mfdes' Authentification to CommandNG structure, fix auth session key (@bkerler)
+ - Port `hf mfdes` Authentification to CommandNG structure, fix auth session key (@bkerler)
- Updates `hf mfdes` functions, improved logging and added new commands (@bkerler)
- Updated 'legic.lua' and 'legic_clone.lua' script - works with current command set (@Pizza_4u)
- Rewrote `hf mfdes` functions and added apdu debugging (@bkerler)
@@ -18,10 +125,11 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Improved `hf 14a info` - card detection handling (@bkerler)
- Updated helptext layout in all luascripts (@iceman1001)
- Change `hf mfdes info` - output and logging (@bkerler)
- - Updated texts in legic commands (@ikarus23)
+ - Updated texts in `hf legic` commands (@ikarus23)
- Fix timing bug inside 40x5 (@mwalker33)
- Refactored all Hitag2 attacks (@doegox)
- Added two new Hitag2 attacks (@doegox)
+ - Change `hf iclass decrypt` - limit amount of data to read if wrong app limit (@iceman1001)
- Change `hf search` - now continue to search in case of dual tech cards (@iceman1001) Thanks to @ikarus23 for the suggestion!
- Added `hf topas info` - old reader command, now also prints NDEF (@iceman1001)
- Change `hf topaz reader` - now only prints lighter info, like UID. (@iceman1001)
@@ -40,14 +148,14 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Change - NDEF supports more signatures now (@iceman1001)
- OSX Makefile now supports `make style` and `make checks` (@Pizza_4u)
- Added `HF_LEGIC` standalone mode to read and simulate a Legic prime tag (@Pizza_4u)
- - Added keri MS decode/encode and update 'lf keri clone' to support MS fc/cid cloning. (@mwalker33)
- - Fix 'hf mfdes enum' - now actually manages to enumerate files under all AID's. :smiley: (@iceman1001)
- - Fix 'hf mfdes info' - now detects DESFire light and work properly Wrapped commands :+1: (@iceman1001)
+ - Added keri MS decode/encode and update `lf keri clone` to support MS fc/cid cloning. (@mwalker33)
+ - Fix `hf mfdes enum` - now actually manages to enumerate files under all AID's. :smiley: (@iceman1001)
+ - Fix `hf mfdes info` - now detects DESFire light and work properly Wrapped commands :+1: (@iceman1001)
- :smiling_imp: support (@doegox)
- Additional colour changes as recommended by @iceman (@dunderhay)
- Change type colour for `hf 14a` card types (@dunderhay)
- Add colour to `hf mfdes` command (@dunderhay)
- - Add 'HINTS' command. Will turn off / on hint messages. Default mode is OFF. (@iceman1001)
+ - Add `HINTS` command. Will turn off / on hint messages. Default mode is OFF. (@iceman1001)
- Add colour to `hf 14a` and `hf mfu` commands (@dunderhay)
- Add colour to `lf hid` commands (@dunderhay)
- Change `script run hf_bruteforce -s start_id -e end_id -t timeout -x mifare_card_type` - The hf_bruteforce card script now requires Mifare type (mfc or mfu) (@dunderhay)
From a5aeadc339421c6bf5e5d18fe8b68ac83842980c Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 09:23:32 +0200
Subject: [PATCH 091/527] Release v4.9222 - Ice Coffee :coffee:
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
19 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index d206611d3..477743d69 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index a56ea5a9a..ce58a4449 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 79943d8fa..260f72751 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -Werror -O3
+CXXFLAGS ?= -Wall -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index 34780f597..fbf2a6f74 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index b16451c07..69b639a84 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 9efff1445..612265de0 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index a95ff0baf..1a55b7fa5 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 679147124..94c184906 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 63e706889..93a646e0d 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index d7e3cfd8a..1040730f1 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index 5a6abda25..c74618149 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index d2d6a5b2a..721873066 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 645cbc88d..563508633 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 1e2be44ba..b1aca3534 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "pre-release v4.0"
+#define BANNERMSG3 "Release v4.9222 - Ice Coffee :coffee:"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index e2c3ae3bc..8f2a90b3b 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 4794d6ec4..318034f51 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 318b5db78..1e157eef6 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index b560577bd..30083c56d 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 9d19b63ee..8e2b38f82 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 521a76d3c2a5e68a063ab514972846e182701be1 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 09:24:38 +0200
Subject: [PATCH 092/527] Revert "Release v4.9222 - Ice Coffee :coffee:"
This reverts commit a5aeadc339421c6bf5e5d18fe8b68ac83842980c.
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
19 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 477743d69..d206611d3 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index ce58a4449..a56ea5a9a 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 260f72751..79943d8fa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -O3
+CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index fbf2a6f74..34780f597 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index 69b639a84..b16451c07 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 612265de0..9efff1445 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index 1a55b7fa5..a95ff0baf 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 94c184906..679147124 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 93a646e0d..63e706889 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index 1040730f1..d7e3cfd8a 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index c74618149..5a6abda25 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index 721873066..d2d6a5b2a 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 563508633..645cbc88d 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index b1aca3534..1e2be44ba 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "Release v4.9222 - Ice Coffee :coffee:"
+#define BANNERMSG3 "pre-release v4.0"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 8f2a90b3b..e2c3ae3bc 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 318034f51..4794d6ec4 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 1e157eef6..318b5db78 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index 30083c56d..b560577bd 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 8e2b38f82..9d19b63ee 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 9cec93fd5477a5f1513d9c805ae885a017e88813 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 09:25:32 +0200
Subject: [PATCH 093/527] Release v4.9224 - Ice Coffee :coffee:
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
19 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index d206611d3..477743d69 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index a56ea5a9a..ce58a4449 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 79943d8fa..260f72751 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -Werror -O3
+CXXFLAGS ?= -Wall -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index 34780f597..fbf2a6f74 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index b16451c07..69b639a84 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 9efff1445..612265de0 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index a95ff0baf..1a55b7fa5 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 679147124..94c184906 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 63e706889..93a646e0d 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index d7e3cfd8a..1040730f1 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index 5a6abda25..c74618149 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index d2d6a5b2a..721873066 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 645cbc88d..563508633 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 1e2be44ba..806213d94 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "pre-release v4.0"
+#define BANNERMSG3 "Release v4.9224 - Ice Coffee :coffee:"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index e2c3ae3bc..8f2a90b3b 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 4794d6ec4..318034f51 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 318b5db78..1e157eef6 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index b560577bd..30083c56d 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 9d19b63ee..8e2b38f82 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 3e389c6e075861e2e712bf202527b7b3a62881e6 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 09:25:32 +0200
Subject: [PATCH 094/527] Revert "Release v4.9224 - Ice Coffee :coffee:"
This reverts commit 9cec93fd5477a5f1513d9c805ae885a017e88813.
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
19 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 477743d69..d206611d3 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index ce58a4449..a56ea5a9a 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 260f72751..79943d8fa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -O3
+CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index fbf2a6f74..34780f597 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index 69b639a84..b16451c07 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 612265de0..9efff1445 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index 1a55b7fa5..a95ff0baf 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 94c184906..679147124 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 93a646e0d..63e706889 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index 1040730f1..d7e3cfd8a 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index c74618149..5a6abda25 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index 721873066..d2d6a5b2a 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 563508633..645cbc88d 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 806213d94..1e2be44ba 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "Release v4.9224 - Ice Coffee :coffee:"
+#define BANNERMSG3 "pre-release v4.0"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 8f2a90b3b..e2c3ae3bc 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 318034f51..4794d6ec4 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 1e157eef6..318b5db78 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index 30083c56d..b560577bd 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 8e2b38f82..9d19b63ee 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 53cb36447f0973242314ecd8592a5b172a6ceac0 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 11:05:09 +0200
Subject: [PATCH 095/527] make release: make sure it's executed from a clean
master
---
Makefile | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 6b0a6cb76..71d61f091 100644
--- a/Makefile
+++ b/Makefile
@@ -238,11 +238,17 @@ endif
release: VERSION="v4.$(shell git log --oneline master | wc -l)"
release:
+ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
+ $(error "!!! you are not on master branch, aborting")
+endif
+ifeq ($(shell git describe --dirty --always|grep -o dirty),dirty)
+ $(error "!!! you have pending changes, aborting")
+endif
+ifeq ($(RELEASE_NAME),)
+ $(error "!!! missing RELEASE_NAME, aborting")
+endif
# Preparing a commit for release tagging, to be reverted after tagging.
@echo "# - Release Tag: $(VERSION)"
-ifeq ($(RELEASE_NAME),)
- $(error "!!! missing RELEASE_NAME")
-endif
@echo "# - Release Name: $(RELEASE_NAME)"
# - Removing -Werror...
@find . \( -path "./Makefile.defs" -or -path "./client/Makefile" -or -path "./common_arm/Makefile.common" -or -path "./tools/hitag2crack/*/Makefile" \) -exec sed -i 's/ -Werror//' {} \;
From 4382f8c9bee8c89ae1d14b558b10e8695428ea85 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 11:50:03 +0200
Subject: [PATCH 096/527] mkversion: add --undecided
---
tools/mkversion.pl | 7 ++++---
tools/mkversion.sh | 10 ++++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/tools/mkversion.pl b/tools/mkversion.pl
index 0d8b9de29..ea3b9940a 100644
--- a/tools/mkversion.pl
+++ b/tools/mkversion.pl
@@ -18,7 +18,7 @@ my $fullgitinfo = 'RRG/Iceman';
my $ctime;
# GIT status 0 = dirty, 1 = clean , 2 = undecided
my $clean = 2;
-
+my $undecided = (defined $ARGV[0]) && ($ARGV[0] =~ '--undecided');
# Do we have acces to git command?
#######
# solves some bug on macos i.e:
@@ -37,8 +37,9 @@ if ( defined($commandGIT) ) {
# 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`;
- $clean = $gitversion =~ '-dirty' ? 0 : 1;
-
+ if (not $undecided) {
+ $clean = $gitversion =~ '-dirty' ? 0 : 1;
+ }
if ( defined($gitbranch) and defined($gitversion) ) {
$fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
diff --git a/tools/mkversion.sh b/tools/mkversion.sh
index cc713d635..850ef2101 100755
--- a/tools/mkversion.sh
+++ b/tools/mkversion.sh
@@ -21,10 +21,12 @@ if [ "$commandGIT" != "" ]; then
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
gitversion=$(git describe --dirty --always)
gitbranch=$(git rev-parse --abbrev-ref HEAD)
- if [ "$gitversion" != "${gitversion%-dirty}" ]; then
- clean=0
- else
- clean=1
+ if [ "$1" != "--undecided" ]; then
+ if [ "$gitversion" != "${gitversion%-dirty}" ]; then
+ clean=0
+ else
+ clean=1
+ fi
fi
if [ "$gitbranch" != "" ] && [ "$gitversion" != "" ]; then
fullgitinfo="${fullgitinfo}/${gitbranch}/${gitversion}"
From 7848d751c515accec05dc3b4cdd1ab358b37f1d7 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 12:05:15 +0200
Subject: [PATCH 097/527] make release: hardcode default version
---
Makefile | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 71d61f091..8f92c4152 100644
--- a/Makefile
+++ b/Makefile
@@ -256,11 +256,19 @@ endif
# - Changing banner...
@sed -i "s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION) - $(RELEASE_NAME)\"/" client/src/proxmark3.c
@echo -n "# ";grep "^#define BANNERMSG3" client/src/proxmark3.c
- # - Committing...
+ # - Committing temporarily...
@git commit -a -m "Release $(VERSION) - $(RELEASE_NAME)"
- # - Tagging...
+ # - Tagging temporarily...
@git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
- # - Reverting...
+ # - Changing default version information based on new tag
+ @$(SH) tools/mkversion.sh --undecided > common/default_version.c.tmp && $(MV) common/default_version.c.tmp common/default_version.c
+ # - Deleting tag...
+ @git tag -d $(VERSION)
+ # - Amending commit...
+ @git commit -a --amend -m "Release $(VERSION) - $(RELEASE_NAME)"
+ # - Tagging again...
+ @git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
+ # - Reverting tagged commit...
@git revert --no-edit HEAD
# Dummy target to test for GNU make availability
From b79ccc12ae29ed1d4a14d9f1190bb022381c7eae Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 12:24:54 +0200
Subject: [PATCH 098/527] make release: document next step
---
Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile
index 8f92c4152..c681320ba 100644
--- a/Makefile
+++ b/Makefile
@@ -270,6 +270,8 @@ endif
@git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
# - Reverting tagged commit...
@git revert --no-edit HEAD
+ @echo "==================================================================="
+ @echo "Done! You can now execute 'git push --follow-tags'"
# Dummy target to test for GNU make availability
_test:
From db2e97c8601686e200fb71fa113962aff031add7 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 12:51:35 +0200
Subject: [PATCH 099/527] Release v4.9230 - Ice Coffee :coffee:
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common/default_version.c | 11 ++++++-----
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
20 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index d206611d3..477743d69 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index a56ea5a9a..ce58a4449 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 79943d8fa..260f72751 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -Werror -O3
+CXXFLAGS ?= -Wall -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index 34780f597..fbf2a6f74 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index b16451c07..69b639a84 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 9efff1445..612265de0 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index a95ff0baf..1a55b7fa5 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 679147124..94c184906 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 63e706889..93a646e0d 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index d7e3cfd8a..1040730f1 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index 5a6abda25..c74618149 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index d2d6a5b2a..721873066 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 645cbc88d..563508633 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 1e2be44ba..e21b04306 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "pre-release v4.0"
+#define BANNERMSG3 "Release v4.9230 - Ice Coffee :coffee:"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common/default_version.c b/common/default_version.c
index 0f42590e8..c89691759 100644
--- a/common/default_version.c
+++ b/common/default_version.c
@@ -1,5 +1,5 @@
#include "common.h"
-/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
+/* Generated file, do not edit */
#ifndef ON_DEVICE
#define SECTVERSINFO
#else
@@ -8,8 +8,9 @@
const struct version_information SECTVERSINFO version_information = {
VERSION_INFORMATION_MAGIC,
- 1, /* version 1 */
- 0, /* version information not present */
- 2, /* cleanliness couldn't be determined */
- /* Remaining fields: zero */
+ 1,
+ 1,
+ 2,
+ "RRG/Iceman/master/v4.9230",
+ "2020-05-21 12:51:35",
};
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index e2c3ae3bc..8f2a90b3b 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 4794d6ec4..318034f51 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 318b5db78..1e157eef6 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index b560577bd..30083c56d 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 9d19b63ee..8e2b38f82 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From bf5c054414178499731bf35c2da59b83544ca560 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 12:51:35 +0200
Subject: [PATCH 100/527] Revert "Release v4.9230 - Ice Coffee :coffee:"
This reverts commit db2e97c8601686e200fb71fa113962aff031add7.
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common/default_version.c | 11 +++++------
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
20 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 477743d69..d206611d3 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index ce58a4449..a56ea5a9a 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 260f72751..79943d8fa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -O3
+CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index fbf2a6f74..34780f597 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index 69b639a84..b16451c07 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 612265de0..9efff1445 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index 1a55b7fa5..a95ff0baf 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 94c184906..679147124 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 93a646e0d..63e706889 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index 1040730f1..d7e3cfd8a 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index c74618149..5a6abda25 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index 721873066..d2d6a5b2a 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 563508633..645cbc88d 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index e21b04306..1e2be44ba 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "Release v4.9230 - Ice Coffee :coffee:"
+#define BANNERMSG3 "pre-release v4.0"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common/default_version.c b/common/default_version.c
index c89691759..0f42590e8 100644
--- a/common/default_version.c
+++ b/common/default_version.c
@@ -1,5 +1,5 @@
#include "common.h"
-/* Generated file, do not edit */
+/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
#ifndef ON_DEVICE
#define SECTVERSINFO
#else
@@ -8,9 +8,8 @@
const struct version_information SECTVERSINFO version_information = {
VERSION_INFORMATION_MAGIC,
- 1,
- 1,
- 2,
- "RRG/Iceman/master/v4.9230",
- "2020-05-21 12:51:35",
+ 1, /* version 1 */
+ 0, /* version information not present */
+ 2, /* cleanliness couldn't be determined */
+ /* Remaining fields: zero */
};
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index 8f2a90b3b..e2c3ae3bc 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 318034f51..4794d6ec4 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 1e157eef6..318b5db78 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index 30083c56d..b560577bd 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 8e2b38f82..9d19b63ee 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 321080de71693788700a10adc05fee122963c646 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 13:00:56 +0200
Subject: [PATCH 101/527] make release doc: push latest tag
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c681320ba..63ca7bf53 100644
--- a/Makefile
+++ b/Makefile
@@ -271,7 +271,7 @@ endif
# - Reverting tagged commit...
@git revert --no-edit HEAD
@echo "==================================================================="
- @echo "Done! You can now execute 'git push --follow-tags'"
+ @echo "Done! You can now execute 'git push origin $(VERSION)'"
# Dummy target to test for GNU make availability
_test:
From 8e12285f665b0fdc3e2af61dc6023b4cf468732b Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 19:28:42 +0200
Subject: [PATCH 102/527] introduce CROSS_*FLAGS for cross-compilation
---
armsrc/Makefile | 6 ++----
bootrom/Makefile | 2 +-
common_arm/Makefile.common | 16 ++++++++--------
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/armsrc/Makefile b/armsrc/Makefile
index 60b23c9f7..18d36a1b7 100644
--- a/armsrc/Makefile
+++ b/armsrc/Makefile
@@ -132,8 +132,6 @@ VERSIONSRC = version.c \
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
include ../common_arm/Makefile.common
-COMMON_FLAGS = -Os
-
INSTALLFW = $(OBJDIR)/fullimage.elf
ifneq (,$(FWTAG))
INSTALLFWTAG = $(notdir $(INSTALLFW:%.elf=%-$(FWTAG).elf))
@@ -178,7 +176,7 @@ $(FPGA_COMPRESSOR):
$(OBJDIR)/fullimage.stage1.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
$(info [=] LD $@)
- $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
+ $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
$(OBJDIR)/fullimage.nodata.bin: $(OBJDIR)/fullimage.stage1.elf
$(info [-] GEN $@)
@@ -206,7 +204,7 @@ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z
$(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o
$(info [=] LD $@)
- $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^
+ $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^
tarbin: $(OBJS)
$(info TAR $@)
diff --git a/bootrom/Makefile b/bootrom/Makefile
index f6cf18174..68597aa22 100644
--- a/bootrom/Makefile
+++ b/bootrom/Makefile
@@ -52,7 +52,7 @@ tarbin: $(OBJS)
$(OBJDIR)/bootrom.elf: $(VERSIONOBJ) $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)
$(info [=] LD $@)
- $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript-flash,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
+ $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript-flash,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
clean:
$(Q)$(RM) $(OBJDIR)$(PATHSEP)*.o
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index e2c3ae3bc..c8dceead5 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -89,10 +89,10 @@ ifeq ($(NOERROR),1)
DEFCFLAGS += -Wno-error
endif
-CFLAGS ?= $(DEFCFLAGS)
-CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 -DON_DEVICE $(APP_CFLAGS)
+CROSS_CFLAGS ?= $(DEFCFLAGS)
+CROSS_CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 -DON_DEVICE $(APP_CFLAGS)
-LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -Wl,--build-id=none -n
+CROSS_LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -Wl,--build-id=none -n
LIBS = -lgcc
# Flags to generate temporary dependency files
@@ -107,21 +107,21 @@ VERSIONOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(VERSIONSRC)))
$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<)
- $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -mthumb -o $@ $<
+ $(Q)$(CC) $(CROSS_CFLAGS) $(DEPFLAGS) -mthumb -o $@ $<
$(Q)$(POSTCOMPILE)
$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<)
- $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -o $@ $<
+ $(Q)$(CC) $(CROSS_CFLAGS) $(DEPFLAGS) -o $@ $<
$(Q)$(POSTCOMPILE)
$(ASMOBJ): $(OBJDIR)/%.o: %.s
$(info [-] CC $<)
- $(Q)$(CC) $(CFLAGS) -o $@ $<
+ $(Q)$(CC) $(CROSS_CFLAGS) -o $@ $<
$(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
$(info [-] CC $<)
- $(Q)$(CC) $(CFLAGS) -mthumb -o $@ $<
+ $(Q)$(CC) $(CROSS_CFLAGS) -mthumb -o $@ $<
# This objcopy call translates physical flash addresses to logical addresses
# without touching start address or RAM addresses (.bss and .data sections)
@@ -135,7 +135,7 @@ $(OBJDIR)/%.s19: $(OBJDIR)/%.elf
$(Q)$(OBJCOPY) -Osrec --srec-forceS3 --strip-debug $(OBJCOPY_TRANSLATIONS) $^ $@
# easy printing of MAKE VARIABLES
-print-%: ; @echo $* = $($*)
+print-%: ; @echo $* = $($*)
# Automatic dependency generation
DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
From 4092effe93b3f3e084389cd1d1316764d1981aa1 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 19:38:20 +0200
Subject: [PATCH 103/527] Document CROSS_*FLAGS
---
doc/md/Development/Maintainers.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 85fcf8963..2a49343fd 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -49,7 +49,9 @@ and it will be added along the other firmware as:
For verbose usage and see the actual commands being executed, add `V=1`.
-`CFLAGS` and `LDFLAGS` can be overriden by environment variables.
+`CFLAGS` and `LDFLAGS` can be overriden by environment variables for client-side components.
+
+`CROSS_CFLAGS` and `CROSS_LDFLAGS` can be overriden by environment variables for ARM-side components.
Default compiler is gcc but you can use clang for the non-ARM parts with e.g. `make client CC=clang CXX=clang++ LD=clang++`.
From c07a8aeba374f651a9c19e111ca282f47d874cb7 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 20:15:46 +0200
Subject: [PATCH 104/527] textual
---
Makefile.platform.sample | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.platform.sample b/Makefile.platform.sample
index 8d587e3b7..8a31a0e9c 100644
--- a/Makefile.platform.sample
+++ b/Makefile.platform.sample
@@ -2,7 +2,7 @@
# Run 'make PLATFORM=' to get an exhaustive list of possible parameters for this file.
PLATFORM=PM3RDV4
+#PLATFORM=PM3OTHER
# If you want more than one PLATFORM_EXTRAS option, separate them by spaces:
#PLATFORM_EXTRAS=BTADDON
-#STANDALONE=LF_SAMYRUN
-STANDALONE=LF_ICEHID
+#STANDALONE=HF_MSDSAL
From a19ba257af631b770ac6fb0989b2984eac4ac7c9 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 21:45:54 +0200
Subject: [PATCH 105/527] fix: #746 - ProxSpace 64b seem to report both _WIN32
and _WIN64
---
tools/mf_nonce_brute/mf_nonce_brute.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/mf_nonce_brute/mf_nonce_brute.c b/tools/mf_nonce_brute/mf_nonce_brute.c
index 3bd2a6f31..7edcf4824 100644
--- a/tools/mf_nonce_brute/mf_nonce_brute.c
+++ b/tools/mf_nonce_brute/mf_nonce_brute.c
@@ -1,7 +1,9 @@
#define __STDC_FORMAT_MACROS
-#if defined(_WIN32)
-# define _USE_32BIT_TIME_T 1
+#if !defined(_WIN64)
+ #if defined(_WIN32) || defined(__WIN32__)
+ # define _USE_32BIT_TIME_T 1
+ #endif
#endif
#include
@@ -56,7 +58,7 @@ int global_counter = 0;
int global_fin_flag = 0;
int global_found = 0;
int global_found_candidate = 0;
-size_t thread_count = 4;
+size_t thread_count = 2;
static uint16_t parity_from_err(uint32_t data, uint16_t par_err) {
@@ -350,7 +352,7 @@ int main(int argc, char *argv[]) {
//calc (parity XOR corresponding nonce bit encoded with the same keystream bit)
uint16_t xored = xored_bits(nt_par, nt_enc, ar_par, ar_enc, at_par, at_enc);
-#ifndef __WIN32
+#if !defined(_WIN32) || !defined(__WIN32__)
thread_count = sysconf(_SC_NPROCESSORS_CONF);
if (thread_count < 2)
thread_count = 2;
From 833bc4d9a3f2c1dcef4a72393663f75e0ba0fbd1 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 21:55:15 +0200
Subject: [PATCH 106/527] Release v4.9237 - Ice Coffee :coffee:
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common/default_version.c | 11 ++++++-----
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
20 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index d206611d3..477743d69 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index a56ea5a9a..ce58a4449 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 79943d8fa..260f72751 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -Werror -O3
+CXXFLAGS ?= -Wall -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index 34780f597..fbf2a6f74 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index b16451c07..69b639a84 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 9efff1445..612265de0 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index a95ff0baf..1a55b7fa5 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 679147124..94c184906 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 63e706889..93a646e0d 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index d7e3cfd8a..1040730f1 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index 5a6abda25..c74618149 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index d2d6a5b2a..721873066 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 645cbc88d..563508633 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 1e2be44ba..cc91e1aaf 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "pre-release v4.0"
+#define BANNERMSG3 "Release v4.9237 - Ice Coffee :coffee:"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common/default_version.c b/common/default_version.c
index 0f42590e8..86ba9f9ab 100644
--- a/common/default_version.c
+++ b/common/default_version.c
@@ -1,5 +1,5 @@
#include "common.h"
-/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
+/* Generated file, do not edit */
#ifndef ON_DEVICE
#define SECTVERSINFO
#else
@@ -8,8 +8,9 @@
const struct version_information SECTVERSINFO version_information = {
VERSION_INFORMATION_MAGIC,
- 1, /* version 1 */
- 0, /* version information not present */
- 2, /* cleanliness couldn't be determined */
- /* Remaining fields: zero */
+ 1,
+ 1,
+ 2,
+ "RRG/Iceman/master/v4.9237",
+ "2020-05-21 21:55:15",
};
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index c8dceead5..d5b2c0557 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 4794d6ec4..318034f51 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 318b5db78..1e157eef6 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index b560577bd..30083c56d 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 9d19b63ee..8e2b38f82 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -Werror -O3
+CFLAGS?=-Wall -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From d40251ff0be75f97ed88b6c8fa6e61674e190edd Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 21:55:15 +0200
Subject: [PATCH 107/527] Revert "Release v4.9237 - Ice Coffee :coffee:"
This reverts commit 833bc4d9a3f2c1dcef4a72393663f75e0ba0fbd1.
---
Makefile.defs | 2 +-
client/CMakeLists.txt | 2 +-
client/Makefile | 2 +-
client/deps/amiibo.cmake | 2 +-
client/deps/cliparser.cmake | 2 +-
client/deps/hardnested.cmake | 12 ++++++------
client/deps/jansson.cmake | 2 +-
client/deps/lua.cmake | 2 +-
client/deps/mbedtls.cmake | 2 +-
client/deps/reveng.cmake | 2 +-
client/deps/tinycbor.cmake | 2 +-
client/deps/whereami.cmake | 2 +-
client/deps/zlib.cmake | 2 +-
client/src/proxmark3.c | 2 +-
common/default_version.c | 11 +++++------
common_arm/Makefile.common | 2 +-
tools/hitag2crack/crack2/Makefile | 2 +-
tools/hitag2crack/crack3/Makefile | 2 +-
tools/hitag2crack/crack4/Makefile | 2 +-
tools/hitag2crack/crack5/Makefile | 2 +-
20 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 477743d69..d206611d3 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -47,7 +47,7 @@ else
RANLIB= ranlib
endif
-DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
# Some more warnings we need first to eliminate, so temporarely tolerated:
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index ce58a4449..a56ea5a9a 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -229,7 +229,7 @@ add_executable(
${ADDITIONAL_SRC}
)
-target_compile_options(proxmark3 PUBLIC -Wall -O3)
+target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
if (MINGW)
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
diff --git a/client/Makefile b/client/Makefile
index 260f72751..79943d8fa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -75,7 +75,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-CXXFLAGS ?= -Wall -O3
+CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include
LUAPLATFORM = generic
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index fbf2a6f74..34780f597 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -13,5 +13,5 @@ add_library(pm3rrg_rdv4_amiibo STATIC
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
-target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake
index 69b639a84..b16451c07 100644
--- a/client/deps/cliparser.cmake
+++ b/client/deps/cliparser.cmake
@@ -8,5 +8,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
-target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake
index 612265de0..9efff1445 100644
--- a/client/deps/hardnested.cmake
+++ b/client/deps/hardnested.cmake
@@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
-target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE
@@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE
-mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -41,7 +41,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE
-mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -55,7 +55,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE
-mmmx -msse2 -mavx -mno-avx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -69,7 +69,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mno-avx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -83,7 +83,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS)
hardnested/hardnested_bf_core.c
hardnested/hardnested_bitarray_core.c)
- target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3)
+ target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE
-mmmx -msse2 -mavx -mavx2 -mavx512f)
set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index 1a55b7fa5..a95ff0baf 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -15,5 +15,5 @@ add_library(pm3rrg_rdv4_jansson STATIC
target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H)
target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson)
-target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3)
+target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3)
set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake
index 94c184906..679147124 100644
--- a/client/deps/lua.cmake
+++ b/client/deps/lua.cmake
@@ -45,5 +45,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
-target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 93a646e0d..63e706889 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
-target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake
index 1040730f1..d7e3cfd8a 100644
--- a/client/deps/reveng.cmake
+++ b/client/deps/reveng.cmake
@@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE
../src
../../include)
target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng)
-target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake
index c74618149..5a6abda25 100644
--- a/client/deps/tinycbor.cmake
+++ b/client/deps/tinycbor.cmake
@@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC
target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor)
# Strange errors on Mingw when compiling with -O3
-target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2)
+target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2)
set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake
index 721873066..d2d6a5b2a 100644
--- a/client/deps/whereami.cmake
+++ b/client/deps/whereami.cmake
@@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c)
target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED)
target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami)
-target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 563508633..645cbc88d 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,5 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
-target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -O3)
+target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index cc91e1aaf..1e2be44ba 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "Release v4.9237 - Ice Coffee :coffee:"
+#define BANNERMSG3 "pre-release v4.0"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
diff --git a/common/default_version.c b/common/default_version.c
index 86ba9f9ab..0f42590e8 100644
--- a/common/default_version.c
+++ b/common/default_version.c
@@ -1,5 +1,5 @@
#include "common.h"
-/* Generated file, do not edit */
+/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
#ifndef ON_DEVICE
#define SECTVERSINFO
#else
@@ -8,9 +8,8 @@
const struct version_information SECTVERSINFO version_information = {
VERSION_INFORMATION_MAGIC,
- 1,
- 1,
- 2,
- "RRG/Iceman/master/v4.9237",
- "2020-05-21 21:55:15",
+ 1, /* version 1 */
+ 0, /* version information not present */
+ 2, /* cleanliness couldn't be determined */
+ /* Remaining fields: zero */
};
diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common
index d5b2c0557..c8dceead5 100644
--- a/common_arm/Makefile.common
+++ b/common_arm/Makefile.common
@@ -40,7 +40,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
ARMCFLAGS = -mthumb-interwork -fno-builtin
-DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe
+DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe
# Some more warnings we want as errors:
DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 318034f51..4794d6ec4 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
# Linux libs
LIBS=-pthread -D_GNU_SOURCE
# Mac libs
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 1e157eef6..318b5db78 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index 30083c56d..b560577bd 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 8e2b38f82..9d19b63ee 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,4 +1,4 @@
-CFLAGS?=-Wall -O3
+CFLAGS?=-Wall -Werror -O3
LIBS=-lpthread
VPATH=../common
INC=-I ../common
From 2cb198743ac0eee76c726471862ced2c951e0d78 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 22:04:21 +0200
Subject: [PATCH 108/527] minor release doc fix
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 63ca7bf53..d39183105 100644
--- a/Makefile
+++ b/Makefile
@@ -271,7 +271,7 @@ endif
# - Reverting tagged commit...
@git revert --no-edit HEAD
@echo "==================================================================="
- @echo "Done! You can now execute 'git push origin $(VERSION)'"
+ @echo "Done! You can now execute 'git push && git push origin $(VERSION)'"
# Dummy target to test for GNU make availability
_test:
From 4eecf9a83c45f6a890bc53f41e6cf29c13f0bd06 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 22:23:12 +0200
Subject: [PATCH 109/527] textual
---
doc/md/Use_of_Proxmark/1_Validation.md | 36 ++++++++++++++------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/doc/md/Use_of_Proxmark/1_Validation.md b/doc/md/Use_of_Proxmark/1_Validation.md
index 507648e64..09432b067 100644
--- a/doc/md/Use_of_Proxmark/1_Validation.md
+++ b/doc/md/Use_of_Proxmark/1_Validation.md
@@ -3,26 +3,27 @@
If all went well you should get some information about the firmware and memory usage as well as the prompt, something like this.
```
+[=] Session log /home/iceman/.proxmark3/log_20200521.txt
+[=] Loading Preferences...
+[+] loaded from JSON file /home/iceman/.proxmark3/preferences.json
+[=] Using UART port /dev/ttyS7
+[=] Communicating with PM3 over USB-CDC
-██████╗ ███╗ ███╗ ████╗ ...iceman fork
-██╔══██╗████╗ ████║ ══█║ ...dedicated to RDV40
+
+██████╗ ███╗ ███╗ ████╗
+██╔══██╗████╗ ████║ ══█║
██████╔╝██╔████╔██║ ████╔╝
-██╔═══╝ ██║╚██╔╝██║ ══█║ iceman@icesql.net
+██╔═══╝ ██║╚██╔╝██║ ══█║ :snowflake: iceman@icesql.net
██║ ██║ ╚═╝ ██║ ████╔╝ https://github.com/rfidresearchgroup/proxmark3/
-╚═╝ ╚═╝ ╚═╝ ╚═══╝ pre-release v4.0
+╚═╝ ╚═╝ ╚═╝ ╚═══╝ Release v4.9237 - Ice Coffee :coffee:
-Support iceman on patreon, https://www.patreon.com/iceman1001/
-
-
-[=] Using UART port /dev/pm3-0
-[=] Communicating with PM3 over USB-CDC
[ Proxmark3 RFID instrument ]
-
[ CLIENT ]
- client: RRG/Iceman
-
+ client: RRG/Iceman/master/v4.9237-2-g2cb19874 2020-05-21 22:00:00
+ compiled with GCC 9.3.0 OS:Linux ARCH:x86_64
+
[ PROXMARK RDV4 ]
external flash: present
smartcard reader: present
@@ -31,17 +32,18 @@ Support iceman on patreon, https://www.patreon.com/iceman1001/
FPC USART for BT add-on support: absent
[ ARM ]
- bootrom: RRG/Iceman/master/5ab9716e 2019-05-01 11:02:08
- os: RRG/Iceman/master/6b5a0f83 2019-05-04 23:57:47
+ bootrom: RRG/Iceman/master/v4.9237-2-g2cb19874 2020-05-21 22:00:10
+ os: RRG/Iceman/master/v4.9237-2-g2cb19874 2019-05-21 22:00:26
+ compiled with GCC 8.3.1 20190703 (release) [gcc-8-branch revision 273027]
[ FPGA ]
- LF image built for 2s30vq100 on 2019/ 4/18 at 9:35:32
- HF image built for 2s30vq100 on 2018/ 9/ 3 at 21:40:23
+ LF image built for 2s30vq100 on 2020/02/22 at 12:51:14
+ HF image built for 2s30vq100 on 2020/01/12 at 15:31:16
[ Hardware ]
--= uC: AT91SAM7S512 Rev B
--= Embedded Processor: ARM7TDMI
- --= Nonvolatile Program Memory Size: 512K bytes, Used: 250913 bytes (48%) Free: 273375 bytes (52%)
+ --= Nonvolatile Program Memory Size: 512K bytes, Used: 291382 bytes (56%) Free: 232906 bytes (44%)
--= Second Nonvolatile Program Memory Size: None
--= Internal SRAM Size: 64K bytes
--= Architecture Identifier: AT91SAM7Sxx Series
From de8710f854c5483cb8a75396ae5b1528ffd4dc4a Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Thu, 21 May 2020 22:24:00 +0200
Subject: [PATCH 110/527] bleeding edge bae!
---
client/src/proxmark3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 1e2be44ba..f50a15b7f 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 "pre-release v4.0"
+#define BANNERMSG3 " bleeding edge"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
From 8847bed0230105d5cd24827b1fe0e7b8e168d9ef Mon Sep 17 00:00:00 2001
From: Iceman
Date: Thu, 21 May 2020 22:28:01 +0200
Subject: [PATCH 111/527] Update 1_Validation.md
---
doc/md/Use_of_Proxmark/1_Validation.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/doc/md/Use_of_Proxmark/1_Validation.md b/doc/md/Use_of_Proxmark/1_Validation.md
index 09432b067..9bb93c453 100644
--- a/doc/md/Use_of_Proxmark/1_Validation.md
+++ b/doc/md/Use_of_Proxmark/1_Validation.md
@@ -13,9 +13,9 @@ If all went well you should get some information about the firmware and memory u
██████╗ ███╗ ███╗ ████╗
██╔══██╗████╗ ████║ ══█║
██████╔╝██╔████╔██║ ████╔╝
-██╔═══╝ ██║╚██╔╝██║ ══█║ :snowflake: iceman@icesql.net
+██╔═══╝ ██║╚██╔╝██║ ══█║ iceman@icesql.net
██║ ██║ ╚═╝ ██║ ████╔╝ https://github.com/rfidresearchgroup/proxmark3/
-╚═╝ ╚═╝ ╚═╝ ╚═══╝ Release v4.9237 - Ice Coffee :coffee:
+╚═╝ ╚═╝ ╚═╝ ╚═══╝ Release v4.9237 - Ice Coffee
[ Proxmark3 RFID instrument ]
@@ -50,10 +50,10 @@ If all went well you should get some information about the firmware and memory u
--= Nonvolatile Program Memory Type: Embedded Flash Memory
-pm3 -->
+[usb] pm3 -->
```
-This `pm3 --> ` is the Proxmark3 interactive prompt.
+This `[usb] pm3 --> ` is the Proxmark3 interactive prompt.
### To get interactive help
@@ -64,16 +64,16 @@ For basic help type `help`. Or for help on a set of sub commands type the comman
These commands will return some info about your Proxmark software and hardware status.
```
-pm3 --> hw status
-pm3 --> hw version
-pm3 --> hw tune
+[usb] pm3 --> hw status
+[usb] pm3 --> hw version
+[usb] pm3 --> hw tune
```
You are now ready to use your newly flashed proxmark3 device. Many commands uses the `h` parameter to show a help text.
### To quit the client
```
-pm3 --> quit
+[usb] pm3 --> quit
```
or simple press `CTRL-D`.
From ebfd18a8f16e96b862060c3346e5989ea3235f32 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Thu, 21 May 2020 22:28:55 +0200
Subject: [PATCH 112/527] Update 2_Configuration-and-Verification.md
---
.../2_Configuration-and-Verification.md | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md b/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md
index 8b88115c6..fe87ec633 100644
--- a/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md
+++ b/doc/md/Use_of_Proxmark/2_Configuration-and-Verification.md
@@ -1,16 +1,16 @@
### First things on your RDV40
You will need to run these commands to make sure your rdv4 is prepared
```
-pm3 --> mem load f mfc_default_keys m
-pm3 --> mem load f t55xx_default_pwds t
-pm3 --> mem load f iclass_default_keys i
-pm3 --> lf t55xx deviceconfig a 29 b 17 c 15 d 47 e 15 p
-pm3 --> lf t55xx deviceconfig r 1 a 31 b 20 c 18 d 50 e 15 p
-pm3 --> lf t55xx deviceconfig r 2 a 31 b 20 c 18 d 40 e 15 p
-pm3 --> lf t55xx deviceconfig r 3 a 29 b 17 c 15 d 31 e 15 f 47 g 63 p
+[usb] pm3 --> mem load f mfc_default_keys m
+[usb] pm3 --> mem load f t55xx_default_pwds t
+[usb] pm3 --> mem load f iclass_default_keys i
+[usb] pm3 --> lf t55xx deviceconfig a 29 b 17 c 15 d 47 e 15 p
+[usb] pm3 --> lf t55xx deviceconfig r 1 a 31 b 20 c 18 d 50 e 15 p
+[usb] pm3 --> lf t55xx deviceconfig r 2 a 31 b 20 c 18 d 40 e 15 p
+[usb] pm3 --> lf t55xx deviceconfig r 3 a 29 b 17 c 15 d 31 e 15 f 47 g 63 p
Set all t55xx settings to defaults (will set all 4 at once)
-pm3 --> lf t55xx deviceconfig z p
+[usb] pm3 --> lf t55xx deviceconfig z p
```
### Verify sim module firmware version
@@ -20,7 +20,7 @@ To make sure you got the latest sim module firmware.
_Lastest version is v3.11_
```
-pm3 --> hw status
+[usb] pm3 --> hw status
```
Find version in the long output, look for these two lines
@@ -46,9 +46,9 @@ Don't not turn off your device during the execution of this command!!
Even its a quite fast command you should be warned. You may brick it if you interrupt it.
```
-pm3 --> sc upgrade f /usr/local/share/proxmark3/firmware/sim011.bin
+[usb] pm3 --> sc upgrade f /usr/local/share/proxmark3/firmware/sim011.bin
# or if from local repo
-pm3 --> sc upgrade f tools/simmodule/sim011.bin
+[usb] pm3 --> sc upgrade f tools/simmodule/sim011.bin
```
You get the following output if the execution was successful:
@@ -71,7 +71,7 @@ You get the following output if the execution was successful:
Run hw status command to verify that the upgrade went well.
```
-pm3 --> hw status
+[usb] pm3 --> hw status
```
## Next steps
From d8c2479e6090fdd633f21b08b4767160f9f85725 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Thu, 21 May 2020 22:29:18 +0200
Subject: [PATCH 113/527] Update 3_Commands-and-Features.md
---
doc/md/Use_of_Proxmark/3_Commands-and-Features.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/md/Use_of_Proxmark/3_Commands-and-Features.md b/doc/md/Use_of_Proxmark/3_Commands-and-Features.md
index deb7036d7..195468002 100644
--- a/doc/md/Use_of_Proxmark/3_Commands-and-Features.md
+++ b/doc/md/Use_of_Proxmark/3_Commands-and-Features.md
@@ -21,17 +21,17 @@ Here are some commands to start off with.
To get an overview of the available commands for LF RFID and HF RFID:
```
-pm3 --> lf
-pm3 --> hf
+[usb] pm3 --> lf
+[usb] pm3 --> hf
```
To search quickly for known LF or HF tags:
```
-pm3 --> lf search
-pm3 --> hf search
+[usb] pm3 --> lf search
+[usb] pm3 --> hf search
```
To get info on a ISO14443-A tag:
```
-pm3 --> hf 14a info
+[usb] pm3 --> hf 14a info
```
From f27760afd69be0844a05a8348ca74cc962a7fbdd Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 00:24:08 +0200
Subject: [PATCH 114/527] text
---
client/src/proxmark3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index f50a15b7f..60f3b5be8 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -34,7 +34,7 @@
#define BANNERMSG1 " :snowflake: iceman@icesql.net"
#define BANNERMSG2 " https://github.com/rfidresearchgroup/proxmark3/"
-#define BANNERMSG3 " bleeding edge"
+#define BANNERMSG3 " bleeding edge :coffee:"
typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode;
From 888235cd74a3e768068ba5f6c2d1d38b9d73a878 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 01:02:00 +0200
Subject: [PATCH 115/527] gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index d28933d82..bdd98d374 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,7 @@ Makefile.platform
# cmake
client/build/
+client/android/build/
# Coverity
cov-int/
From 0a2eb6783c204ebfc4416a8435446da7685db00f Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 12:41:19 +0200
Subject: [PATCH 116/527] chmod perl scripts
---
tools/mkversion.pl | 0
tools/rfidtest.pl | 0
2 files changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 tools/mkversion.pl
mode change 100644 => 100755 tools/rfidtest.pl
diff --git a/tools/mkversion.pl b/tools/mkversion.pl
old mode 100644
new mode 100755
diff --git a/tools/rfidtest.pl b/tools/rfidtest.pl
old mode 100644
new mode 100755
From 0a263b353bba2b1c72699027c1775ea88f98bd2e Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 13:02:52 +0200
Subject: [PATCH 117/527] make release: remove mkversion calls
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index d39183105..f78964b94 100644
--- a/Makefile
+++ b/Makefile
@@ -262,6 +262,9 @@ endif
@git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
# - Changing default version information based on new tag
@$(SH) tools/mkversion.sh --undecided > common/default_version.c.tmp && $(MV) common/default_version.c.tmp common/default_version.c
+ # - Removing mkversion calls
+ @sed -i 's#^.*\.\./tools/mkversion.sh.*|| #\t$$(Q)#' client/Makefile bootrom/Makefile armsrc/Makefile
+ @sed -i '/COMMAND/s/sh .*|| //' client/CMakeLists.txt
# - Deleting tag...
@git tag -d $(VERSION)
# - Amending commit...
From 5dc1b6cc6fbe85629b014020d0244cfa19851af3 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 13:33:03 +0200
Subject: [PATCH 118/527] make release: trigger git calls only on recipe
---
Makefile | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index f78964b94..44db7c01d 100644
--- a/Makefile
+++ b/Makefile
@@ -238,15 +238,9 @@ endif
release: VERSION="v4.$(shell git log --oneline master | wc -l)"
release:
-ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
- $(error "!!! you are not on master branch, aborting")
-endif
-ifeq ($(shell git describe --dirty --always|grep -o dirty),dirty)
- $(error "!!! you have pending changes, aborting")
-endif
-ifeq ($(RELEASE_NAME),)
- $(error "!!! missing RELEASE_NAME, aborting")
-endif
+ $(if $(findstring master,$(shell git rev-parse --abbrev-ref HEAD)),,$(error "!!! you are not on master branch, aborting"))
+ $(if $(findstring dirty,$(shell git describe --dirty --always)),$(error "!!! you have pending changes, aborting"))
+ $(if $(RELEASE_NAME),,$(error "!!! missing RELEASE_NAME, aborting"))
# Preparing a commit for release tagging, to be reverted after tagging.
@echo "# - Release Tag: $(VERSION)"
@echo "# - Release Name: $(RELEASE_NAME)"
From f30ccd0f5184af677451b14452812f592c8e8c1c Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 13:34:43 +0200
Subject: [PATCH 119/527] Makefile: fix cp version for armsrc
---
armsrc/Makefile | 2 +-
bootrom/Makefile | 2 +-
client/Makefile | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/armsrc/Makefile b/armsrc/Makefile
index 18d36a1b7..f9e33f5e5 100644
--- a/armsrc/Makefile
+++ b/armsrc/Makefile
@@ -152,7 +152,7 @@ showinfo:
# version.c should be remade on every time fullimage.stage1.elf should be remade
version.c: default_version.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
$(info [-] GEN $@)
- $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $< $@
fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
$(info [-] GEN $@)
diff --git a/bootrom/Makefile b/bootrom/Makefile
index 68597aa22..785293ca6 100644
--- a/bootrom/Makefile
+++ b/bootrom/Makefile
@@ -39,7 +39,7 @@ OBJS = $(OBJDIR)/bootrom.s19
# version.c should be remade on every compilation
version.c: default_version.c
$(info [=] GEN $@)
- $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $< $@
all: showinfo $(OBJS)
diff --git a/client/Makefile b/client/Makefile
index 79943d8fa..71d6a6d88 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -430,7 +430,7 @@ zlib:
# version.c should be remade on every compilation
src/version.c: default_version.c
$(info [=] GEN $@)
- $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $^ $@
+ $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $< $@
# easy printing of MAKE VARIABLES
print-%: ; @echo $* = $($*)
From 3d4d90eac581e04941744d83198f480d3f85caf4 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 13:44:35 +0200
Subject: [PATCH 120/527] make release : remove undecided/suspect
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 44db7c01d..958fe65a2 100644
--- a/Makefile
+++ b/Makefile
@@ -255,7 +255,7 @@ release:
# - Tagging temporarily...
@git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
# - Changing default version information based on new tag
- @$(SH) tools/mkversion.sh --undecided > common/default_version.c.tmp && $(MV) common/default_version.c.tmp common/default_version.c
+ @$(SH) tools/mkversion.sh > common/default_version.c.tmp && $(MV) common/default_version.c.tmp common/default_version.c
# - Removing mkversion calls
@sed -i 's#^.*\.\./tools/mkversion.sh.*|| #\t$$(Q)#' client/Makefile bootrom/Makefile armsrc/Makefile
@sed -i '/COMMAND/s/sh .*|| //' client/CMakeLists.txt
From d7cfaae17f03f92a4a6d7f2ba77bfbf6c06050a0 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 13:59:30 +0200
Subject: [PATCH 121/527] Load prefs only after parsing of options, don't
clutter -v
---
client/src/proxmark3.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 60f3b5be8..427619e75 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -691,6 +691,7 @@ int main(int argc, char *argv[]) {
bool flash_mode = false;
bool flash_can_write_bl = false;
+ bool debug_mode_forced = false;
int flash_num_files = 0;
char *flash_filenames[FLASH_MAX_FILES];
@@ -698,16 +699,6 @@ int main(int argc, char *argv[]) {
set_my_executable_path();
set_my_user_directory();
-#ifdef USE_PREFERENCE_FILE
- // Load Settings and assign
- // This will allow the command line to override the settings.json values
- preferences_load();
- // quick patch for debug level
- g_debugMode = session.client_debug_level;
- // settings_save ();
- // End Settings
-#endif
-
for (int i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
@@ -779,6 +770,7 @@ int main(int argc, char *argv[]) {
return 1;
}
g_debugMode = demod;
+ debug_mode_forced = true;
i++;
continue;
}
@@ -886,6 +878,17 @@ int main(int argc, char *argv[]) {
return 1;
}
+#ifdef USE_PREFERENCE_FILE
+ // Load Settings and assign
+ // This will allow the command line to override the settings.json values
+ preferences_load();
+ // quick patch for debug level
+ if (! debug_mode_forced)
+ g_debugMode = session.client_debug_level;
+ // settings_save ();
+ // End Settings
+#endif
+
#ifndef USE_PREFERENCE_FILE
// comment next 2 lines to use session values set from settings_load
session.supports_colors = DetectWindowsAnsiSupport();
From aef6d7e5f21ac6e47bef20290cc2be26a95ec3c2 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Thu, 21 May 2020 02:20:02 +0200
Subject: [PATCH 122/527] Detect and use system Lua. Makefile. Cmake todo
---
client/Makefile | 114 +++++++++++++++++++-----------
doc/md/Development/Maintainers.md | 1 +
2 files changed, 73 insertions(+), 42 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index 71d6a6d88..363ff0089 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -36,74 +36,63 @@ endif
# local libraries
LUALIBPATH = ./deps/liblua
+LUALIBINC = -I$(LUALIBPATH)
LUALIB = $(LUALIBPATH)/liblua.a
JANSSONLIBPATH = ./deps/jansson
+JANSSONLIBINC = -I$(JANSSONLIBPATH)
JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
CBORLIBPATH = ./deps/tinycbor
+CBORLIBINC = -I$(CBORLIBPATH)
CBORLIB = $(CBORLIBPATH)/tinycbor.a
REVENGLIBPATH = ./deps/reveng
+REVENGLIBINC = -I$(REVENGLIBPATH)
REVENGLIB = $(REVENGLIBPATH)/libreveng.a
AMIIBOLIBPATH = ./deps/amiitool
+AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
HARDNESTEDLIBPATH = ./deps/hardnested
+HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
CLIPARSERLIBPATH = ./deps/cliparser
+CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
WAILIBPATH = ./deps/whereami
+WAILIBINC = -I$(WAILIBPATH)
WAILIB = $(WAILIBPATH)/libwhereami.a
+LUAPLATFORM = generic
+ifneq (,$(findstring MINGW,$(platform)))
+ LUAPLATFORM = mingw
+else
+ ifeq ($(platform),Darwin)
+ LUAPLATFORM = macosx
+ else
+ LUALIB += -ldl
+ LUAPLATFORM = linux
+ endif
+endif
+
# common libraries
MBEDTLSLIBPATH = ../common/mbedtls
MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
ZLIBPATH = ../common/zlib
ZLIB = $(OBJDIR)/libz.a
-LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGLIBPATH) -I$(AMIIBOLIBPATH) -I$(HARDNESTEDLIBPATH) -I$(CLIPARSERLIBPATH) -I$(WAILIBPATH)
-INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
-CFLAGS ?= $(DEFCFLAGS)
-
-# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
-PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
-# WIP Testing
-#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
-PREFIX ?= /usr/local
-ifneq (,$(findstring MINGW,$(platform)))
- # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
- # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
- # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
- # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
- PM3CFLAGS += -D_ISOC99_SOURCE
- PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
-endif
-CXXFLAGS ?= -Wall -Werror -O3
-PM3CXXFLAGS = $(CXXFLAGS) -I../include
-
-LUAPLATFORM = generic
-ifneq (,$(findstring MINGW,$(platform)))
- LUAPLATFORM = mingw
-else
- ifeq ($(platform),Darwin)
- LUAPLATFORM = macosx
- OBJCSRCS = util_darwin.m
- LDFLAGS += -framework Foundation -framework AppKit
- LDLIBS := -L/usr/local/opt/readline/lib $(LDLIBS)
- LIBS := -I/usr/local/opt/readline/include $(LIBS)
- # cf brew info qt: qt not symlinked anymore
- PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
-else
- LUALIB += -ldl
- LUAPLATFORM = linux
-endif
+# system libraries
+ifneq ($(SKIPLUASYSTEM),1)
+ LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
+ LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
+ ifneq ($(LUAINCLUDES),)
+ LUALIB = $(LUALDLIBS)
+ LUALIBINC = $(LUAINCLUDES)
+ LUASYSTEM = 1
+ endif
endif
ifneq ($(SKIPBT),1)
BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
endif
-ifneq ($(BTLDLIBS),)
- PM3CFLAGS += -DHAVE_BLUEZ
-endif
-
ifneq ($(SKIPQT),1)
# Check for correctly configured Qt5
QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
@@ -118,7 +107,7 @@ ifneq ($(SKIPQT),1)
UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
else
# On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
- PM3CXXFLAGS += -fPIC -std=c++11
+ QT5FOUND = 1
endif
ifeq ($(QTINCLUDES), )
# if both pkg-config commands failed, search in common places
@@ -128,7 +117,7 @@ ifneq ($(SKIPQT),1)
ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
QTINCLUDES += -I$(QTDIR)/include/QtWidgets
QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
- PM3CXXFLAGS += -fPIC -std=c++11
+ QT5FOUND = 1
endif
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
@@ -136,11 +125,47 @@ ifneq ($(SKIPQT),1)
endif
endif
+LIBS = $(LUALIBINC) $(MBEDTLSLIBINC) $(JANSSONLIBINC) $(CBORLIBINC) $(ZLIBINC) $(REVENGLIBINC) $(AMIIBOLIBINC) $(HARDNESTEDLIBINC) $(CLIPARSERLIBINC) $(WAILIBINC)
+INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
+CFLAGS ?= $(DEFCFLAGS)
+
+# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
+PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
+# WIP Testing
+#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
+PREFIX ?= /usr/local
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
+ # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
+ PM3CFLAGS += -D_ISOC99_SOURCE
+ PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
+endif
+ifeq ($(platform),Darwin)
+ OBJCSRCS = util_darwin.m
+ LDFLAGS += -framework Foundation -framework AppKit
+ LDLIBS := -L/usr/local/opt/readline/lib $(LDLIBS)
+ LIBS := -I/usr/local/opt/readline/include $(LIBS)
+ # cf brew info qt: qt not symlinked anymore
+ PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
+endif
+
+CXXFLAGS ?= -Wall -Werror -O3
+PM3CXXFLAGS = $(CXXFLAGS) -I../include
+
+ifneq ($(BTLDLIBS),)
+ PM3CFLAGS += -DHAVE_BLUEZ
+endif
+
ifneq ($(QTLDLIBS),)
QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
PM3CFLAGS += -DHAVE_GUI
PM3CXXFLAGS += -DQT_NO_DEBUG
+ ifeq ($(QT5FOUND),1)
+ PM3CXXFLAGS += -fPIC -std=c++11
+ endif
else
QTGUISRCS = guidummy.cpp
QTGUIOBJS = $(OBJDIR)/guidummy.o
@@ -162,6 +187,9 @@ $(info native BT support: Bluez found, enabled)
else
$(info native BT support: Bluez not found, disabled)
endif
+ifeq ($(LUASYSTEM),1)
+$(info system LUA: Lua5.2 found)
+endif
$(info compiler version: $(shell $(CC) --version|head -n 1))
$(info ===================================================================)
@@ -385,8 +413,10 @@ tarbin: $(BINS)
# local libraries:
liblua:
+ifneq ($(LUASYSTEM),1)
$(info [*] MAKE $@ for $(LUAPLATFORM))
$(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
+endif
jansson:
$(info [*] MAKE $@)
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 2a49343fd..c3d0e4e29 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -61,6 +61,7 @@ It's also possible to skip parts even if libraries are present in the compilatio
* `make client SKIPQT=1` to skip GUI even if Qt is present
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
+* `make client SKIPLUASYSTEM=1` to skip system Lua lib even if liblua5.2 is present, use embedded Lua lib instead
If you're cross-compiling, these ones might be useful:
From 278db15f5aa62d30ef09aa900c70a2c2a57c6264 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 17:47:30 +0200
Subject: [PATCH 123/527] Move tests to tools/pm3_tests.sh and add "make check"
to call it
---
.travis.yml | 4 +-
Makefile | 41 ++++++-
Makefile.defs | 1 +
covbuild.sh | 2 +-
pm3test.sh | 167 ---------------------------
tools/pm3_tests.sh | 276 +++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 317 insertions(+), 174 deletions(-)
delete mode 100755 pm3test.sh
create mode 100755 tools/pm3_tests.sh
diff --git a/.travis.yml b/.travis.yml
index f8cf8228f..ad23bf6f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -54,9 +54,9 @@ install:
script:
- if [ "$TO_TEST" = "MAKEFILE" ]; then
make clean && make V=1 "$MAKE_PARAMS";
- ./pm3test.sh;
+ make check;
fi
- if [ "$TO_TEST" = "CMAKE" ]; then
mkdir -p client/build && ( cd client/build && cmake .. && make VERBOSE=1 );
- PM3BIN=./client/build/proxmark3 ./pm3test.sh client;
+ make client/check CHECKARGS="--clientbin ./client/build/proxmark3";
fi
diff --git a/Makefile b/Makefile
index 958fe65a2..d111d01fc 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ ifneq (,$(DESTDIR))
endif
endif
-all clean install uninstall: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% fpga_compress/%
+all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% fpga_compress/%
INSTALLTOOLS=pm3_eml2lower.sh pm3_eml2upper.sh pm3_mfdread.py pm3_mfd2eml.py pm3_eml2mfd.py findbits.py rfidtest.pl xorcheck.py
INSTALLSIMFW=sim011.bin sim011.sha512.txt
@@ -78,6 +78,37 @@ ifeq ($(platform),Linux)
endif
$(Q)$(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
+# tests
+mfkey/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+nonce2key/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+mf_nonce_brute/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+fpga_compress/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+bootrom/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+armsrc/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+client/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+recovery/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+common/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+check: common/check
+ $(info [*] ALL CHECKS DONE)
+
mfkey/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@) DESTDIR=$(MYDESTDIR)
@@ -106,7 +137,7 @@ recovery/%: FORCE cleanifplatformchanged
$(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
-.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute style checks FORCE udev accessrights cleanifplatformchanged
+.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute style miscchecks release FORCE udev accessrights cleanifplatformchanged
help:
@echo "Multi-OS Makefile"
@@ -129,7 +160,9 @@ help:
@echo "+ fpga_compress - Make tools/fpga_compress"
@echo
@echo "+ style - Apply some automated source code formatting rules"
- @echo "+ checks - Detect various encoding issues in source code"
+ @echo "+ check - Run offline tests. Set CHECKARGS to pass arguments to the test script"
+ @echo "+ .../check - Run offline tests against specific target. See above."
+ @echo "+ miscchecks - Detect various encoding issues in source code"
@echo
@echo "Possible platforms: try \"make PLATFORM=\" for more info, default is PM3RDV4"
@echo "To activate verbose mode, use make V=1"
@@ -217,7 +250,7 @@ style:
--align-pointer=name {} \;
# Detecting weird codepages and tabs.
-checks:
+miscchecks:
# Make sure recode is installed
@which recode >/dev/null || ( echo "Please install 'recode' package first" ; exit 1 )
@echo "Files with suspicious chars:"
diff --git a/Makefile.defs b/Makefile.defs
index d206611d3..fb8a7a45b 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -25,6 +25,7 @@ CC = gcc
CXX = g++
LD = g++
SH = sh
+BASH = bash
PERL = perl
PATHSEP=/
diff --git a/covbuild.sh b/covbuild.sh
index 2e18e677f..73c9a4441 100755
--- a/covbuild.sh
+++ b/covbuild.sh
@@ -32,7 +32,7 @@ cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --no-generate-
#########################################
# Run tests #
#########################################
-cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --test-capture ./pm3test.sh long
+cov-build --dir "$COVDIR" --c-coverage=gcov --no-network-coverage --test-capture tools/pm3_tests.sh --long
#cov-manage-emit --dir "$COVDIR" list-coverage-known
#########################################
diff --git a/pm3test.sh b/pm3test.sh
deleted file mode 100755
index 3bd7ae3a8..000000000
--- a/pm3test.sh
+++ /dev/null
@@ -1,167 +0,0 @@
-#!/usr/bin/env bash
-
-PM3PATH=$(dirname "$0")
-cd "$PM3PATH" || exit 1
-
-if [ "$1" == "client" ]; then
- shift
- TESTDEVICE=false
- TESTTOOLS=false
-else
- TESTDEVICE=true
- TESTTOOLS=true
-fi
-if [ "$1" == "long" ]; then
- shift
- SLOWTESTS=true
-else
- SLOWTESTS=false
-fi
-
-C_RED='\033[0;31m'
-C_GREEN='\033[0;32m'
-C_YELLOW='\033[0;33m'
-C_BLUE='\033[0;34m'
-C_NC='\033[0m' # No Color
-
-# title, file name or file wildcard to check
-function CheckFileExist() {
-
- if [ -f "$2" ]; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
- return 0
- fi
-
- if ls "$2" 1> /dev/null 2>&1; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
- return 0
- fi
-
- echo -e "$1 ${C_RED}[Fail]${C_NC}"
- return 1
-}
-
-# title, command line, check result, repeat several times if failed, ignore if fail
-function CheckExecute() {
-
- if [ "$4" ]; then
- local RETRY="1 2 3 e"
- else
- local RETRY="e"
- fi
-
- for I in $RETRY
- do
- RES=$(eval "$2")
- if echo "$RES" | grep -q "$3"; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
- return 0
- fi
- if [ ! $I == "e" ]; then echo "retry $I"; fi
- done
-
-
- if [ "$5" ]; then
- echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}"
- return 0
- fi
-
- echo -e "$1 ${C_RED}[Fail]${C_NC}"
- echo -e "Execution trace:\n$RES"
- return 1
-}
-
-echo -e "\n${C_BLUE}RRG/Iceman Proxmark3 test tool ${C_NC}\n"
-
-echo -n "work directory: "
-pwd
-echo "client ${PM3BIN:="./client/proxmark3"}"
-
-if [ "$TRAVIS_COMMIT" ]; then
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
- echo "Travis branch: $TRAVIS_BRANCH slug: $TRAVIS_REPO_SLUG commit: $TRAVIS_COMMIT"
- else
- echo "Travis pull request: $TRAVIS_PULL_REQUEST branch: $TRAVIS_BRANCH slug: $TRAVIS_PULL_REQUEST_SLUG commit: $TRAVIS_COMMIT"
- fi
-fi
-
-echo -n "git branch: "
-git describe --all
-echo -n "git sha: "
-git rev-parse HEAD
-echo ""
-
-while true; do
- echo -e "\n${C_BLUE}Testing files:${C_NC}"
- if ! CheckFileExist "proxmark3 exists" "$PM3BIN"; then break; fi
- if ! CheckFileExist "hardnested tables exists" "./client/resources/hardnested_tables/bitflip_0_001_states.bin.z"; then break; fi
- if ! CheckFileExist "simmodule fw file exists" "./tools/simmodule/sim011.bin"; then break; fi
-
- if $TESTDEVICE; then
- if ! CheckFileExist "arm image exists" "./armsrc/obj/fullimage.elf"; then break; fi
- if ! CheckFileExist "bootrom exists" "./bootrom/obj/bootrom.elf"; then break; fi
- fi
-
- echo -e "\n${C_BLUE}Testing basic help:${C_NC}"
- if ! CheckExecute "proxmark help" "$PM3BIN -h" "wait"; then break; fi
- if ! CheckExecute "proxmark help text ISO7816" "$PM3BIN -t 2>&1" "ISO7816"; then break; fi
- if ! CheckExecute "proxmark help text hardnested" "$PM3BIN -t 2>&1" "hardnested"; then break; fi
-
- echo -e "\n${C_BLUE}Testing data manipulation:${C_NC}"
- if ! CheckExecute "reveng readline test" "$PM3BIN -c 'reveng -h;reveng -D'" "CRC-64/GO-ISO"; then break; fi
- if ! CheckExecute "reveng -g test" "$PM3BIN -c 'reveng -g abda202c'" "CRC-16/ISO-IEC-14443-3-A"; then break; fi
- if ! CheckExecute "reveng -w test" "$PM3BIN -c 'reveng -w 8 -s 01020304e3 010204039d'" "CRC-8/SMBUS"; then break; fi
- if ! CheckExecute "mfu pwdgen test" "$PM3BIN -c 'hf mfu pwdgen t'" "Selftest OK"; then break; fi
- if ! CheckExecute "trace load/list 14a" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list 1;'" "READBLOCK(8)"; then break; fi
- if ! CheckExecute "trace load/list x" "$PM3BIN -c 'trace load traces/hf_mfu.trace; trace list x 1;'" "0.0101840425"; then break; fi
-
- echo -e "\n${C_BLUE}Testing LF:${C_NC}"
- if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
- if ! CheckExecute "lf EM410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
- if ! CheckExecute "lf VISA2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
- if ! CheckExecute "lf AWID test" "$PM3BIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
- if ! CheckExecute "lf SECURAKEY test" "$PM3BIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
- if ! CheckExecute "lf NEXWATCH test" "$PM3BIN -c 'data load traces/quadrakey-521512301.pm3;lf search 1 '" "NexWatch ID found"; then break; fi
- if ! CheckExecute "lf KERI test" "$PM3BIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
- if ! CheckExecute "lf HID Prox test" "$PM3BIN -c 'data load traces/hid-proxCardII-05512-11432784-1.pm3;lf search 1'" "HID Prox ID found"; then break; fi
- if ! CheckExecute "lf PARADOX test" "$PM3BIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
- if ! CheckExecute "lf PAC test" "$PM3BIN -c 'data load traces/pac-8E4C058E.pm3;lf search 1'" "PAC/Stanley ID found"; then break; fi
- if ! CheckExecute "lf VIKING test" "$PM3BIN -c 'data load traces/Transit999-best.pm3;lf search 1'" "Viking ID found"; then break; fi
- if ! CheckExecute "lf FDX-B test" "$PM3BIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
- if ! CheckExecute "lf INDALA test" "$PM3BIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
- if ! CheckExecute "lf FDX/BioThermo test" "$PM3BIN -c 'data load traces/lf_fdx_biothermo.pm3; lf fdx demo'" "95.2 F / 35.1 C"; then break; fi
-
-
- echo -e "\n${C_BLUE}Testing HF:${C_NC}"
- if ! CheckExecute "hf mf offline text" "$PM3BIN -c 'hf mf'" "at_enc"; then break; fi
- if $SLOWTESTS; then
- if ! CheckExecute "hf mf hardnested test" "$PM3BIN -c 'hf mf hardnested t 1 000000000000'" "found:" "repeat" "ignore"; then break; fi
- if ! CheckExecute "hf iclass test" "$PM3BIN -c 'hf iclass loclass t l'" "verified ok"; then break; fi
- if ! CheckExecute "emv test" "$PM3BIN -c 'emv test -l'" "Test(s) \[ OK"; then break; fi
- else
- if ! CheckExecute "hf iclass test" "$PM3BIN -c 'hf iclass loclass t'" "key diversification (ok)"; then break; fi
- if ! CheckExecute "emv test" "$PM3BIN -c 'emv test'" "Test(s) \[ OK"; then break; fi
- fi
-
- if $TESTTOOLS; then
- echo -e "\n${C_BLUE}Testing tools:${C_NC}"
- # Need a decent example for mfkey32...
- if ! CheckExecute "mfkey32v2 test" "tools/mfkey/mfkey32v2 12345678 1AD8DF2B 1D316024 620EF048 30D6CB07 C52077E2 837AC61A" "Found Key: \[a0a1a2a3a4a5\]"; then break; fi
- if ! CheckExecute "mfkey64 test" "tools/mfkey/mfkey64 9c599b32 82a4166c a1e458ce 6eea41e0 5cadf439" "Found Key: \[ffffffffffff\]"; then break; fi
- if ! CheckExecute "mfkey64 long trace test" "tools/mfkey/./mfkey64 14579f69 ce844261 f8049ccb 0525c84f 9431cc40 7093df99 9972428ce2e8523f456b99c831e769dced09 8ca6827b ab797fd369e8b93a86776b40dae3ef686efd c3c381ba 49e2c9def4868d1777670e584c27230286f4 fbdcd7c1 4abd964b07d3563aa066ed0a2eac7f6312bf 9f9149ea" "Found Key: \[091e639cb715\]"; then break; fi
- if ! CheckExecute "nonce2key test" "tools/nonce2key/nonce2key e9cadd9c a8bf4a12 a020a8285858b090 050f010607060e07 5693be6c00000000" "key recovered: fc00018778f7"; then break; fi
- if ! CheckExecute "xorcheck test" "tools/xorcheck.py 04 00 80 64 ba" "final LRC XOR byte value: 5A"; then break; fi
- if ! CheckExecute "findbits test" "tools/findbits.py 73 0110010101110011" "Match at bit 9: 011001010"; then break; fi
- if ! CheckExecute "findbits_test test" "tools/findbits_test.py 2>&1" "OK"; then break; fi
- if ! CheckExecute "pm3_eml_mfd test" "tools/pm3_eml_mfd_test.py 2>&1" "OK"; then break; fi
- if $SLOWTESTS; then
- if ! CheckExecute "mf_nonce_brute test" "tools/mf_nonce_brute/mf_nonce_brute 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a" "Key.*: \[ffffffffffff\]"; then break; fi
- fi
- fi
-
- echo -e "\n${C_GREEN}Tests [OK]${C_NC}\n"
- exit 0
-done
-
-echo -e "\n${C_RED}Tests [FAIL]${C_NC}\n"
-exit 1
diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh
new file mode 100755
index 000000000..8aaf82d58
--- /dev/null
+++ b/tools/pm3_tests.sh
@@ -0,0 +1,276 @@
+#!/usr/bin/env bash
+
+PM3PATH="$(dirname "$0")/.."
+cd "$PM3PATH" || exit 1
+
+SLOWTESTS=false
+TESTALL=true
+TESTMFKEY=false
+TESTNONCE2KEY=false
+TESTMFNONCEBRUTE=false
+TESTFPGACOMPRESS=false
+TESTBOOTROM=false
+TESTARMSRC=false
+TESTCLIENT=false
+TESTRECOVERY=false
+TESTCOMMON=false
+
+# https://medium.com/@Drew_Stokes/bash-argument-parsing-54f3b81a6a8f
+PARAMS=""
+while (( "$#" )); do
+ case "$1" in
+ -h|--help)
+ echo """
+Usage: $0 [--long] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|fpga_compress|bootrom|armsrc|client|recovery|common]
+ --long: Enable slow tests
+ --clientbin ...: Specify path to proxmark3 binary to test
+ If no target given, all targets will be tested
+"""
+ exit 0
+ ;;
+ -l|--long)
+ SLOWTESTS=true
+ shift
+ ;;
+ --clientbin)
+ if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+ CLIENTBIN=$2
+ shift 2
+ else
+ echo "Error: Argument for $1 is missing" >&2
+ exit 1
+ fi
+ ;;
+ mfkey)
+ TESTALL=false
+ TESTMFKEY=true
+ shift
+ ;;
+ nonce2key)
+ TESTALL=false
+ TESTNONCE2KEY=true
+ shift
+ ;;
+ mf_nonce_brute)
+ TESTALL=false
+ TESTMFNONCEBRUTE=true
+ shift
+ ;;
+ fpga_compress)
+ TESTALL=false
+ TESTFPGACOMPRESS=true
+ shift
+ ;;
+ bootrom)
+ TESTALL=false
+ TESTBOOTROM=true
+ shift
+ ;;
+ armsrc)
+ TESTALL=false
+ TESTARMSRC=true
+ shift
+ ;;
+ client)
+ TESTALL=false
+ TESTCLIENT=true
+ shift
+ ;;
+ recovery)
+ TESTALL=false
+ TESTRECOVERY=true
+ shift
+ ;;
+ common)
+ TESTALL=false
+ TESTCOMMON=true
+ shift
+ ;;
+ -*|--*=) # unsupported flags
+ echo "Error: Unsupported flag $1" >&2
+ exit 1
+ ;;
+ *) # preserve positional arguments
+ PARAMS="$PARAMS $1"
+ shift
+ ;;
+ esac
+done
+# set positional arguments in their proper place
+eval set -- "$PARAMS"
+
+C_RED='\033[0;31m'
+C_GREEN='\033[0;32m'
+C_YELLOW='\033[0;33m'
+C_BLUE='\033[0;34m'
+C_NC='\033[0m' # No Color
+
+# title, file name or file wildcard to check
+function CheckFileExist() {
+
+ if [ -f "$2" ]; then
+ echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ return 0
+ fi
+
+ if ls "$2" 1> /dev/null 2>&1; then
+ echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ return 0
+ fi
+
+ echo -e "$1 ${C_RED}[Fail]${C_NC}"
+ return 1
+}
+
+# title, command line, check result, repeat several times if failed, ignore if fail
+function CheckExecute() {
+ if [ "$1" == "slow" ]; then
+ SLOWTEST=true
+ shift
+ else
+ SLOWTEST=false
+ fi
+ if [ "$4" ]; then
+ local RETRY="1 2 3 e"
+ else
+ local RETRY="e"
+ fi
+
+ if $SLOWTEST && ! $SLOWTESTS; then
+ echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (slow)\n"
+ return 0
+ fi
+
+ for I in $RETRY
+ do
+ RES=$(eval "$2")
+ if echo "$RES" | grep -q "$3"; then
+ echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ return 0
+ fi
+ if [ ! $I == "e" ]; then echo "retry $I"; fi
+ done
+
+ if [ "$5" ]; then
+ echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}"
+ return 0
+ fi
+
+ echo -e "$1 ${C_RED}[Fail]${C_NC}"
+ echo -e "Execution trace:\n$RES"
+ return 1
+}
+
+echo -e "\n${C_BLUE}RRG/Iceman Proxmark3 test tool ${C_NC}\n"
+
+echo -n "work directory: "
+pwd
+
+if [ "$TRAVIS_COMMIT" ]; then
+ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
+ echo "Travis branch: $TRAVIS_BRANCH slug: $TRAVIS_REPO_SLUG commit: $TRAVIS_COMMIT"
+ else
+ echo "Travis pull request: $TRAVIS_PULL_REQUEST branch: $TRAVIS_BRANCH slug: $TRAVIS_PULL_REQUEST_SLUG commit: $TRAVIS_COMMIT"
+ fi
+fi
+
+echo -n "git branch: "
+git describe --all
+echo -n "git sha: "
+git rev-parse HEAD
+echo ""
+
+while true; do
+ if $TESTALL || $TESTCOMMON; then
+ echo -e "\n${C_BLUE}Testing common:${C_NC}"
+ if ! CheckFileExist "hardnested tables exists" "./client/resources/hardnested_tables/bitflip_0_001_states.bin.z"; then break; fi
+ if ! CheckFileExist "simmodule fw file exists" "./tools/simmodule/sim011.bin"; then break; fi
+ echo -e "\n${C_BLUE}Testing tools:${C_NC}"
+ if ! CheckExecute "xorcheck test" "tools/xorcheck.py 04 00 80 64 ba" "final LRC XOR byte value: 5A"; then break; fi
+ if ! CheckExecute "findbits test" "tools/findbits.py 73 0110010101110011" "Match at bit 9: 011001010"; then break; fi
+ if ! CheckExecute "findbits_test test" "tools/findbits_test.py 2>&1" "OK"; then break; fi
+ if ! CheckExecute "pm3_eml_mfd test" "tools/pm3_eml_mfd_test.py 2>&1" "OK"; then break; fi
+ fi
+ if $TESTALL || $TESTBOOTROM; then
+ echo -e "\n${C_BLUE}Testing bootrom:${C_NC}"
+ if ! CheckFileExist "bootrom exists" "./bootrom/obj/bootrom.elf"; then break; fi
+ fi
+ if $TESTALL || $TESTARMSRC; then
+ echo -e "\n${C_BLUE}Testing armsrc:${C_NC}"
+ if ! CheckFileExist "arm image exists" "./armsrc/obj/fullimage.elf"; then break; fi
+ fi
+ if $TESTALL || $TESTRECOVERY; then
+ echo -e "\n${C_BLUE}Testing recovery:${C_NC}"
+ if ! CheckFileExist "recovery image exists" "./recovery/proxmark3_recovery.bin"; then break; fi
+
+ fi
+ if $TESTALL || $TESTFPGACOMPRESS; then
+ echo -e "\n${C_BLUE}Testing fpgacompress:${C_NC} ${FPGACPMPRESSBIN:=./tools/fpga_compress/fpga_compress}"
+ if ! CheckFileExist "fpgacompress exists" "$FPGACPMPRESSBIN"; then break; fi
+ fi
+ if $TESTALL || $TESTMFKEY; then
+ echo -e "\n${C_BLUE}Testing mfkey:${C_NC} ${MFKEY32V2BIN:=./tools/mfkey/mfkey32v2} ${MFKEY64BIN:=./tools/mfkey/mfkey64}"
+ if ! CheckFileExist "mfkey32v2 exists" "$MFKEY32V2BIN"; then break; fi
+ if ! CheckFileExist "mfkey64 exists" "$MFKEY64BIN"; then break; fi
+ # Need a decent example for mfkey32...
+ if ! CheckExecute "mfkey32v2 test" "$MFKEY32V2BIN 12345678 1AD8DF2B 1D316024 620EF048 30D6CB07 C52077E2 837AC61A" "Found Key: \[a0a1a2a3a4a5\]"; then break; fi
+ if ! CheckExecute "mfkey64 test" "$MFKEY64BIN 9c599b32 82a4166c a1e458ce 6eea41e0 5cadf439" "Found Key: \[ffffffffffff\]"; then break; fi
+ if ! CheckExecute "mfkey64 long trace test" "$MFKEY64BIN 14579f69 ce844261 f8049ccb 0525c84f 9431cc40 7093df99 9972428ce2e8523f456b99c831e769dced09 8ca6827b ab797fd369e8b93a86776b40dae3ef686efd c3c381ba 49e2c9def4868d1777670e584c27230286f4 fbdcd7c1 4abd964b07d3563aa066ed0a2eac7f6312bf 9f9149ea" "Found Key: \[091e639cb715\]"; then break; fi
+ fi
+ if $TESTALL || $TESTNONCE2KEY; then
+ echo -e "\n${C_BLUE}Testing nonce2key:${C_NC} ${NONCE2KEYBIN:=./tools/nonce2key/nonce2key}"
+ if ! CheckFileExist "nonce2key exists" "$NONCE2KEYBIN"; then break; fi
+ if ! CheckExecute "nonce2key test" "$NONCE2KEYBIN e9cadd9c a8bf4a12 a020a8285858b090 050f010607060e07 5693be6c00000000" "key recovered: fc00018778f7"; then break; fi
+ fi
+ if $TESTALL || $TESTMFNONCEBRUTE; then
+ echo -e "\n${C_BLUE}Testing mf_nonce_brute:${C_NC} ${MFNONCEBRUTEBIN:=./tools/mf_nonce_brute/mf_nonce_brute}"
+ if ! CheckFileExist "mf_nonce_brute exists" "$MFNONCEBRUTEBIN"; then break; fi
+ if ! CheckExecute slow "mf_nonce_brute test" "$MFNONCEBRUTEBIN 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a" "Key.*: \[ffffffffffff\]"; then break; fi
+ fi
+ if $TESTALL || $TESTCLIENT; then
+ echo -e "\n${C_BLUE}Testing client:${C_NC} ${CLIENTBIN:=./client/proxmark3}"
+ if ! CheckFileExist "proxmark3 exists" "$CLIENTBIN"; then break; fi
+ echo -e "\n${C_BLUE}Testing basic help:${C_NC}"
+ if ! CheckExecute "proxmark help" "$CLIENTBIN -h" "wait"; then break; fi
+ if ! CheckExecute "proxmark help text ISO7816" "$CLIENTBIN -t 2>&1" "ISO7816"; then break; fi
+ if ! CheckExecute "proxmark help text hardnested" "$CLIENTBIN -t 2>&1" "hardnested"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing data manipulation:${C_NC}"
+ if ! CheckExecute "reveng readline test" "$CLIENTBIN -c 'reveng -h;reveng -D'" "CRC-64/GO-ISO"; then break; fi
+ if ! CheckExecute "reveng -g test" "$CLIENTBIN -c 'reveng -g abda202c'" "CRC-16/ISO-IEC-14443-3-A"; then break; fi
+ if ! CheckExecute "reveng -w test" "$CLIENTBIN -c 'reveng -w 8 -s 01020304e3 010204039d'" "CRC-8/SMBUS"; then break; fi
+ if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen t'" "Selftest OK"; then break; fi
+ if ! CheckExecute "trace load/list 14a" "$CLIENTBIN -c 'trace load traces/hf_mfu.trace; trace list 1;'" "READBLOCK(8)"; then break; fi
+ if ! CheckExecute "trace load/list x" "$CLIENTBIN -c 'trace load traces/hf_mfu.trace; trace list x 1;'" "0.0101840425"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing LF:${C_NC}"
+ if ! CheckExecute "lf EM4x05 test" "$CLIENTBIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
+ if ! CheckExecute "lf EM410x test" "$CLIENTBIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
+ if ! CheckExecute "lf VISA2000 test" "$CLIENTBIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
+ if ! CheckExecute "lf AWID test" "$CLIENTBIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
+ if ! CheckExecute "lf SECURAKEY test" "$CLIENTBIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
+ if ! CheckExecute "lf NEXWATCH test" "$CLIENTBIN -c 'data load traces/quadrakey-521512301.pm3;lf search 1 '" "NexWatch ID found"; then break; fi
+ if ! CheckExecute "lf KERI test" "$CLIENTBIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
+ if ! CheckExecute "lf HID Prox test" "$CLIENTBIN -c 'data load traces/hid-proxCardII-05512-11432784-1.pm3;lf search 1'" "HID Prox ID found"; then break; fi
+ if ! CheckExecute "lf PARADOX test" "$CLIENTBIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
+ if ! CheckExecute "lf PAC test" "$CLIENTBIN -c 'data load traces/pac-8E4C058E.pm3;lf search 1'" "PAC/Stanley ID found"; then break; fi
+ if ! CheckExecute "lf VIKING test" "$CLIENTBIN -c 'data load traces/Transit999-best.pm3;lf search 1'" "Viking ID found"; then break; fi
+ if ! CheckExecute "lf FDX-B test" "$CLIENTBIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
+ if ! CheckExecute "lf INDALA test" "$CLIENTBIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
+ if ! CheckExecute "lf FDX/BioThermo test" "$CLIENTBIN -c 'data load traces/lf_fdx_biothermo.pm3; lf fdx demo'" "95.2 F / 35.1 C"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing HF:${C_NC}"
+ if ! CheckExecute "hf mf offline text" "$CLIENTBIN -c 'hf mf'" "at_enc"; then break; fi
+ if ! CheckExecute slow "hf mf hardnested long test" "$CLIENTBIN -c 'hf mf hardnested t 1 000000000000'" "found:" "repeat" "ignore"; then break; fi
+ if ! CheckExecute slow "hf iclass long test" "$CLIENTBIN -c 'hf iclass loclass t l'" "verified ok"; then break; fi
+ if ! CheckExecute slow "emv long test" "$CLIENTBIN -c 'emv test -l'" "Test(s) \[ OK"; then break; fi
+ if ! $SLOWTESTS; then
+ if ! CheckExecute "hf iclass test" "$CLIENTBIN -c 'hf iclass loclass t'" "key diversification (ok)"; then break; fi
+ if ! CheckExecute "emv test" "$CLIENTBIN -c 'emv test'" "Test(s) \[ OK"; then break; fi
+ fi
+ fi
+ echo -e "\n${C_GREEN}Tests [OK]${C_NC}\n"
+ exit 0
+done
+echo -e "\n${C_RED}Tests [FAIL]${C_NC}\n"
+exit 1
From bcb0e5db4d0a80de456289a33df0287c3f46fb66 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 18:40:12 +0200
Subject: [PATCH 124/527] document make check
---
doc/md/Development/Maintainers.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index c3d0e4e29..af36dbbe2 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -72,6 +72,8 @@ On some architectures, pthread library is not present:
* `make client SKIPPTHREAD=1` to skip `-lpthread` at linker stage.
+Some unittests are available via `make check`, which is actually triggering individual targets as for `make install`.
+
`make install` is actually triggering the following individual targets which can be accessed individually:
* `make client/install`
@@ -89,4 +91,4 @@ On some architectures, pthread library is not present:
* SIM firmware
* udev rule on Linux
-Same logic for `make all`, `make clean`, `make uninstall`
+Same logic for `make all`, `make clean`, `make uninstall` and `make check`.
From 9e756c5957d8c1806abd492b0d5b959b407f5040 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Sat, 23 May 2020 12:26:33 +0200
Subject: [PATCH 125/527] chg: hf mf eload - made messages more clear.\n added
color to hf mf helptext
---
client/src/cmdhfmf.c | 160 ++++++++++++++++++++-----------------------
1 file changed, 76 insertions(+), 84 deletions(-)
diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c
index 560ed0a16..08a4f1781 100644
--- a/client/src/cmdhfmf.c
+++ b/client/src/cmdhfmf.c
@@ -48,8 +48,8 @@ static int usage_hf14_ice(void) {
PrintAndLogEx(NORMAL, " f save nonces to instead of hf-mf--nonces.bin");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf ice");
- PrintAndLogEx(NORMAL, " hf mf ice f nonces.bin");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ice"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ice f nonces.bin"));
return PM3_SUCCESS;
}
@@ -60,8 +60,8 @@ static int usage_hf14_dump(void) {
PrintAndLogEx(NORMAL, " f : data filename, if no given, UID will be used as filename");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf dump");
- PrintAndLogEx(NORMAL, " hf mf dump 4");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf dump"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf dump 4"));
return PM3_SUCCESS;
}
@@ -72,9 +72,9 @@ static int usage_hf14_mifare(void) {
PrintAndLogEx(NORMAL, " (Optional) target other block");
PrintAndLogEx(NORMAL, " (optional) target key type");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf darkside");
- PrintAndLogEx(NORMAL, " hf mf darkside 16");
- PrintAndLogEx(NORMAL, " hf mf darkside 16 B");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf darkside"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf darkside 16"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf darkside 16 B"));
return PM3_SUCCESS;
}
static int usage_hf14_mfsim(void) {
@@ -95,10 +95,10 @@ static int usage_hf14_mfsim(void) {
PrintAndLogEx(NORMAL, " e (Optional) Fill simulator keys from found keys");
PrintAndLogEx(NORMAL, " v (Optional) Verbose");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf sim u 0a0a0a0a");
- PrintAndLogEx(NORMAL, " hf mf sim u 11223344556677");
- PrintAndLogEx(NORMAL, " hf mf sim u 112233445566778899AA");
- PrintAndLogEx(NORMAL, " hf mf sim u 11223344 i x");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf sim u 0a0a0a0a"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf sim u 11223344556677"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf sim u 112233445566778899AA"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf sim u 11223344 i x"));
return PM3_SUCCESS;
}
/*
@@ -112,7 +112,7 @@ static int usage_hf14_mfsim(void) {
// PrintAndLogEx(NORMAL, " n/a e decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory");
PrintAndLogEx(NORMAL, " f decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");
PrintAndLogEx(NORMAL, "Example:");
- PrintAndLogEx(NORMAL, " hf mf sniff l d f");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf sniff l d f"));
return PM3_SUCCESS;
}
*/
@@ -127,10 +127,10 @@ static int usage_hf14_nested(void) {
PrintAndLogEx(NORMAL, " d write keys to binary file `hf-mf--key.bin`");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf nested 1 0 A FFFFFFFFFFFF -- key recovery against 1K, block 0, Key A using key FFFFFFFFFFFF");
- PrintAndLogEx(NORMAL, " hf mf nested 1 0 A FFFFFFFFFFFF t -- and transfer keys into emulator memory");
- PrintAndLogEx(NORMAL, " hf mf nested 1 0 A FFFFFFFFFFFF d -- or write keys to binary file ");
- PrintAndLogEx(NORMAL, " hf mf nested o 0 A FFFFFFFFFFFF 4 A -- one sector key recovery. Use block 0 Key A to find block 4 Key A");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf nested 1 0 A FFFFFFFFFFFF")" -- key recovery against 1K, block 0, Key A using key FFFFFFFFFFFF");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf nested 1 0 A FFFFFFFFFFFF t")" -- and transfer keys into emulator memory");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf nested 1 0 A FFFFFFFFFFFF d")" -- or write keys to binary file ");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf nested o 0 A FFFFFFFFFFFF 4 A")" -- one sector key recovery. Use block 0 Key A to find block 4 Key A");
return PM3_SUCCESS;
}
static int usage_hf14_staticnested(void) {
@@ -143,9 +143,9 @@ static int usage_hf14_staticnested(void) {
PrintAndLogEx(NORMAL, " d write keys to binary file `hf-mf--key.bin`");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf staticnested 1 0 A FFFFFFFFFFFF -- key recovery against 1K, block 0, Key A using key FFFFFFFFFFFF");
- PrintAndLogEx(NORMAL, " hf mf staticnested 1 0 A FFFFFFFFFFFF t -- and transfer keys into emulator memory");
- PrintAndLogEx(NORMAL, " hf mf staticnested 1 0 A FFFFFFFFFFFF d -- or write keys to binary file ");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf staticnested 1 0 A FFFFFFFFFFFF")" -- key recovery against 1K, block 0, Key A using key FFFFFFFFFFFF");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf staticnested 1 0 A FFFFFFFFFFFF t")" -- and transfer keys into emulator memory");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf staticnested 1 0 A FFFFFFFFFFFF d")" -- or write keys to binary file ");
return PM3_SUCCESS;
}
static int usage_hf14_hardnested(void) {
@@ -175,35 +175,17 @@ static int usage_hf14_hardnested(void) {
PrintAndLogEx(NORMAL, " i n = none (use CPU regular instruction set)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf hardnested 0 A FFFFFFFFFFFF 4 A");
- PrintAndLogEx(NORMAL, " hf mf hardnested 0 A FFFFFFFFFFFF 4 A w");
- PrintAndLogEx(NORMAL, " hf mf hardnested 0 A FFFFFFFFFFFF 4 A f nonces.bin w s");
- PrintAndLogEx(NORMAL, " hf mf hardnested r");
- PrintAndLogEx(NORMAL, " hf mf hardnested r a0a1a2a3a4a5");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A w"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A f nonces.bin w s"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested r"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested r a0a1a2a3a4a5"));
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Add the known target key to check if it is present in the remaining key space:");
- PrintAndLogEx(NORMAL, " hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF"));
return PM3_SUCCESS;
}
-/*
-static int usage_hf14_fixednested(void) {
- PrintAndLogEx(NORMAL, "Usage:");
- PrintAndLogEx(NORMAL, " all sectors: hf mf fixed [t,d]");
- PrintAndLogEx(NORMAL, " one sector: hf mf fixed o [t]");
- PrintAndLogEx(NORMAL, "Options:");
- PrintAndLogEx(NORMAL, " h this help");
- PrintAndLogEx(NORMAL, " card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, - 1K");
- PrintAndLogEx(NORMAL, " t transfer keys into emulator memory");
- PrintAndLogEx(NORMAL, " d write keys to binary file `hf-mf--key.bin`");
- PrintAndLogEx(NORMAL, "");
- PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf fixed 1 0 A FFFFFFFFFFFF -- key recovery against 1K, block 0, Key A using key FFFFFFFFFFFF");
- PrintAndLogEx(NORMAL, " hf mf fixed 1 0 A FFFFFFFFFFFF t -- and transfer keys into emulator memory");
- PrintAndLogEx(NORMAL, " hf mf fixed 1 0 A FFFFFFFFFFFF d -- or write keys to binary file ");
- PrintAndLogEx(NORMAL, " hf mf fixed o 0 A FFFFFFFFFFFF 4 A -- one sector key recovery. Use block 0 Key A to find block 4 Key A");
- return PM3_SUCCESS;
-}
-*/
+
static int usage_hf14_autopwn(void) {
PrintAndLogEx(NORMAL, "Usage:");
PrintAndLogEx(NORMAL, " hf mf autopwn [k] ");
@@ -238,10 +220,10 @@ static int usage_hf14_autopwn(void) {
PrintAndLogEx(NORMAL, " i n = none (use CPU regular instruction set)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf autopwn -- target Mifare classic card with default keys");
- PrintAndLogEx(NORMAL, " hf mf autopwn * 1 f mfc_default_keys -- target Mifare classic card (size 1k) with default dictionary");
- PrintAndLogEx(NORMAL, " hf mf autopwn k 0 A FFFFFFFFFFFF -- target Mifare classic card with Sector0 typeA with known key 'FFFFFFFFFFFF'");
- PrintAndLogEx(NORMAL, " hf mf autopwn k 0 A FFFFFFFFFFFF * 1 f mfc_default_keys -- this command combines the two above (reduce the need for nested / hardnested attacks, by using a dictionary)");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf autopwn")" -- target Mifare classic card with default keys");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf autopwn * 1 f mfc_default_keys")" -- target Mifare classic card (size 1k) with default dictionary");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf autopwn k 0 A FFFFFFFFFFFF")" -- target Mifare classic card with Sector0 typeA with known key 'FFFFFFFFFFFF'");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf autopwn k 0 A FFFFFFFFFFFF * 1 f mfc_default_keys")" -- this command combines the two above (reduce the need for nested / hardnested attacks, by using a dictionary)");
return PM3_SUCCESS;
}
static int usage_hf14_chk(void) {
@@ -301,7 +283,7 @@ static int usage_hf14_keybrute(void) {
PrintAndLogEx(NORMAL, " target key type");
PrintAndLogEx(NORMAL, " candidate key from mf_nonce_brute tool");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf keybrute 1 A 000011223344");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf keybrute 1 A 000011223344"));
return 0;
}
*/
@@ -314,10 +296,10 @@ static int usage_hf14_restore(void) {
PrintAndLogEx(NORMAL, " f : data filename, specific the full filename of data file");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf restore -- read the UID from tag first, then restore from hf-mf--key.bin and and hf-mf--dump.bin");
- PrintAndLogEx(NORMAL, " hf mf restore 1 u 12345678 -- restore from hf-mf-12345678-key.bin and hf-mf-12345678-dump.bin");
- PrintAndLogEx(NORMAL, " hf mf restore 1 u 12345678 k dumpkey.bin -- restore from dumpkey.bin and hf-mf-12345678-dump.bin");
- PrintAndLogEx(NORMAL, " hf mf restore 4 -- read the UID from tag with 4K memory first, then restore from hf-mf--key.bin and and hf-mf--dump.bin");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf restore") " -- read the UID from tag first, then restore from hf-mf--key.bin and and hf-mf--dump.bin");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf restore 1 u 12345678") " -- restore from hf-mf-12345678-key.bin and hf-mf-12345678-dump.bin");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf restore 1 u 12345678 k dumpkey.bin") " -- restore from dumpkey.bin and hf-mf-12345678-dump.bin");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf restore 4") " -- read the UID from tag with 4K memory first, then restore from hf-mf--key.bin and and hf-mf--dump.bin");
return PM3_SUCCESS;
}
static int usage_hf14_decryptbytes(void) {
@@ -330,26 +312,28 @@ static int usage_hf14_decryptbytes(void) {
PrintAndLogEx(NORMAL, " encrypted tag response");
PrintAndLogEx(NORMAL, " encrypted data, taken directly after at_enc and forward");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf decrypt b830049b 9248314a 9280e203 41e586f9\n");
- PrintAndLogEx(NORMAL, " this sample decrypts 41e586f9 -> 3003999a Annotated: 30 03 [99 9a] auth block 3 [crc]");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf decrypt b830049b 9248314a 9280e203 41e586f9"));
+ PrintAndLogEx(NORMAL, "\n this sample decrypts 41e586f9 -> 3003999a Annotated: 30 03 [99 9a] auth block 3 [crc]");
return PM3_SUCCESS;
}
static int usage_hf14_eget(void) {
PrintAndLogEx(NORMAL, "Usage: hf mf eget ");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf eget 0 ");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf eget 0"));
return PM3_SUCCESS;
}
static int usage_hf14_eclr(void) {
PrintAndLogEx(NORMAL, "It set card emulator memory to empty data blocks and key A/B FFFFFFFFFFFF \n");
PrintAndLogEx(NORMAL, "Usage: hf mf eclr");
+ PrintAndLogEx(NORMAL, "Examples:");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf eclr"));
return PM3_SUCCESS;
}
static int usage_hf14_eset(void) {
PrintAndLogEx(NORMAL, "Usage: hf mf eset ");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf eset 1 000102030405060708090a0b0c0d0e0f ");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf eset 1 000102030405060708090a0b0c0d0e0f"));
return PM3_SUCCESS;
}
static int usage_hf14_eload(void) {
@@ -358,8 +342,8 @@ static int usage_hf14_eload(void) {
PrintAndLogEx(NORMAL, " [card memory]: 0 = 320 bytes (Mifare Mini), 1 = 1K (default), 2 = 2K, 4 = 4K, u = UL");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf eload filename");
- PrintAndLogEx(NORMAL, " hf mf eload 4 filename");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf eload filename"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf eload 4 filename"));
return PM3_SUCCESS;
}
static int usage_hf14_esave(void) {
@@ -368,9 +352,9 @@ static int usage_hf14_esave(void) {
PrintAndLogEx(NORMAL, " [card memory]: 0 = 320 bytes (Mifare Mini), 1 = 1K (default), 2 = 2K, 4 = 4K");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf esave ");
- PrintAndLogEx(NORMAL, " hf mf esave 4");
- PrintAndLogEx(NORMAL, " hf mf esave 4 filename");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf esave"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf esave 4"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf esave 4 filename"));
return PM3_SUCCESS;
}
static int usage_hf14_ecfill(void) {
@@ -380,8 +364,8 @@ static int usage_hf14_ecfill(void) {
PrintAndLogEx(NORMAL, " [card memory]: 0 = 320 bytes (Mifare Mini), 1 = 1K (default), 2 = 2K, 4 = 4K");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf ecfill A");
- PrintAndLogEx(NORMAL, " hf mf ecfill A 4");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ecfill A"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ecfill A 4"));
return PM3_SUCCESS;
}
static int usage_hf14_ekeyprn(void) {
@@ -393,8 +377,8 @@ static int usage_hf14_ekeyprn(void) {
PrintAndLogEx(NORMAL, " d write keys to binary file `hf-mf--key.bin`");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf ekeyprn 1");
- PrintAndLogEx(NORMAL, " hf mf ekeyprn d");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ekeyprn 1"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ekeyprn d"));
return PM3_SUCCESS;
}
@@ -409,8 +393,8 @@ static int usage_hf14_csetuid(void) {
PrintAndLogEx(NORMAL, " ATQA 4 hex symbols");
PrintAndLogEx(NORMAL, " SAK 2 hex symbols");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf csetuid 01020304");
- PrintAndLogEx(NORMAL, " hf mf csetuid 01020304 0004 08 w");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csetuid 01020304"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csetuid 01020304 0004 08 w"));
return PM3_SUCCESS;
}
static int usage_hf14_csetblk(void) {
@@ -423,8 +407,8 @@ static int usage_hf14_csetblk(void) {
PrintAndLogEx(NORMAL, " block number");
PrintAndLogEx(NORMAL, " block data to write (32 hex symbols)");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf csetblk 1 01020304050607080910111213141516");
- PrintAndLogEx(NORMAL, " hf mf csetblk 1 01020304050607080910111213141516 w");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csetblk 1 01020304050607080910111213141516"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csetblk 1 01020304050607080910111213141516 w"));
return PM3_SUCCESS;
}
static int usage_hf14_cload(void) {
@@ -439,8 +423,8 @@ static int usage_hf14_cload(void) {
PrintAndLogEx(NORMAL, " b load card with data from binary file");
PrintAndLogEx(NORMAL, " load card with data from eml file");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf cload mydump");
- PrintAndLogEx(NORMAL, " hf mf cload e");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf cload mydump"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf cload e"));
return PM3_SUCCESS;
}
static int usage_hf14_cgetblk(void) {
@@ -451,7 +435,7 @@ static int usage_hf14_cgetblk(void) {
PrintAndLogEx(NORMAL, " h this help");
PrintAndLogEx(NORMAL, " block number");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf cgetblk 1");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf cgetblk 1"));
return PM3_SUCCESS;
}
static int usage_hf14_cgetsc(void) {
@@ -462,7 +446,7 @@ static int usage_hf14_cgetsc(void) {
PrintAndLogEx(NORMAL, " h this help");
PrintAndLogEx(NORMAL, " sector number");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf cgetsc 0");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf cgetsc 0"));
return PM3_SUCCESS;
}
static int usage_hf14_csave(void) {
@@ -478,9 +462,9 @@ static int usage_hf14_csave(void) {
PrintAndLogEx(NORMAL, " o save data to file");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf csave u 1");
- PrintAndLogEx(NORMAL, " hf mf csave e 1");
- PrintAndLogEx(NORMAL, " hf mf csave 4 o filename");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csave u 1"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csave e 1"));
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf csave 4 o filename"));
return PM3_SUCCESS;
}
static int usage_hf14_nack(void) {
@@ -491,7 +475,7 @@ static int usage_hf14_nack(void) {
PrintAndLogEx(NORMAL, " h this help");
PrintAndLogEx(NORMAL, " v verbose");
PrintAndLogEx(NORMAL, "Examples:");
- PrintAndLogEx(NORMAL, " hf mf nack");
+ PrintAndLogEx(NORMAL, _YELLOW_(" hf mf nack"));
return PM3_SUCCESS;
}
@@ -3727,6 +3711,11 @@ int CmdHF14AMfELoad(const char *Cmd) {
free(data);
return res;
}
+
+ // update expected blocks to match converted data.
+ if (numBlocks != datalen / 4) {
+ numBlocks = datalen / 4;
+ }
}
PrintAndLogEx(INFO, "Uploading to emulator memory");
@@ -3752,24 +3741,27 @@ int CmdHF14AMfELoad(const char *Cmd) {
counter += blockWidth;
datalen -= blockWidth;
}
+ free(data);
PrintAndLogEx(NORMAL, "\n");
- // Ultralight /Ntag
if (blockWidth == 4) {
+ PrintAndLogEx(HINT, "You are ready to simulate. See " _YELLOW_("`hf mfu sim h`"));
+ // MFU / NTAG
if ((blockNum != numBlocks)) {
- PrintAndLogEx(FAILED, "Warning, Ultralight/Ntag file content, Loaded %d blocks into emulator memory", blockNum);
- free(data);
+ PrintAndLogEx(WARNING, "Warning, Ultralight/Ntag file content, Loaded %d blocks of expected %d blocks into emulator memory", blockNum, numBlocks);
return PM3_SUCCESS;
}
} else {
+ PrintAndLogEx(HINT, "You are ready to simulate. See " _YELLOW_("`hf mf sim h`"));
+ // MFC
if ((blockNum != numBlocks)) {
- PrintAndLogEx(FAILED, "Error, file content, Only loaded %d blocks, must be %d blocks into emulator memory", blockNum, numBlocks);
- free(data);
+ PrintAndLogEx(WARNING, "Error, file content, Only loaded %d blocks, must be %d blocks into emulator memory", blockNum, numBlocks);
+
return PM3_SUCCESS;
}
+
}
PrintAndLogEx(SUCCESS, "Done");
- free(data);
return PM3_SUCCESS;
}
From 6d33c0b784e33b344f31217423d97f9c528b9d37 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Fri, 22 May 2020 19:20:44 +0200
Subject: [PATCH 126/527] Bring hitag2crack tools in main Makefiles
---
Makefile | 13 +-
doc/md/Development/Maintainers.md | 4 +
tools/hitag2crack/Makefile | 33 +++++
tools/hitag2crack/common/ht2crackutils.h | 5 +
tools/hitag2crack/crack2/Makefile | 37 +++---
.../hitag2crack/crack2/ht2crack2buildtable.c | 50 ++++----
tools/hitag2crack/crack2/ht2crack2gentest.c | 4 +-
tools/hitag2crack/crack2/ht2crack2search.c | 16 +--
tools/hitag2crack/crack3/.gitignore | 5 +-
tools/hitag2crack/crack3/Makefile | 32 ++---
tools/hitag2crack/crack3/README.md | 4 +-
tools/hitag2crack/crack3/ht2crack3.c | 12 +-
.../crack3/{ht2test.c => ht2crack3test.c} | 2 +-
tools/hitag2crack/crack4/Makefile | 30 ++---
tools/hitag2crack/crack4/ht2crack4.c | 57 +++++----
tools/hitag2crack/crack5/Makefile | 29 +++--
tools/hitag2crack/crack5/ht2crack5.c | 10 +-
tools/hitag2crack/crack5gpu/Makefile | 42 ++++---
.../crack5gpu/{ht2crack5.c => ht2crack5gpu.c} | 6 +-
tools/hitag2crack/hitag2_gen_nRaR.py | 118 ++++++++++++++++++
tools/pm3_tests.sh | 92 +++++++++++++-
21 files changed, 433 insertions(+), 168 deletions(-)
create mode 100644 tools/hitag2crack/Makefile
rename tools/hitag2crack/crack3/{ht2test.c => ht2crack3test.c} (96%)
rename tools/hitag2crack/crack5gpu/{ht2crack5.c => ht2crack5gpu.c} (98%)
create mode 100755 tools/hitag2crack/hitag2_gen_nRaR.py
diff --git a/Makefile b/Makefile
index d111d01fc..f7a434d3b 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,8 @@ ifneq (,$(DESTDIR))
endif
all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% fpga_compress/%
+# hitag2crack toolsuite is not yet integrated in "all", it must be called explicitly: "make hitag2crack"
+#all clean install uninstall check: %: hitag2crack/%
INSTALLTOOLS=pm3_eml2lower.sh pm3_eml2upper.sh pm3_mfdread.py pm3_mfd2eml.py pm3_eml2mfd.py findbits.py rfidtest.pl xorcheck.py
INSTALLSIMFW=sim011.bin sim011.sha512.txt
@@ -103,6 +105,9 @@ client/check: FORCE
recovery/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
+hitag2crack/check: FORCE
+ $(info [*] CHECK $(patsubst %/check,%,$@))
+ $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
common/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
@@ -135,9 +140,12 @@ recovery/install: bootrom/all armsrc/all
recovery/%: FORCE cleanifplatformchanged
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
+hitag2crack/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C tools/hitag2crack $(patsubst hitag2crack/%,%,$@) DESTDIR=$(MYDESTDIR)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
-.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute style miscchecks release FORCE udev accessrights cleanifplatformchanged
+.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute hitag2crack style miscchecks release FORCE udev accessrights cleanifplatformchanged
help:
@echo "Multi-OS Makefile"
@@ -157,6 +165,7 @@ help:
@echo "+ mfkey - Make tools/mfkey"
@echo "+ nonce2key - Make tools/nonce2key"
@echo "+ mf_nonce_brute - Make tools/mf_nonce_brute"
+ @echo "+ hitag2crack - Make tools/hitag2crack"
@echo "+ fpga_compress - Make tools/fpga_compress"
@echo
@echo "+ style - Apply some automated source code formatting rules"
@@ -193,6 +202,8 @@ mf_nonce_brute: mf_nonce_brute/all
fpga_compress: fpga_compress/all
+hitag2crack: hitag2crack/all
+
newtarbin:
$(RM) proxmark3-$(platform)-bin.tar proxmark3-$(platform)-bin.tar.gz
@touch proxmark3-$(platform)-bin.tar
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index af36dbbe2..09cddede7 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -72,6 +72,10 @@ On some architectures, pthread library is not present:
* `make client SKIPPTHREAD=1` to skip `-lpthread` at linker stage.
+One tool requires a CUDA compilation environment, it can be skipped as well:
+
+* `make hitag2crack SKIPGPU=1` to skip ht2crack5gpu tool when compiling the hitag2crack toolsuite.
+
Some unittests are available via `make check`, which is actually triggering individual targets as for `make install`.
`make install` is actually triggering the following individual targets which can be accessed individually:
diff --git a/tools/hitag2crack/Makefile b/tools/hitag2crack/Makefile
new file mode 100644
index 000000000..c36d18b30
--- /dev/null
+++ b/tools/hitag2crack/Makefile
@@ -0,0 +1,33 @@
+# Must be called before any Makefile include
+ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
+
+include ../../Makefile.defs
+
+all clean install uninstall check: %: crack2/% crack3/% crack4/% crack5/%
+ifneq ($(SKIPGPU),1)
+all clean install uninstall check: %: crack5gpu/%
+endif
+
+crack2/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C crack2 $(patsubst crack2/%,%,$@) DESTDIR=$(MYDESTDIR)
+
+crack3/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C crack3 $(patsubst crack3/%,%,$@) DESTDIR=$(MYDESTDIR)
+
+crack4/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C crack4 $(patsubst crack4/%,%,$@) DESTDIR=$(MYDESTDIR)
+
+crack5/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C crack5 $(patsubst crack5/%,%,$@) DESTDIR=$(MYDESTDIR)
+
+crack5gpu/%: FORCE
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C crack5gpu $(patsubst crack5gpu/%,%,$@) DESTDIR=$(MYDESTDIR)
+
+FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
+
+.phony: crack2 crack3 crack4 crack5 crack5gpu FORCE
diff --git a/tools/hitag2crack/common/ht2crackutils.h b/tools/hitag2crack/common/ht2crackutils.h
index 41c3a07c2..16f4fab5b 100644
--- a/tools/hitag2crack/common/ht2crackutils.h
+++ b/tools/hitag2crack/common/ht2crackutils.h
@@ -1,3 +1,6 @@
+#ifndef HT2CRACKUTILS_H
+#define HT2CRACKUTILS_H
+
#include
#include
#include
@@ -41,3 +44,5 @@ void buildlfsr(Hitag_State *hstate);
#define rev64(X) (rev32(X) + (rev32(X >> 32) << 32))
unsigned long hexreversetoulong(char *hex);
unsigned long long hexreversetoulonglong(char *hex);
+
+#endif /* HT2CRACKUTILS_H */
diff --git a/tools/hitag2crack/crack2/Makefile b/tools/hitag2crack/crack2/Makefile
index 4794d6ec4..e8dbc4bac 100644
--- a/tools/hitag2crack/crack2/Makefile
+++ b/tools/hitag2crack/crack2/Makefile
@@ -1,23 +1,22 @@
-CFLAGS?=-Wall -Werror -O3
-# Linux libs
-LIBS=-pthread -D_GNU_SOURCE
-# Mac libs
-# LIBS=
-VPATH=../common
-INC=-I ../common
+MYSRCPATHS = ../common
+MYSRCS = ht2crackutils.c hitagcrypto.c
+MYINCLUDES =-I ../common
+MYCFLAGS = -D_GNU_SOURCE
+MYDEFS =
+MYLDLIBS = -lpthread
-all: ht2crack2buildtable.c ht2crack2search.c ht2crack2gentest.c hitagcrypto.o ht2crackutils.o
- $(CC) $(CFLAGS) $(INC) -o ht2crack2buildtable ht2crack2buildtable.c hitagcrypto.o ht2crackutils.o $(LIBS)
- $(CC) $(CFLAGS) $(INC) -o ht2crack2search ht2crack2search.c hitagcrypto.o ht2crackutils.o $(LIBS)
- $(CC) $(CFLAGS) $(INC) -o ht2crack2gentest ht2crack2gentest.c hitagcrypto.o ht2crackutils.o $(LIBS)
+BINS = ht2crack2buildtable ht2crack2search ht2crack2gentest
+INSTALLTOOLS = $(BINS)
-ht2crackutils.o: ht2crackutils.c ht2crackutils.h
- $(CC) $(CFLAGS) -c $<
+include ../../../Makefile.host
-hitagcrypto.o: hitagcrypto.c hitagcrypto.h
- $(CC) $(CFLAGS) -c $<
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
-clean:
- rm -rf *.o ht2crack2buildtable ht2crack2search ht2crack2gentest
-
-fresh: clean all
+ht2crack2buildtable : $(OBJDIR)/ht2crack2buildtable.o $(MYOBJS)
+ht2crack2search : $(OBJDIR)/ht2crack2search.o $(MYOBJS)
+ht2crack2gentest : $(OBJDIR)/ht2crack2gentest.o $(MYOBJS)
diff --git a/tools/hitag2crack/crack2/ht2crack2buildtable.c b/tools/hitag2crack/crack2/ht2crack2buildtable.c
index 8bf67a8ac..c45768998 100644
--- a/tools/hitag2crack/crack2/ht2crack2buildtable.c
+++ b/tools/hitag2crack/crack2/ht2crack2buildtable.c
@@ -4,7 +4,7 @@
*/
#include "ht2crackutils.h"
-
+#include
// DATAMAX is the size of each bucket (bytes). There are 65536 buckets so choose a value such that
// DATAMAX * 65536 < RAM available. For ex, if you want to use 12GB of RAM (for a 16GB machine
@@ -53,63 +53,63 @@ uint64_t d2[48];
int nsteps2;
// create table entry
-void create_table(struct table *t, int d1, int d2) {
- if (!t) {
+static void create_table(struct table *tt, int d_1, int d_2) {
+ if (!tt) {
printf("create_table: t is NULL\n");
exit(1);
}
// create some space
- t->data = (unsigned char *)malloc(DATAMAX);
- if (!(t->data)) {
+ tt->data = (unsigned char *)malloc(DATAMAX);
+ if (!(tt->data)) {
printf("create_table: cannot malloc data\n");
exit(1);
}
// set data ptr to start of data table
- t->ptr = t->data;
+ tt->ptr = tt->data;
// init the mutex
- if (pthread_mutex_init(&(t->mutex), NULL)) {
+ if (pthread_mutex_init(&(tt->mutex), NULL)) {
printf("create_table: cannot init mutex\n");
exit(1);
}
// create the path
-// sprintf(t->path, "/Volumes/2tb/%02X/%02X.bin", d1 & 0xff, d2 & 0xff);
- sprintf(t->path, "table/%02x/%02x.bin", d1 & 0xff, d2 & 0xff);
+// sprintf(tt->path, "/Volumes/2tb/%02X/%02X.bin", d_1 & 0xff, d_2 & 0xff);
+ sprintf(tt->path, "table/%02x/%02x.bin", d_1 & 0xff, d_2 & 0xff);
}
// create all table entries
-void create_tables(struct table *t) {
+static void create_tables(struct table *tt) {
int i, j;
- if (!t) {
+ if (!tt) {
printf("create_tables: t is NULL\n");
exit(1);
}
for (i = 0; i < 0x100; i++) {
for (j = 0; j < 0x100; j++) {
- create_table(t + ((i * 0x100) + j), i, j);
+ create_table(tt + ((i * 0x100) + j), i, j);
}
}
}
// free the table memory
-void free_tables(struct table *t) {
+static void free_tables(struct table *tt) {
int i;
struct table *ttmp;
- if (!t) {
+ if (!tt) {
printf("free_tables: t is NULL\n");
exit(1);
}
for (i = 0; i < 0x10000; i++) {
- ttmp = t + i;
+ ttmp = tt + i;
free(ttmp->data);
}
}
@@ -117,7 +117,7 @@ void free_tables(struct table *t) {
// write (partial) table to file
-void writetable(struct table *t1) {
+static void writetable(struct table *t1) {
int fd;
if (debug) printf("writetable %s\n", t1->path);
@@ -142,7 +142,7 @@ void writetable(struct table *t1) {
// store value in table
-void store(unsigned char *data) {
+static void store(unsigned char *data) {
unsigned char d_1, d_2;
int offset;
struct table *t1;
@@ -194,7 +194,7 @@ void store(unsigned char *data) {
}
// writes the ks (keystream) and s (state)
-void write_ks_s(uint32_t ks1, uint32_t ks2, uint64_t shiftreg) {
+static void write_ks_s(uint32_t ks1, uint32_t ks2, uint64_t shiftreg) {
unsigned char buf[16];
// create buffer
@@ -209,7 +209,7 @@ void write_ks_s(uint32_t ks1, uint32_t ks2, uint64_t shiftreg) {
// builds the di table for jumping
-void builddi(int steps, int table) {
+static void builddi(int steps, int table) {
uint64_t statemask;
int i;
Hitag_State mystate;
@@ -241,7 +241,7 @@ void builddi(int steps, int table) {
}
// jump function - quickly jumps a load of steps
-void jumpnsteps(Hitag_State *hstate, int table) {
+static void jumpnsteps(Hitag_State *hstate, int table) {
uint64_t output = 0;
uint64_t bitmask;
int i;
@@ -277,14 +277,14 @@ void jumpnsteps(Hitag_State *hstate, int table) {
// thread to build a part of the table
-void *buildtable(void *d) {
+static void *buildtable(void *dd) {
Hitag_State hstate;
Hitag_State hstate2;
unsigned long i;
unsigned long maxentries = 1;
uint32_t ks1;
uint32_t ks2;
- int index = (int)(long)d;
+ int index = (int)(long)dd;
int tnum = NUM_BUILD_THREADS;
/* set random state */
@@ -334,7 +334,7 @@ void *buildtable(void *d) {
// make 'table/' (unsorted) and 'sorted/' dir structures
-void makedirs() {
+static void makedirs(void) {
char path[32];
int i;
@@ -368,7 +368,7 @@ static int datacmp(const void *p1, const void *p2, void *dummy) {
return memcmp(d_1, d_2, DATASIZE);
}
-void *sorttable(void *d) {
+static void *sorttable(void *dd) {
int i, j;
int fdin;
int fdout;
@@ -378,7 +378,7 @@ void *sorttable(void *d) {
struct stat filestat;
unsigned char *table = NULL;
uint64_t numentries = 0;
- int index = (int)(long)d;
+ int index = (int)(long)dd;
int space = 0x100 / NUM_SORT_THREADS;
// create table - 50MB should be enough
diff --git a/tools/hitag2crack/crack2/ht2crack2gentest.c b/tools/hitag2crack/crack2/ht2crack2gentest.c
index 0f255a5b6..cc8d1e94e 100644
--- a/tools/hitag2crack/crack2/ht2crack2gentest.c
+++ b/tools/hitag2crack/crack2/ht2crack2gentest.c
@@ -5,7 +5,7 @@
#include "ht2crackutils.h"
-int makerandom(char *hex, unsigned int len, int fd) {
+static int makerandom(char *hex, unsigned int len, int fd) {
unsigned char raw[32];
int i;
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
int urandomfd;
if (argc < 2) {
- printf("ht2crack2gentest number\n");
+ printf("%s number\n", argv[0]);
exit(1);
}
diff --git a/tools/hitag2crack/crack2/ht2crack2search.c b/tools/hitag2crack/crack2/ht2crack2search.c
index 16a2e00b8..d339f878f 100644
--- a/tools/hitag2crack/crack2/ht2crack2search.c
+++ b/tools/hitag2crack/crack2/ht2crack2search.c
@@ -23,7 +23,7 @@ static int datacmp(const void *p1, const void *p2) {
return memcmp(d1, d2, DATASIZE - 6);
}
-int loadrngdata(struct rngdata *r, char *file) {
+static int loadrngdata(struct rngdata *r, char *file) {
int fd;
int i, j;
int nibble;
@@ -90,7 +90,7 @@ int loadrngdata(struct rngdata *r, char *file) {
return 1;
}
-int makecand(unsigned char *c, struct rngdata *r, int bitoffset) {
+static int makecand(unsigned char *c, struct rngdata *r, int bitoffset) {
int bytenum;
int bitnum;
int i;
@@ -116,7 +116,7 @@ int makecand(unsigned char *c, struct rngdata *r, int bitoffset) {
// test the candidate against the next or previous rng data
-int testcand(unsigned char *f, unsigned char *rt, int fwd) {
+static int testcand(unsigned char *f, unsigned char *rt, int fwd) {
Hitag_State hstate;
int i;
uint32_t ks1;
@@ -154,7 +154,7 @@ int testcand(unsigned char *f, unsigned char *rt, int fwd) {
}
}
-int searchcand(unsigned char *c, unsigned char *rt, int fwd, unsigned char *m, unsigned char *s) {
+static int searchcand(unsigned char *c, unsigned char *rt, int fwd, unsigned char *m, unsigned char *s) {
int fd;
struct stat filestat;
char file[64];
@@ -222,7 +222,7 @@ int searchcand(unsigned char *c, unsigned char *rt, int fwd, unsigned char *m, u
}
-int findmatch(struct rngdata *r, unsigned char *outmatch, unsigned char *outstate, int *bitoffset) {
+static int findmatch(struct rngdata *r, unsigned char *outmatch, unsigned char *outstate, int *bitoffset) {
int i;
int bitlen;
unsigned char cand[6];
@@ -276,7 +276,7 @@ int findmatch(struct rngdata *r, unsigned char *outmatch, unsigned char *outstat
-void rollbackrng(Hitag_State *hstate, unsigned char *s, int offset) {
+static void rollbackrng(Hitag_State *hstate, unsigned char *s, int offset) {
int i;
if (!s) {
@@ -305,7 +305,7 @@ void rollbackrng(Hitag_State *hstate, unsigned char *s, int offset) {
}
-uint64_t recoverkey(Hitag_State *hstate, char *uidstr, char *nRstr) {
+static uint64_t recoverkey(Hitag_State *hstate, char *uidstr, char *nRstr) {
uint64_t key;
uint64_t keyupper;
uint32_t uid;
@@ -368,7 +368,7 @@ int main(int argc, char *argv[]) {
int i;
if (argc < 4) {
- printf("ht2crack2search rngdatafile UID nR\n");
+ printf("%s rngdatafile UID nR\n", argv[0]);
exit(1);
}
diff --git a/tools/hitag2crack/crack3/.gitignore b/tools/hitag2crack/crack3/.gitignore
index c993f2fe3..adf433d08 100644
--- a/tools/hitag2crack/crack3/.gitignore
+++ b/tools/hitag2crack/crack3/.gitignore
@@ -1,6 +1,5 @@
ht2crack3
-ht2test
+ht2crack3test
ht2crack3.exe
-ht2test.exe
-
+ht2crack3test.exe
diff --git a/tools/hitag2crack/crack3/Makefile b/tools/hitag2crack/crack3/Makefile
index 318b5db78..010b6151c 100644
--- a/tools/hitag2crack/crack3/Makefile
+++ b/tools/hitag2crack/crack3/Makefile
@@ -1,19 +1,21 @@
-CFLAGS?=-Wall -Werror -O3
-LIBS=
-VPATH=../common
-INC=-I ../common
+MYSRCPATHS = ../common
+MYSRCS = ht2crackutils.c hitagcrypto.c
+MYINCLUDES =-I ../common
+MYCFLAGS = -D_GNU_SOURCE
+MYDEFS =
+MYLDLIBS = -lpthread
-all: ht2crack3.c ht2test.c hitagcrypto.o ht2crackutils.o
- $(CC) $(CFLAGS) $(INC) -o ht2crack3 $< hitagcrypto.o ht2crackutils.o -lpthread $(LIBS)
- $(CC) $(CFLAGS) $(INC) -o ht2test ht2test.c hitagcrypto.o ht2crackutils.o $(LIBS)
+BINS = ht2crack3 ht2crack3test
+INSTALLTOOLS = $(BINS)
-ht2crackutils.o: ht2crackutils.c ht2crackutils.h
- $(CC) $(CFLAGS) -c $<
+include ../../../Makefile.host
-hitagcrypto.o: hitagcrypto.c hitagcrypto.h
- $(CC) $(CFLAGS) -c $<
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
-clean:
- rm -rf *.o ht2crack3 ht2test
-
-fresh: clean all
+ht2crack3 : $(OBJDIR)/ht2crack3.o $(MYOBJS)
+ht2crack3test : $(OBJDIR)/ht2crack3test.o $(MYOBJS)
diff --git a/tools/hitag2crack/crack3/README.md b/tools/hitag2crack/crack3/README.md
index 57d5d2aa8..955775a62 100644
--- a/tools/hitag2crack/crack3/README.md
+++ b/tools/hitag2crack/crack3/README.md
@@ -31,9 +31,9 @@ Tests
If you happen to know the key and want to check that all your nR aR values
are valid (for high-powered demonstrations only, really) then you can use
-the ht2test program to check them. It's otherwise massively pointless and a
+the ht2crack3test program to check them. It's otherwise massively pointless and a
complete waste of space.
```
-./ht2test NRARFILE KEY UID
+./ht2crack3test NRARFILE KEY UID
```
diff --git a/tools/hitag2crack/crack3/ht2crack3.c b/tools/hitag2crack/crack3/ht2crack3.c
index 4f481fbf7..b54c7b000 100644
--- a/tools/hitag2crack/crack3/ht2crack3.c
+++ b/tools/hitag2crack/crack3/ht2crack3.c
@@ -65,7 +65,7 @@ static uint32_t hitag2_crypt(uint64_t s) {
// this function is a modification of the filter function f, based heavily
// on the hitag2_crypt function in Rfidler
-int fnP(uint64_t klowery) {
+static int fnP(uint64_t klowery) {
const uint32_t ht2_function4a = 0x2C79; // 0010 1100 0111 1001
const uint32_t ht2_function4b = 0x6671; // 0110 0110 0111 0001
const uint32_t ht2_function4p = 0xAE83; // 1010 1110 1000 0011
@@ -84,7 +84,7 @@ int fnP(uint64_t klowery) {
}
// comparison function for sorting/searching Tklower entries
-int Tk_cmp(const void *v1, const void *v2) {
+static int Tk_cmp(const void *v1, const void *v2) {
const struct Tklower *Tk1 = (struct Tklower *)v1;
const struct Tklower *Tk2 = (struct Tklower *)v2;
@@ -98,7 +98,7 @@ int Tk_cmp(const void *v1, const void *v2) {
}
// test for bad guesses of kmiddle
-int is_kmiddle_badguess(uint64_t z, struct Tklower *Tk, int max, int aR0) {
+static int is_kmiddle_badguess(uint64_t z, struct Tklower *Tk, int max, int aR0) {
struct Tklower *result, target;
@@ -122,7 +122,7 @@ int is_kmiddle_badguess(uint64_t z, struct Tklower *Tk, int max, int aR0) {
}
// function to test if a partial key is valid
-int testkey(uint64_t *out, uint64_t uid, uint64_t pkey, uint64_t nR, uint64_t aR) {
+static int testkey(uint64_t *out, uint64_t uid, uint64_t pkey, uint64_t nR, uint64_t aR) {
uint64_t kupper;
uint64_t key;
Hitag_State hstate;
@@ -178,7 +178,7 @@ int testkey(uint64_t *out, uint64_t uid, uint64_t pkey, uint64_t nR, uint64_t aR
// effectively work out candidates for the lower 34 bits of the key.
-void *crack(void *d) {
+static void *crack(void *d) {
struct threaddata *data = (struct threaddata *)d;
uint64_t uid;
struct nRaR *TnRaR;
@@ -321,7 +321,7 @@ int main(int argc, char *argv[]) {
struct threaddata *tdata = NULL;
if (argc < 3) {
- printf("ht2crack3 uid nRaRfile\n");
+ printf("%s uid nRaRfile\n", argv[0]);
exit(1);
}
diff --git a/tools/hitag2crack/crack3/ht2test.c b/tools/hitag2crack/crack3/ht2crack3test.c
similarity index 96%
rename from tools/hitag2crack/crack3/ht2test.c
rename to tools/hitag2crack/crack3/ht2crack3test.c
index 53d47cfca..8d48cc914 100644
--- a/tools/hitag2crack/crack3/ht2test.c
+++ b/tools/hitag2crack/crack3/ht2crack3test.c
@@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
char *uid;
if (argc < 4) {
- printf("ht2test nRaRfile KEY UID\n");
+ printf("%s nRaRfile KEY UID\n", argv[0]);
exit(1);
}
diff --git a/tools/hitag2crack/crack4/Makefile b/tools/hitag2crack/crack4/Makefile
index b560577bd..1c7298840 100644
--- a/tools/hitag2crack/crack4/Makefile
+++ b/tools/hitag2crack/crack4/Makefile
@@ -1,18 +1,20 @@
-CFLAGS?=-Wall -Werror -O3
-LIBS=-lpthread
-VPATH=../common
-INC=-I ../common
+MYSRCPATHS = ../common
+MYSRCS = ht2crackutils.c hitagcrypto.c
+MYINCLUDES =-I ../common
+MYCFLAGS = -D_GNU_SOURCE
+MYDEFS =
+MYLDLIBS = -lpthread
-all: ht2crack4.c hitagcrypto.o ht2crackutils.o
- $(CC) $(CFLAGS) $(INC) -o ht2crack4 $< hitagcrypto.o ht2crackutils.o $(LIBS)
+BINS = ht2crack4
+INSTALLTOOLS = $(BINS)
-hitagcrypto.o: hitagcrypto.c hitagcrypto.h
- $(CC) $(CFLAGS) -c $<
+include ../../../Makefile.host
-ht2crackutils.o: ht2crackutils.c ht2crackutils.h
- $(CC) $(CFLAGS) -c $<
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
-clean:
- rm -rf *.o ht2crack4
-
-fresh: clean all
+ht2crack4 : $(OBJDIR)/ht2crack4.o $(MYOBJS)
diff --git a/tools/hitag2crack/crack4/ht2crack4.c b/tools/hitag2crack/crack4/ht2crack4.c
index 4c923737f..e630a956f 100644
--- a/tools/hitag2crack/crack4/ht2crack4.c
+++ b/tools/hitag2crack/crack4/ht2crack4.c
@@ -93,7 +93,7 @@ uint64_t uid;
int maxtablesize = 800000;
uint64_t supplied_testkey = 0;
-void usage() {
+static void usage(void) {
printf("ht2crack4 - K Sheldrake, based on the work of Garcia et al\n\n");
printf("Cracks a HiTag2 key using a small number (4 to 16) of encrypted\n");
printf("nonce and challenge response pairs, using a fast correlation\n");
@@ -147,6 +147,7 @@ double pfnc[][16] = {
/* hitag2_crypt works on the post-shifted form of the lfsr; this is the ref in rfidler code */
+/*
static uint32_t hitag2_crypt(uint64_t s) {
uint32_t bitindex;
@@ -158,9 +159,10 @@ static uint32_t hitag2_crypt(uint64_t s) {
return (ht2_function5c >> bitindex) & 1;
}
+*/
/* ht2crypt works on the pre-shifted form of the lfsr; this is the ref in the paper */
-uint64_t ht2crypt(uint64_t s) {
+static uint64_t ht2crypt(uint64_t s) {
uint64_t bitindex;
bitindex = (ht2_function4a >> pickbits2_2(s, 2, 5)) & 1;
@@ -174,12 +176,13 @@ uint64_t ht2crypt(uint64_t s) {
/* fnL is the feedback function for the reference code */
-uint64_t fnL(uint64_t x) {
+/*
+static uint64_t fnL(uint64_t x) {
return (bitn(x, 0) ^ bitn(x, 2) ^ bitn(x, 3) ^ bitn(x, 6) ^ bitn(x, 7) ^ bitn(x, 8) ^
bitn(x, 16) ^ bitn(x, 22) ^ bitn(x, 23) ^ bitn(x, 26) ^ bitn(x, 30) ^ bitn(x, 41) ^
bitn(x, 42) ^ bitn(x, 43) ^ bitn(x, 46) ^ bitn(x, 47));
}
-
+*/
/* packed_size is an array that maps the number of confirmed bits in a state to
* the number of relevant bits.
@@ -193,7 +196,7 @@ unsigned int packed_size[] = { 0, 0, 0, 1, 2, 2, 3, 4, 4, 5, 5, 5, 5
/* f20 is the same as hitag2_crypt except it works on the packed version
* of the state where all 20 relevant bits are squashed together */
-uint64_t f20(uint64_t y) {
+static uint64_t f20(uint64_t y) {
uint64_t bitindex;
bitindex = (ht2_function4a >> (y & 0xf)) & 1;
@@ -207,7 +210,7 @@ uint64_t f20(uint64_t y) {
/* packstate packs the relevant bits from LFSR state into 20 bits for pre-shifted lfsr */
-uint64_t packstate(uint64_t s) {
+static uint64_t packstate(uint64_t s) {
uint64_t packed;
packed = pickbits2_2(s, 2, 5);
@@ -221,7 +224,7 @@ uint64_t packstate(uint64_t s) {
/* create_guess_table mallocs the tables */
-void create_guess_table() {
+static void create_guess_table(void) {
guesses = (struct guess *)malloc(sizeof(struct guess) * maxtablesize);
if (!guesses) {
printf("cannot malloc guess table\n");
@@ -232,7 +235,7 @@ void create_guess_table() {
/* init the guess table by reading in the encrypted nR,aR values and
* setting the first 2^16 key guesses */
-void init_guess_table(char *filename, char *uidstr) {
+static void init_guess_table(char *filename, char *uidstr) {
unsigned int i, j;
FILE *fp;
char *buf = NULL;
@@ -313,7 +316,7 @@ void init_guess_table(char *filename, char *uidstr) {
/* bit_score calculates the ratio of partial states that could generate
* the resulting bit b to all possible states
* size is the number of confirmed bits in the state */
-double bit_score(uint64_t s, uint64_t size, uint64_t b) {
+static double bit_score(uint64_t s, uint64_t size, uint64_t b) {
uint64_t packed;
uint64_t chopped;
unsigned int n;
@@ -396,7 +399,7 @@ double bit_score(uint64_t s, uint64_t size, uint64_t b) {
* bit_scores together until no bits remain. bit_scores are
* multiplied by the number of relevant bits in the scored state
* to give weight to more complete states. */
-double score(uint64_t s, unsigned int size, uint64_t ks, unsigned int kssize) {
+static double score(uint64_t s, unsigned int size, uint64_t ks, unsigned int kssize) {
double sc, sc2;
if ((size == 1) || (kssize == 1)) {
@@ -427,7 +430,7 @@ double score(uint64_t s, unsigned int size, uint64_t ks, unsigned int kssize) {
/* score_traces runs score for each encrypted nonce */
-void score_traces(struct guess *g, unsigned int size) {
+static void score_traces(struct guess *g, unsigned int size) {
uint64_t lfsr;
unsigned int i;
double sc;
@@ -481,7 +484,7 @@ void score_all_traces(unsigned int size)
*/
/* score_some_traces runs score_traces for every key guess in a section of the table */
-void *score_some_traces(void *data) {
+static void *score_some_traces(void *data) {
unsigned int i;
struct thread_data *tdata = (struct thread_data *)data;
@@ -494,7 +497,7 @@ void *score_some_traces(void *data) {
/* score_all_traces runs score_traces for every key guess in the table */
-void score_all_traces(unsigned int size) {
+static void score_all_traces(unsigned int size) {
pthread_t threads[NUM_THREADS];
void *status;
struct thread_data tdata[NUM_THREADS];
@@ -535,7 +538,7 @@ void score_all_traces(unsigned int size) {
/* cmp_guess is the comparison function for qsorting the guess table */
-int cmp_guess(const void *a, const void *b) {
+static int cmp_guess(const void *a, const void *b) {
struct guess *a1 = (struct guess *)a;
struct guess *b1 = (struct guess *)b;
@@ -552,7 +555,7 @@ int cmp_guess(const void *a, const void *b) {
/* expand all guesses in first half of (sorted) table by
* copying them into the second half and extending the copied
* ones with an extra 1, leaving the first half with an extra 0 */
-void expand_guesses(unsigned int halfsize, unsigned int size) {
+static void expand_guesses(unsigned int halfsize, unsigned int size) {
unsigned int i, j;
for (i = 0; i < halfsize; i++) {
@@ -567,7 +570,7 @@ void expand_guesses(unsigned int halfsize, unsigned int size) {
/* checks if the supplied test key is still in the table, which
* is useful when testing different scoring methods */
-void check_supplied_testkey(unsigned int size) {
+static void check_supplied_testkey(unsigned int size) {
uint64_t partkey;
unsigned int i;
@@ -586,7 +589,7 @@ void check_supplied_testkey(unsigned int size) {
/* execute_round scores the guesses, sorts them and expands the good half */
-void execute_round(unsigned int size) {
+static void execute_round(unsigned int size) {
unsigned int halfsize;
// score all the current guesses
@@ -614,7 +617,7 @@ void execute_round(unsigned int size) {
/* crack is the main cracking algo; it executes the rounds */
-void crack() {
+static void crack(void) {
unsigned int i;
uint64_t revkey;
uint64_t foundkey;
@@ -630,9 +633,9 @@ void crack() {
}
}
-
/* test function to make sure I know how the LFSR works */
-void testkey(uint64_t key) {
+/*
+static void testkey(uint64_t key) {
uint64_t i;
uint64_t b0to31 = 0;
uint64_t ks = 0;
@@ -689,10 +692,11 @@ void testkey(uint64_t key) {
printbin2(lfsr, 48);
printf("\n\n");
}
-
+*/
/* test function to generate test data */
-void gen_bitstreams_testks(struct guess *g, uint64_t key) {
+/*
+static void gen_bitstreams_testks(struct guess *g, uint64_t key) {
unsigned int i, j;
uint64_t nRxorkey, lfsr, ks;
@@ -730,10 +734,11 @@ void gen_bitstreams_testks(struct guess *g, uint64_t key) {
}
}
}
-
+*/
/* test function */
-void test() {
+/*
+static void test(void) {
uint64_t lfsr;
uint64_t packed;
@@ -751,10 +756,10 @@ void test() {
printf("test done\n");
}
-
+*/
/* check_key tests the potential key against an encrypted nonce, ks pair */
-int check_key(uint64_t key, uint64_t enc_nR, uint64_t ks) {
+static int check_key(uint64_t key, uint64_t enc_nR, uint64_t ks) {
Hitag_State hstate;
uint64_t bits;
int i;
diff --git a/tools/hitag2crack/crack5/Makefile b/tools/hitag2crack/crack5/Makefile
index 9d19b63ee..8fc46e838 100644
--- a/tools/hitag2crack/crack5/Makefile
+++ b/tools/hitag2crack/crack5/Makefile
@@ -1,17 +1,20 @@
-CFLAGS?=-Wall -Werror -O3
-LIBS=-lpthread
-VPATH=../common
-INC=-I ../common
+MYSRCPATHS = ../common
+MYSRCS = ht2crackutils.c hitagcrypto.c
+MYINCLUDES =-I ../common
+MYCFLAGS =
+MYDEFS =
+MYLDLIBS = -lpthread
-all: ht2crack5.c ht2crackutils.o hitagcrypto.o
- $(CC) $(CFLAGS) $(INC) -O3 $< -o ht2crack5 ht2crackutils.o hitagcrypto.o $(LIBS)
+BINS = ht2crack5
+INSTALLTOOLS = $(BINS)
-hitagcrypto.o: hitagcrypto.c hitagcrypto.h
- $(CC) $(CFLAGS) -c $<
+include ../../../Makefile.host
-ht2crackutils.o: ht2crackutils.c ht2crackutils.h
- $(CC) $(CFLAGS) -c $<
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
-clean:
- rm -f *.o ht2crack5
-fresh: clean all
+ht2crack5 : $(OBJDIR)/ht2crack5.o $(MYOBJS)
diff --git a/tools/hitag2crack/crack5/ht2crack5.c b/tools/hitag2crack/crack5/ht2crack5.c
index d07d03b64..a92afc854 100644
--- a/tools/hitag2crack/crack5/ht2crack5.c
+++ b/tools/hitag2crack/crack5/ht2crack5.c
@@ -55,7 +55,7 @@ bitslice_t bs_zeroes, bs_ones;
#define get_bit(n, word) ((word >> (n)) & 1)
#define get_vector_bit(slice, value) get_bit(slice&0x3f, value.bytes64[slice>>6])
-const uint64_t expand(uint64_t mask, uint64_t value) {
+static uint64_t expand(uint64_t mask, uint64_t value) {
uint64_t fill = 0;
for (uint64_t bit_index = 0; bit_index < 48; bit_index++) {
if (mask & 1) {
@@ -67,7 +67,7 @@ const uint64_t expand(uint64_t mask, uint64_t value) {
return fill;
}
-void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value, const size_t bit_len, bool reverse) {
+static void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value, const size_t bit_len, bool reverse) {
size_t bit_idx;
for (bit_idx = 0; bit_idx < bit_len; bit_idx++) {
bool bit;
@@ -84,7 +84,7 @@ void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value, const
}
}
-const uint64_t unbitslice(const bitslice_t *restrict b, const uint8_t s, const uint8_t n) {
+static uint64_t unbitslice(const bitslice_t *restrict b, const uint8_t s, const uint8_t n) {
uint64_t result = 0;
for (uint8_t i = 0; i < n; ++i) {
result <<= 1;
@@ -118,7 +118,7 @@ bitslice_t initial_bitslices[48];
size_t filter_pos[20] = {4, 7, 9, 13, 16, 18, 22, 24, 27, 30, 32, 35, 45, 47 };
size_t thread_count = 8;
uint64_t layer_0_found;
-void *find_state(void *thread_d);
+static void *find_state(void *thread_d);
static void try_state(uint64_t s);
int main(int argc, char *argv[]) {
@@ -201,7 +201,7 @@ int main(int argc, char *argv[]) {
exit(1);
}
-void *find_state(void *thread_d) {
+static void *find_state(void *thread_d) {
uint64_t thread = (uint64_t)thread_d;
for (uint64_t index = thread; index < layer_0_found; index += thread_count) {
diff --git a/tools/hitag2crack/crack5gpu/Makefile b/tools/hitag2crack/crack5gpu/Makefile
index b88fa00e8..57e44641f 100644
--- a/tools/hitag2crack/crack5gpu/Makefile
+++ b/tools/hitag2crack/crack5gpu/Makefile
@@ -1,23 +1,27 @@
-CFLAGS?=-Wall
-#INCLUDE=-I/usr/local/cuda-7.5/include
-INCLUDE=-I/opt/nvidia/cuda/include
-#Linux
-#LIBS=-L/usr/local/cuda-7.5/lib64 -lOpenCL
-LIBS=-L/opt/nvidia/cuda/lib64 -lOpenCL
-#Mac
-#LIBS=-framework OpenCL
-VPATH=../common
-INC=-I ../common
+MYSRCPATHS = ../common
+MYSRCS = ht2crackutils.c hitagcrypto.c
+MYCFLAGS =
+MYDEFS =
+ifeq ($(platform),Darwin)
+ MYLDLIBS ?= -framework OpenCL
+else
+ #MYINCLUDES ?=-I/usr/local/cuda-7.5/include
+ #MYINCLUDES ?=-I/opt/nvidia/cuda/include
+ #MYLDLIBS ?= -L/usr/local/cuda-7.5/lib64 -lOpenCL
+ MYLDLIBS ?= -L/opt/nvidia/cuda/lib64 -lOpenCL
+endif
+MYINCLUDES +=-I ../common
-all: ht2crack5.c ht2crackutils.o hitagcrypto.o
- $(CC) $(CFLAGS) $(INC) -o ht2crack5gpu $< ht2crackutils.o hitagcrypto.o $(LIBS) -lpthread
+BINS = ht2crack5gpu
+INSTALLTOOLS = $(BINS)
-hitagcrypto.o: hitagcrypto.c hitagcrypto.h
- $(CC) $(CFLAGS) $(INCLUDE) -c $<
+include ../../../Makefile.host
-ht2crackutils.o: ht2crackutils.c ht2crackutils.h
- $(CC) $(CFLAGS) $(INCLUDE) -c $<
+# checking platform can be done only after Makefile.host
+ifneq (,$(findstring MINGW,$(platform)))
+ # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
+ # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
+ CFLAGS += -D_ISOC99_SOURCE
+endif
-clean:
- rm -f *.o ht2crack5gpu
-fresh: clean all
+ht2crack5gpu : $(OBJDIR)/ht2crack5gpu.o $(MYOBJS)
diff --git a/tools/hitag2crack/crack5gpu/ht2crack5.c b/tools/hitag2crack/crack5gpu/ht2crack5gpu.c
similarity index 98%
rename from tools/hitag2crack/crack5gpu/ht2crack5.c
rename to tools/hitag2crack/crack5gpu/ht2crack5gpu.c
index cfacecc98..8cb720540 100644
--- a/tools/hitag2crack/crack5gpu/ht2crack5.c
+++ b/tools/hitag2crack/crack5gpu/ht2crack5gpu.c
@@ -65,7 +65,7 @@ bitslice_t bs_zeroes, bs_ones;
state[-2+i+42].value ^ state[-2+i+43].value ^ state[-2+i+46].value ^ state[-2+i+47].value);
#define get_bit(n, word) ((word >> (n)) & 1)
-const uint64_t expand(uint64_t mask, uint64_t value) {
+static uint64_t expand(uint64_t mask, uint64_t value) {
uint64_t fill = 0;
for (uint64_t bit_index = 0; bit_index < 48; bit_index++) {
if (mask & 1) {
@@ -77,7 +77,7 @@ const uint64_t expand(uint64_t mask, uint64_t value) {
return fill;
}
-void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value, const size_t bit_len, bool reverse) {
+static void bitslice(const uint64_t value, bitslice_t *restrict bitsliced_value, const size_t bit_len, bool reverse) {
size_t bit_idx;
for (bit_idx = 0; bit_idx < bit_len; bit_idx++) {
bool bit;
@@ -123,7 +123,7 @@ struct context {
};
-void runKernel(struct context *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found) {
+static void runKernel(struct context *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found) {
int err;
size_t global[2];
diff --git a/tools/hitag2crack/hitag2_gen_nRaR.py b/tools/hitag2crack/hitag2_gen_nRaR.py
new file mode 100755
index 000000000..14f48a26d
--- /dev/null
+++ b/tools/hitag2crack/hitag2_gen_nRaR.py
@@ -0,0 +1,118 @@
+#!/usr/bin/env python3
+
+"""
+HITAG2 cipher
+Implemented by Aram Verstegen
+"""
+import random
+
+def i4(x, a, b, c, d):
+ return (((x >> a) & 1)*8)+((x >> b) & 1)*4+((x >> c) & 1)*2+((x >> d) & 1)
+
+
+def f20_4(state):
+ return ((0x3c65 >> i4(state,34,43,44,46)) & 1)
+
+def f20_3(state):
+ return (( 0xee5 >> i4(state,28,29,31,33)) & 1)
+
+def f20_2(state):
+ return (( 0xee5 >> i4(state,17,21,23,26)) & 1)
+
+def f20_1(state):
+ return (( 0xee5 >> i4(state, 8,12,14,15)) & 1)
+
+def f20_0(state):
+ return ((0x3c65 >> i4(state, 2, 3, 5, 6)) & 1)
+
+def f20_last(s0,s1,s2,s3,s4):
+ return (0xdd3929b >> ((s0 * 16)
+ + (s1 * 8)
+ + (s2 * 4)
+ + (s3 * 2)
+ + (s4 * 1))) & 1
+
+def f20(state):
+ return f20_last(f20_0(state), f20_1(state), f20_2(state), f20_3(state), f20_4(state))
+
+def lfsr_bs(state, i):
+ return (state[i+ 0] ^ state[i+ 2] ^ state[i+ 3] ^ state[i+ 6] ^
+ state[i+ 7] ^ state[i+ 8] ^ state[i+16] ^ state[i+22] ^
+ state[i+23] ^ state[i+26] ^ state[i+30] ^ state[i+41] ^
+ state[i+42] ^ state[i+43] ^ state[i+46] ^ state[i+47])
+
+def f20a_bs(a,b,c,d):
+ return (~(((a|b)&c)^(a|d)^b)) # 6 ops
+def f20b_bs(a,b,c,d):
+ return (~(((d|c)&(a^b))^(d|a|b))) # 7 ops
+def f20c_bs(a,b,c,d,e):
+ return (~((((((c^e)|d)&a)^b)&(c^b))^(((d^e)|a)&((d^b)|c)))) # 13 ops
+
+def filter_bs(state, i):
+ return (f20c_bs( f20a_bs(state[i+ 2],state[i+ 3],state[i+ 5],state[i+ 6]),
+ f20b_bs(state[i+ 8],state[i+12],state[i+14],state[i+15]),
+ f20b_bs(state[i+17],state[i+21],state[i+23],state[i+26]),
+ f20b_bs(state[i+28],state[i+29],state[i+31],state[i+33]),
+ f20a_bs(state[i+34],state[i+43],state[i+44],state[i+46])))
+
+def unbitslice(s, n):
+ return int(''.join(map(str,map(int,map(bool,s[n:n+48])))[::-1]),2)
+
+def hitag2_init(key, uid, nonce):
+ state = 0
+ for i in range(32, 48):
+ state = (state << 1) | ((key >> i) & 1)
+ for i in range(0, 32):
+ state = (state << 1) | ((uid >> i) & 1)
+ #print '%012x' % state
+ #print '%012x' % (int("{0:048b}".format(state)[::-1],2))
+ for i in range(0, 32):
+ nonce_bit = (f20(state) ^ ((nonce >> (31-i)) & 1))
+ #print nonce_bit
+ state = (state >> 1) | (((nonce_bit ^ (key >> (31-i))) & 1) << 47)
+ #print '%012x' % state
+ #print '%012x' % (int("{0:048b}".format(state)[::-1],2))
+ return state
+
+def lfsr_feedback(state):
+ return (((state >> 0) ^ (state >> 2) ^ (state >> 3)
+ ^ (state >> 6) ^ (state >> 7) ^ (state >> 8)
+ ^ (state >> 16) ^ (state >> 22) ^ (state >> 23)
+ ^ (state >> 26) ^ (state >> 30) ^ (state >> 41)
+ ^ (state >> 42) ^ (state >> 43) ^ (state >> 46)
+ ^ (state >> 47)) & 1)
+def lfsr(state):
+ return (state >> 1) + (lfsr_feedback(state) << 47)
+
+def lfsr_feedback_inv(state):
+ return (((state >> 47) ^ (state >> 1) ^ (state >> 2)
+ ^ (state >> 5) ^ (state >> 6) ^ (state >> 7)
+ ^ (state >> 15) ^ (state >> 21) ^ (state >> 22)
+ ^ (state >> 25) ^ (state >> 29) ^ (state >> 40)
+ ^ (state >> 41) ^ (state >> 42) ^ (state >> 45)
+ ^ (state >> 46)) & 1)
+
+def lfsr_inv(state):
+ return ((state << 1) + (lfsr_feedback_inv(state))) & ((1<<48)-1)
+
+def hitag2(state, length=48):
+ c = 0
+ for i in range(0, length):
+ c = (c << 1) | f20(state)
+ #print '%012x' % state
+ #print '%012x' % (int("{0:048b}".format(state)[::-1],2))
+ state = lfsr(state)
+ return c
+
+if __name__ == "__main__":
+ import sys
+ if len(sys.argv) == 4:
+ key = int(sys.argv[1], 16)
+ uid = int(sys.argv[2], 16)
+ n = int(sys.argv[3])
+ for i in range(n):
+ nonce = random.randrange(2**32)
+ state = hitag2_init(key, uid, nonce)
+ print('%08X %08X' % (nonce, hitag2(state, 32)^0xffffffff))
+ else:
+ print("Usage: python %s " % sys.argv[0])
diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh
index 8aaf82d58..89850e8bd 100755
--- a/tools/pm3_tests.sh
+++ b/tools/pm3_tests.sh
@@ -4,10 +4,12 @@ PM3PATH="$(dirname "$0")/.."
cd "$PM3PATH" || exit 1
SLOWTESTS=false
+GPUTESTS=false
TESTALL=true
TESTMFKEY=false
TESTNONCE2KEY=false
TESTMFNONCEBRUTE=false
+TESTHITAG2CRACK=false
TESTFPGACOMPRESS=false
TESTBOOTROM=false
TESTARMSRC=false
@@ -32,6 +34,10 @@ Usage: $0 [--long] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_br
SLOWTESTS=true
shift
;;
+ --gpu)
+ GPUTESTS=true
+ shift
+ ;;
--clientbin)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
CLIENTBIN=$2
@@ -61,6 +67,11 @@ Usage: $0 [--long] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_br
TESTFPGACOMPRESS=true
shift
;;
+ hitag2crack)
+ TESTALL=false
+ TESTHITAG2CRACK=true
+ shift
+ ;;
bootrom)
TESTALL=false
TESTBOOTROM=true
@@ -122,24 +133,45 @@ function CheckFileExist() {
return 1
}
-# title, command line, check result, repeat several times if failed, ignore if fail
+# [slow] [gpu] [retry] [ignore]
+# slow: test takes more than ~5s
+# gpu: test requires GPU presence
+# retry: test repeated up to 3 times in case of failure
+# ignore: test failure is not fatal
function CheckExecute() {
if [ "$1" == "slow" ]; then
- SLOWTEST=true
+ local SLOWTEST=true
shift
else
- SLOWTEST=false
+ local SLOWTEST=false
fi
- if [ "$4" ]; then
+ if [ "$1" == "gpu" ]; then
+ local GPUTEST=true
+ shift
+ else
+ local GPUTEST=false
+ fi
+ if [ "$1" == "retry" ]; then
local RETRY="1 2 3 e"
+ shift
else
local RETRY="e"
fi
+ if [ "$1" == "ignore" ]; then
+ local IGNOREFAILURE=true
+ shift
+ else
+ local IGNOREFAILURE=false
+ fi
if $SLOWTEST && ! $SLOWTESTS; then
echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (slow)\n"
return 0
fi
+ if $GPUTEST && ! $GPUTESTS; then
+ echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (gpu)\n"
+ return 0
+ fi
for I in $RETRY
do
@@ -151,7 +183,7 @@ function CheckExecute() {
if [ ! $I == "e" ]; then echo "retry $I"; fi
done
- if [ "$5" ]; then
+ if $IGNOREFAILURE; then
echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}"
return 0
fi
@@ -227,6 +259,54 @@ while true; do
if ! CheckFileExist "mf_nonce_brute exists" "$MFNONCEBRUTEBIN"; then break; fi
if ! CheckExecute slow "mf_nonce_brute test" "$MFNONCEBRUTEBIN 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a" "Key.*: \[ffffffffffff\]"; then break; fi
fi
+ # hitag2crack not yet part of "all"
+ # if $TESTALL || $TESTHITAG2CRACK; then
+ if $TESTHITAG2CRACK; then
+ echo -e "\n${C_BLUE}Testing ht2crack2:${C_NC} ${HT2CRACK2PATH:=./tools/hitag2crack/crack2/}"
+ if ! CheckFileExist "ht2crack2buildtable exists" "$HT2CRACK2PATH/ht2crack2buildtable"; then break; fi
+ if ! CheckFileExist "ht2crack2gentest exists" "$HT2CRACK2PATH/ht2crack2gentest"; then break; fi
+ if ! CheckFileExist "ht2crack2search exists" "$HT2CRACK2PATH/ht2crack2search"; then break; fi
+ # 1.5Tb tables are supposed to be absent, so it's just a fast check without real cracking
+ if ! CheckExecute "ht2crack2 quick test" "cd $HT2CRACK2PATH; ./ht2crack2gentest 1 && ./runalltests.sh; rm keystream*" "searching on bit"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing ht2crack3:${C_NC} ${HT2CRACK3PATH:=./tools/hitag2crack/crack3/}"
+ if ! CheckFileExist "ht2crack3 exists" "$HT2CRACK3PATH/ht2crack3"; then break; fi
+ if ! CheckFileExist "ht2crack3test exists" "$HT2CRACK3PATH/ht2crack3test"; then break; fi
+ HT2CRACK3UID=AABBCCDD
+ # Test fast only for HT2CRACK3KEY in begin of keyspace!
+ HT2CRACK3KEY=000102030405
+ HT2CRACK3N=32
+ HT2CRACK3NRAR=hitag2_${HT2CRACK3UID}_nrar_${HT2CRACK3N}emul.txt
+ if ! CheckExecute "ht2crack3 gen testfile" "cd $HT2CRACK3PATH; python3 ../hitag2_gen_nRaR.py $HT2CRACK3KEY $HT2CRACK3UID $HT2CRACK3N > $HT2CRACK3NRAR && echo SUCCESS" "SUCCESS"; then break; fi
+ if ! CheckExecute "ht2crack3test test" "cd $HT2CRACK3PATH; ./ht2crack3test $HT2CRACK3NRAR $HT2CRACK3KEY $HT2CRACK3UID|grep -v SUCCESS||echo SUCCESS" "SUCCESS"; then break; fi
+ if ! CheckExecute "ht2crack3 test" "cd $HT2CRACK3PATH; ./ht2crack3 $HT2CRACK3UID $HT2CRACK3NRAR |egrep -v '(trying|partial)'" "key = $HT2CRACK3KEY"; then break; fi
+ if ! CheckExecute "ht2crack3 rm testfile" "cd $HT2CRACK3PATH; rm $HT2CRACK3NRAR && echo SUCCESS" "SUCCESS"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing ht2crack4:${C_NC} ${HT2CRACK4PATH:=./tools/hitag2crack/crack4/}"
+ if ! CheckFileExist "ht2crack4 exists" "$HT2CRACK4PATH/ht2crack4"; then break; fi
+ HT2CRACK4UID=12345678
+ HT2CRACK4KEY=AABBCCDDEEFF
+ HT2CRACK4N=32
+ HT2CRACK4NRAR=hitag2_${HT2CRACK4UID}_nrar_${HT2CRACK4N}emul.txt
+ # The success is probabilistic: a fresh random nRaR file is required for each run
+ # Order of magnitude to crack it: ~15s -> tagged as "slow"
+ if ! CheckExecute slow retry ignore "ht2crack4 test" "cd $HT2CRACK4PATH; \
+ python3 ../hitag2_gen_nRaR.py $HT2CRACK4KEY $HT2CRACK4UID $HT2CRACK4N > $HT2CRACK4NRAR; \
+ ./ht2crack4 -u $HT2CRACK4UID -n $HT2CRACK4NRAR -N 16 -t 500000 2>&1; \
+ rm $HT2CRACK4NRAR" "key = $HT2CRACK4KEY"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing ht2crack5:${C_NC} ${HT2CRACK5PATH:=./tools/hitag2crack/crack5/}"
+ if ! CheckFileExist "ht2crack5 exists" "$HT2CRACK5PATH/ht2crack5"; then break; fi
+
+ echo -e "\n${C_BLUE}Testing ht2crack5gpu:${C_NC} ${HT2CRACK5GPUPATH:=./tools/hitag2crack/crack5gpu/}"
+ if ! CheckFileExist "ht2crack5gpu exists" "$HT2CRACK5GPUPATH/ht2crack5gpu"; then break; fi
+ HT2CRACK5GPUUID=12345678
+ HT2CRACK5GPUKEY=AABBCCDDEEFF
+ # The speed depends on the nRaR so we'll use two pairs known to work fast
+ HT2CRACK5GPUNRAR="B438220C 944FFD74 942C59E3 3D450B34"
+ # Order of magnitude to crack it: ~15s -> tagged as "slow"
+ if ! CheckExecute slow gpu "ht2crack5gpu test" "cd $HT2CRACK5GPUPATH; ./ht2crack5gpu $HT2CRACK5GPUUID $HT2CRACK5GPUNRAR" "Key: $HT2CRACK5GPUKEY"; then break; fi
+ fi
if $TESTALL || $TESTCLIENT; then
echo -e "\n${C_BLUE}Testing client:${C_NC} ${CLIENTBIN:=./client/proxmark3}"
if ! CheckFileExist "proxmark3 exists" "$CLIENTBIN"; then break; fi
@@ -261,7 +341,7 @@ while true; do
echo -e "\n${C_BLUE}Testing HF:${C_NC}"
if ! CheckExecute "hf mf offline text" "$CLIENTBIN -c 'hf mf'" "at_enc"; then break; fi
- if ! CheckExecute slow "hf mf hardnested long test" "$CLIENTBIN -c 'hf mf hardnested t 1 000000000000'" "found:" "repeat" "ignore"; then break; fi
+ if ! CheckExecute slow retry ignore "hf mf hardnested long test" "$CLIENTBIN -c 'hf mf hardnested t 1 000000000000'" "found:"; then break; fi
if ! CheckExecute slow "hf iclass long test" "$CLIENTBIN -c 'hf iclass loclass t l'" "verified ok"; then break; fi
if ! CheckExecute slow "emv long test" "$CLIENTBIN -c 'emv test -l'" "Test(s) \[ OK"; then break; fi
if ! $SLOWTESTS; then
From 077b156b2f7614a8b2a0020126ee797b8cb8e350 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 23 May 2020 17:07:14 +0200
Subject: [PATCH 127/527] add ht2crack5 test
---
tools/pm3_tests.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh
index 89850e8bd..71a754080 100755
--- a/tools/pm3_tests.sh
+++ b/tools/pm3_tests.sh
@@ -297,6 +297,12 @@ while true; do
echo -e "\n${C_BLUE}Testing ht2crack5:${C_NC} ${HT2CRACK5PATH:=./tools/hitag2crack/crack5/}"
if ! CheckFileExist "ht2crack5 exists" "$HT2CRACK5PATH/ht2crack5"; then break; fi
+ HT2CRACK5UID=12345678
+ HT2CRACK5KEY=AABBCCDDEEFF
+ # The speed depends on the nRaR so we'll use two pairs known to work fast
+ HT2CRACK5NRAR="6F901EE0 3AC77442 E5F99B3C 055B29BE"
+ # Order of magnitude to crack it: ~45s -> tagged as "slow"
+ if ! CheckExecute slow "ht2crack5 test" "cd $HT2CRACK5PATH; ./ht2crack5 $HT2CRACK5UID $HT2CRACK5NRAR" "Key: $HT2CRACK5KEY"; then break; fi
echo -e "\n${C_BLUE}Testing ht2crack5gpu:${C_NC} ${HT2CRACK5GPUPATH:=./tools/hitag2crack/crack5gpu/}"
if ! CheckFileExist "ht2crack5gpu exists" "$HT2CRACK5GPUPATH/ht2crack5gpu"; then break; fi
@@ -305,7 +311,7 @@ while true; do
# The speed depends on the nRaR so we'll use two pairs known to work fast
HT2CRACK5GPUNRAR="B438220C 944FFD74 942C59E3 3D450B34"
# Order of magnitude to crack it: ~15s -> tagged as "slow"
- if ! CheckExecute slow gpu "ht2crack5gpu test" "cd $HT2CRACK5GPUPATH; ./ht2crack5gpu $HT2CRACK5GPUUID $HT2CRACK5GPUNRAR" "Key: $HT2CRACK5GPUKEY"; then break; fi
+ if ! CheckExecute slow gpu "ht2crack5gpu test" "cd $HT2CRACK5GPUPATH; ./ht2crack5gpu $HT2CRACK5GPUUID $HT2CRACK5GPUNRAR" "Key: $HT2CRACK5GPUKEY"; then break; fi
fi
if $TESTALL || $TESTCLIENT; then
echo -e "\n${C_BLUE}Testing client:${C_NC} ${CLIENTBIN:=./client/proxmark3}"
From 4df2727ab768906745bbd6f2df3d47a4445e5e5f Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 23 May 2020 23:47:33 +0200
Subject: [PATCH 128/527] ht2crack5: faster test
---
tools/pm3_tests.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh
index 71a754080..ee554b01b 100755
--- a/tools/pm3_tests.sh
+++ b/tools/pm3_tests.sh
@@ -300,8 +300,8 @@ while true; do
HT2CRACK5UID=12345678
HT2CRACK5KEY=AABBCCDDEEFF
# The speed depends on the nRaR so we'll use two pairs known to work fast
- HT2CRACK5NRAR="6F901EE0 3AC77442 E5F99B3C 055B29BE"
- # Order of magnitude to crack it: ~45s -> tagged as "slow"
+ HT2CRACK5NRAR="71DA20AA 7EFDF3FA 2A4265F9 59653B07"
+ # Order of magnitude to crack it: ~12s on 1 core, ~3s on 4 cores -> tagged as "slow"
if ! CheckExecute slow "ht2crack5 test" "cd $HT2CRACK5PATH; ./ht2crack5 $HT2CRACK5UID $HT2CRACK5NRAR" "Key: $HT2CRACK5KEY"; then break; fi
echo -e "\n${C_BLUE}Testing ht2crack5gpu:${C_NC} ${HT2CRACK5GPUPATH:=./tools/hitag2crack/crack5gpu/}"
From 6e5de1090a0ec8fa4321dec55f0477bb5d657dc7 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sat, 23 May 2020 23:59:10 +0200
Subject: [PATCH 129/527] pm3_tests: cosmetic
---
tools/pm3_tests.sh | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh
index ee554b01b..d5b88f446 100755
--- a/tools/pm3_tests.sh
+++ b/tools/pm3_tests.sh
@@ -23,8 +23,9 @@ while (( "$#" )); do
case "$1" in
-h|--help)
echo """
-Usage: $0 [--long] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|fpga_compress|bootrom|armsrc|client|recovery|common]
+Usage: $0 [--long] [--gpu] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|fpga_compress|bootrom|armsrc|client|recovery|common]
--long: Enable slow tests
+ --gpu: Enable tests requiring GPU
--clientbin ...: Specify path to proxmark3 binary to test
If no target given, all targets will be tested
"""
@@ -119,17 +120,19 @@ C_NC='\033[0m' # No Color
# title, file name or file wildcard to check
function CheckFileExist() {
+ printf "%-40s" "$1 "
+
if [ -f "$2" ]; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ echo -e "${C_GREEN}[OK]${C_NC}"
return 0
fi
if ls "$2" 1> /dev/null 2>&1; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ echo -e "${C_GREEN}[OK]${C_NC}"
return 0
fi
- echo -e "$1 ${C_RED}[Fail]${C_NC}"
+ echo -e "${C_RED}[FAIL]${C_NC}"
return 1
}
@@ -164,12 +167,14 @@ function CheckExecute() {
local IGNOREFAILURE=false
fi
+ printf "%-40s" "$1 "
+
if $SLOWTEST && ! $SLOWTESTS; then
- echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (slow)\n"
+ echo -e "${C_YELLOW}[SKIPPED]${C_NC} (slow)\n"
return 0
fi
if $GPUTEST && ! $GPUTESTS; then
- echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (gpu)\n"
+ echo -e "${C_YELLOW}[SKIPPED]${C_NC} (gpu)\n"
return 0
fi
@@ -177,18 +182,18 @@ function CheckExecute() {
do
RES=$(eval "$2")
if echo "$RES" | grep -q "$3"; then
- echo -e "$1 ${C_GREEN}[OK]${C_NC}"
+ echo -e "${C_GREEN}[OK]${C_NC}"
return 0
fi
if [ ! $I == "e" ]; then echo "retry $I"; fi
done
if $IGNOREFAILURE; then
- echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}"
+ echo -e "${C_YELLOW}[IGNORED]${C_NC}"
return 0
fi
- echo -e "$1 ${C_RED}[Fail]${C_NC}"
+ echo -e "${C_RED}[FAIL]${C_NC}"
echo -e "Execution trace:\n$RES"
return 1
}
From f54f8103ace2c37b21657fd149e40ff625f6813e Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 01:03:23 +0200
Subject: [PATCH 130/527] fix pathsep in subdirs
---
include/common.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/common.h b/include/common.h
index d52e40f10..a66ddabd5 100644
--- a/include/common.h
+++ b/include/common.h
@@ -31,8 +31,8 @@
#define RESOURCES_SUBDIR "resources" PATHSEP
#define TRACES_SUBDIR "traces" PATHSEP
#define FIRMWARES_SUBDIR "firmware" PATHSEP
-#define BOOTROM_SUBDIR "bootrom/obj" PATHSEP
-#define FULLIMAGE_SUBDIR "armsrc/obj" PATHSEP
+#define BOOTROM_SUBDIR "bootrom" PATHSEP "obj" PATHSEP
+#define FULLIMAGE_SUBDIR "armsrc" PATHSEP "obj" PATHSEP
#define PACKED __attribute__((packed))
From a6f76444de2ef26c5380fb1a347e2da6aac83790 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 01:20:43 +0200
Subject: [PATCH 131/527] Put logfiles in subdir
---
client/src/preferences.c | 2 +-
client/src/proxmark3.c | 2 +-
client/src/ui.c | 46 ++++++++++++++++++++++++++++++++++++----
client/src/ui.h | 2 +-
include/common.h | 1 +
5 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/client/src/preferences.c b/client/src/preferences.c
index 4c8fefb77..89d9cc188 100644
--- a/client/src/preferences.c
+++ b/client/src/preferences.c
@@ -32,7 +32,7 @@ static int setCmdHelp(const char *Cmd);
static char *prefGetFilename(void) {
char *path;
- if (searchHomeFilePath(&path, preferencesFilename, false) == PM3_SUCCESS)
+ if (searchHomeFilePath(&path, NULL, preferencesFilename, false) == PM3_SUCCESS)
return path;
else
return strdup(preferencesFilename);
diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c
index 427619e75..a461d4c95 100644
--- a/client/src/proxmark3.c
+++ b/client/src/proxmark3.c
@@ -206,7 +206,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
}
char *my_history_path = NULL;
- if (searchHomeFilePath(&my_history_path, PROXHISTORY, true) != PM3_SUCCESS) {
+ if (searchHomeFilePath(&my_history_path, NULL, PROXHISTORY, true) != PM3_SUCCESS) {
PrintAndLogEx(ERR, "No history will be recorded");
my_history_path = NULL;
} else {
diff --git a/client/src/ui.c b/client/src/ui.c
index 9414fbb34..798ed165a 100644
--- a/client/src/ui.c
+++ b/client/src/ui.c
@@ -54,7 +54,7 @@ pthread_mutex_t print_lock = PTHREAD_MUTEX_INITIALIZER;
static void fPrintAndLog(FILE *stream, const char *fmt, ...);
// needed by flasher, so let's put it here instead of fileutils.c
-int searchHomeFilePath(char **foundpath, const char *filename, bool create_home) {
+int searchHomeFilePath(char **foundpath, const char *subdir, const char *filename, bool create_home) {
if (foundpath == NULL)
return PM3_EINVARG;
const char *user_path = get_my_user_directory();
@@ -62,7 +62,8 @@ int searchHomeFilePath(char **foundpath, const char *filename, bool create_home)
fprintf(stderr, "Could not retrieve $HOME from the environment\n");
return PM3_EFILE;
}
- char *path = calloc(strlen(user_path) + strlen(PM3_USER_DIRECTORY) + 1, sizeof(char));
+ size_t pathlen = strlen(user_path) + strlen(PM3_USER_DIRECTORY) + 1;
+ char *path = calloc(pathlen, sizeof(char));
if (path == NULL)
return PM3_EMALLOC;
strcpy(path, user_path);
@@ -96,11 +97,48 @@ int searchHomeFilePath(char **foundpath, const char *filename, bool create_home)
return PM3_EFILE;
}
}
+ if (subdir != NULL) {
+ pathlen += strlen(subdir);
+ path = realloc(path, pathlen * sizeof(char));
+ if (path == NULL)
+ return PM3_EMALLOC;
+ strcat(path, subdir);
+
+#ifdef _WIN32
+ // Mingw _stat fails if path ends with /, so let's use a stripped path
+ if (path[strlen(path) - 1] == '/') {
+ path[strlen(path) - 1] = '\0';
+ result = _stat(path, &st);
+ path[strlen(path)] = '/';
+ } else {
+ result = _stat(path, &st);
+ }
+#else
+ result = stat(path, &st);
+#endif
+ if ((result != 0) && create_home) {
+
+#ifdef _WIN32
+ if (_mkdir(path))
+#else
+ if (mkdir(path, 0700))
+#endif
+ {
+ fprintf(stderr, "Could not create user directory %s\n", path);
+ free(path);
+ return PM3_EFILE;
+ }
+ }
+ }
+
if (filename == NULL) {
*foundpath = path;
return PM3_SUCCESS;
}
- path = realloc(path, (strlen(user_path) + strlen(PM3_USER_DIRECTORY) + strlen(filename) + 1) * sizeof(char));
+ pathlen += strlen(filename);
+ path = realloc(path, pathlen * sizeof(char));
+ if (path == NULL)
+ return PM3_EMALLOC;
strcat(path, filename);
*foundpath = path;
return PM3_SUCCESS;
@@ -266,7 +304,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
time_t now = time(NULL);
timenow = gmtime(&now);
strftime(filename, sizeof(filename), PROXLOG, timenow);
- if (searchHomeFilePath(&my_logfile_path, filename, true) != PM3_SUCCESS) {
+ if (searchHomeFilePath(&my_logfile_path, LOGS_SUBDIR, filename, true) != PM3_SUCCESS) {
fprintf(stderr, "[-] Logging disabled!\n\n");
my_logfile_path = NULL;
logging = 0;
diff --git a/client/src/ui.h b/client/src/ui.h
index 20b5a3619..60064c0aa 100644
--- a/client/src/ui.h
+++ b/client/src/ui.h
@@ -59,7 +59,7 @@ void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter);
void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n);
void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode);
-int searchHomeFilePath(char **foundpath, const char *filename, bool create_home);
+int searchHomeFilePath(char **foundpath, const char *subdir, const char *filename, bool create_home);
extern pthread_mutex_t print_lock;
diff --git a/include/common.h b/include/common.h
index a66ddabd5..4d6efcce2 100644
--- a/include/common.h
+++ b/include/common.h
@@ -30,6 +30,7 @@
#define LUA_SCRIPTS_SUBDIR "luascripts" PATHSEP
#define RESOURCES_SUBDIR "resources" PATHSEP
#define TRACES_SUBDIR "traces" PATHSEP
+#define LOGS_SUBDIR "logs" PATHSEP
#define FIRMWARES_SUBDIR "firmware" PATHSEP
#define BOOTROM_SUBDIR "bootrom" PATHSEP "obj" PATHSEP
#define FULLIMAGE_SUBDIR "armsrc" PATHSEP "obj" PATHSEP
From e7585b59445d780c312abe3a85c778baba458483 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Sun, 24 May 2020 11:17:11 +0200
Subject: [PATCH 132/527] fix #747, 'hf mfu eload' - now detects and converts
between plain/old/new mfu binary format
---
CHANGELOG.md | 3 +
client/src/cmdhfmf.c | 29 +++++++-
client/src/cmdhfmfu.c | 9 ++-
client/src/cmdhfmfu.h | 5 +-
client/src/fileutils.c | 161 +++++++++++++++++++++++++++++++++++------
client/src/fileutils.h | 20 ++++-
6 files changed, 188 insertions(+), 39 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90c6dccb3..8edd91099 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
## [ice coffee.4.][2020-05-21]
+ - Fix `hf mfu eload` - now detects and converts between plain/old/new mfu binary format (@iceman1001)
+ - Change log files moved to subfolders (@doegex)
+ - Change lib lua unbundled. (@doegex)
- Updated documentation (@doegox, @iceman1001)
- Change `pm3test.sh` - more regression tests to (@doegox, @iceman1001)
- Change `hf 15 dump` - now supports basic json format (@iceman1001)
diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c
index 08a4f1781..4940e96a2 100644
--- a/client/src/cmdhfmf.c
+++ b/client/src/cmdhfmf.c
@@ -3688,10 +3688,15 @@ int CmdHF14AMfELoad(const char *Cmd) {
return usage_hf14_eload();
uint8_t *data = calloc(4096, sizeof(uint8_t));
+ if (data == NULL) {
+ PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
+ return PM3_EMALLOC;
+ }
+
size_t datalen = 0;
//int res = loadFile(filename, ".bin", data, maxdatalen, &datalen);
int res = loadFileEML(filename, data, &datalen);
- if (res) {
+ if (res != PM3_SUCCESS) {
free(data);
return PM3_EFILE;
}
@@ -3703,15 +3708,31 @@ int CmdHF14AMfELoad(const char *Cmd) {
return PM3_ESOFT;
}
- // convert old mfu format to new
+ // convert plain or old mfu format to new format
if (blockWidth == 4) {
- res = convertOldMfuDump(&data, &datalen);
- if (res) {
+
+ res = convert_mfu_dump_format(&data, &datalen, true);
+ if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
free(data);
return res;
}
+ mfu_dump_t *mfu_dump = (mfu_dump_t *)data;
+
+ PrintAndLogEx(INFO, _CYAN_("MFU dump file information"));
+ PrintAndLogEx(INFO, " version %s", sprint_hex(mfu_dump->version, sizeof(mfu_dump->version)));
+ PrintAndLogEx(INFO, " tb 0 %s", sprint_hex(mfu_dump->tbo, sizeof(mfu_dump->tbo)));
+ PrintAndLogEx(INFO, " tb 1 %s", sprint_hex(mfu_dump->tbo1, sizeof(mfu_dump->tbo1)));
+ for(uint8_t m = 0; m < 3; m++) {
+ PrintAndLogEx(INFO, " counter %d %s - tearing 0x%02x", m + 1, sprint_hex(mfu_dump->counter_tearing[m], 3), mfu_dump->counter_tearing[m][3]);
+ }
+ PrintAndLogEx(INFO, " signature %s", sprint_hex(mfu_dump->signature, sizeof(mfu_dump->signature)));
+ PrintAndLogEx(INFO, " data %s... (only first 8 bytes showing)", sprint_hex(mfu_dump->data, 8));
+ PrintAndLogEx(INFO, " max data page %d, data len %d bytes", mfu_dump->pages, (mfu_dump->pages + 1) * 4);
+ PrintAndLogEx(INFO, " file header size %d", MFU_DUMP_PREFIX_LENGTH);
+ PrintAndLogEx(INFO, "----------------------------------------------");
+
// update expected blocks to match converted data.
if (numBlocks != datalen / 4) {
numBlocks = datalen / 4;
diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c
index 9dc739417..75afa7641 100644
--- a/client/src/cmdhfmfu.c
+++ b/client/src/cmdhfmfu.c
@@ -2039,6 +2039,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
bool write_special = false;
bool write_extra = false;
bool read_key = false;
+ bool verbose = false;
size_t filelen = 0;
FILE *f;
@@ -2087,6 +2088,9 @@ static int CmdHF14AMfURestore(const char *Cmd) {
cmdp++;
read_key = true;
break;
+ case 'v':
+ cmdp++;
+ verbose = true;
default:
PrintAndLogEx(WARNING, "Unknown parameter: " _RED_("'%c'"), param_getchar(Cmd, cmdp));
errors = true;
@@ -2128,10 +2132,9 @@ static int CmdHF14AMfURestore(const char *Cmd) {
return 1;
}
- // convert old format to new format, if need
- int res = convertOldMfuDump(&dump, &bytes_read);
+ int res = convert_mfu_dump_format(&dump, &bytes_read, verbose);
if (res != PM3_SUCCESS) {
- PrintAndLogEx(WARNING, "Failed convert on load to new Ultralight/NTAG format");
+ PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
free(dump);
return res;
}
diff --git a/client/src/cmdhfmfu.h b/client/src/cmdhfmfu.h
index 0f87cb3f6..eb81c8dea 100644
--- a/client/src/cmdhfmfu.h
+++ b/client/src/cmdhfmfu.h
@@ -18,19 +18,16 @@ typedef struct {
uint8_t signature[32];
//uint8_t counter[3];
uint8_t data[1024];
-} old_mfu_dump_t;
-
+} PACKED old_mfu_dump_t;
uint32_t GetHF14AMfU_Type(void);
int ul_print_type(uint32_t tagtype, uint8_t spaces);
-
void printMFUdump(mfu_dump_t *card);
void printMFUdumpEx(mfu_dump_t *card, uint16_t pages, uint8_t startpage);
int CmdHFMFUltra(const char *Cmd);
uint16_t ul_ev1_packgen_VCNEW(uint8_t *uid, uint32_t pwd);
-
uint32_t ul_ev1_otpgenA(uint8_t *uid);
typedef enum TAGTYPE_UL {
diff --git a/client/src/fileutils.c b/client/src/fileutils.c
index 4e5573747..a650e3929 100644
--- a/client/src/fileutils.c
+++ b/client/src/fileutils.c
@@ -313,6 +313,9 @@ out:
}
int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen) {
+ return saveFileJSONex(preferredName, ftype, data, datalen, true);
+}
+int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen, bool verbose) {
if (data == NULL) return PM3_EINVARG;
@@ -559,7 +562,9 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
retval = 200;
goto out;
}
- PrintAndLogEx(SUCCESS, "saved to json file " _YELLOW_("%s"), fileName);
+ if (verbose)
+ PrintAndLogEx(SUCCESS, "saved to json file " _YELLOW_("%s"), fileName);
+
json_decref(root);
out:
@@ -678,7 +683,6 @@ int createMfcKeyDump(const char *preferredName, uint8_t sectorsCnt, sector_t *e_
return PM3_SUCCESS;
}
-
int loadFile(const char *preferredName, const char *suffix, void *data, size_t maxdatalen, size_t *datalen) {
if (data == NULL) return 1;
@@ -820,6 +824,7 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
if (fgets(line, sizeof(line), f) == NULL) {
if (feof(f))
break;
+
fclose(f);
PrintAndLogEx(FAILED, "File reading error.");
retval = PM3_EFILE;
@@ -829,10 +834,14 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
if (line[0] == '#')
continue;
+ strcleanrn(line, sizeof(line));
+
int res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen);
- if (res == 0 || res == 1) {
+ if (res == 0) {
memcpy(udata + counter, buf, hexlen);
counter += hexlen;
+ } else {
+ retval = PM3_ESOFT;
}
}
fclose(f);
@@ -847,6 +856,9 @@ out:
}
int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen) {
+ return loadFileJSONex(preferredName, data, maxdatalen, datalen, true);
+}
+int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, bool verbose) {
if (data == NULL) return PM3_EINVARG;
char *fileName = filenamemcopy(preferredName, ".json");
@@ -986,7 +998,9 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
}
*datalen = sptr;
}
- PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
+ if (verbose)
+ PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
+
if (!strcmp(ctype, "settings")) {
preferences_load_callback(root);
}
@@ -1185,38 +1199,137 @@ out:
return retval;
}
-int convertOldMfuDump(uint8_t **dump, size_t *dumplen) {
- if (!dump || !dumplen || *dumplen < OLD_MFU_DUMP_PREFIX_LENGTH)
- return 1;
- // try to check new file format
- mfu_dump_t *mfu_dump = (mfu_dump_t *) *dump;
- if ((*dumplen - MFU_DUMP_PREFIX_LENGTH) / 4 - 1 == mfu_dump->pages)
- return 0;
+mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
+
+ mfu_df_e retval = MFU_DF_UNKNOWN;
+ uint8_t bcc0, bcc1;
+ uint8_t ct = 0x88;
+
+ // detect new
+ mfu_dump_t *new = (mfu_dump_t *)*dump;
+ bcc0 = ct ^ new->data[0] ^ new->data[1] ^ new->data[2];
+ bcc1 = new->data[4] ^ new->data[5] ^ new->data[6] ^ new->data[7];
+ if (bcc0 == new->data[3] && bcc1 == new->data[8]) {
+ retval = MFU_DF_NEWBIN;
+ }
+
+ // detect old
+ if (retval == MFU_DF_UNKNOWN) {
+ old_mfu_dump_t *old = (old_mfu_dump_t *)*dump;
+ bcc0 = ct ^ old->data[0] ^ old->data[1] ^ old->data[2];
+ bcc1 = old->data[4] ^ old->data[5] ^ old->data[6] ^ old->data[7];
+ if (bcc0 == old->data[3] && bcc1 == old->data[8]) {
+ retval = MFU_DF_OLDBIN;
+ }
+ }
+
+ // detect plain
+ if (retval == MFU_DF_UNKNOWN) {
+ uint8_t *plain = *dump;
+ bcc0 = ct ^ plain[0] ^ plain[1] ^ plain[2];
+ bcc1 = plain[4] ^ plain[5] ^ plain[6] ^ plain[7];
+ if ((bcc0 == plain[3]) && (bcc1 == plain[8])) {
+ retval = MFU_DF_PLAINBIN;
+ }
+ }
+
+ if (verbose) {
+ switch(retval) {
+ case MFU_DF_NEWBIN:
+ PrintAndLogEx(INFO, "detected " _GREEN_("new") " mfu dump format");
+ break;
+ case MFU_DF_OLDBIN:
+ PrintAndLogEx(INFO, "detected " _GREEN_("old") " mfu dump format");
+ break;
+ case MFU_DF_PLAINBIN:
+ PrintAndLogEx(INFO, "detected " _GREEN_("plain") " mfu dump format");
+ break;
+ case MFU_DF_UNKNOWN:
+ PrintAndLogEx(WARNING, "failed to detected mfu dump format");
+ break;
+ }
+ }
+ return retval;
+}
+
+static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
+
+ mfu_dump_t *mfu = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t));
+ if (mfu == NULL) {
+ return PM3_EMALLOC;
+ }
+
+ memcpy(mfu->data, *dump, *dumplen);
+
+ mfu->pages = *dumplen / 4 - 1;
+
+ if (verbose) {
+ PrintAndLogEx(SUCCESS, "plain mfu dump format was converted to " _GREEN_("%d") " blocks", mfu->pages + 1);
+ }
+
+ *dump = (uint8_t *)mfu;
+ *dumplen += MFU_DUMP_PREFIX_LENGTH ;
+ return PM3_SUCCESS;
+}
+
+static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
+
// convert old format
- old_mfu_dump_t *old_mfu_dump = (old_mfu_dump_t *) *dump;
+ old_mfu_dump_t *old_mfu_dump = (old_mfu_dump_t *)*dump;
size_t old_data_len = *dumplen - OLD_MFU_DUMP_PREFIX_LENGTH;
size_t new_dump_len = old_data_len + MFU_DUMP_PREFIX_LENGTH;
+
+ mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t));
+ if (mfu_dump == NULL) {
+ return PM3_EMALLOC;
+ }
- mfu_dump = (mfu_dump_t *) calloc(new_dump_len, sizeof(uint8_t));
-
- memcpy(mfu_dump->version, old_mfu_dump->version, 8);
- memcpy(mfu_dump->tbo, old_mfu_dump->tbo, 2);
+ memcpy(mfu_dump->version, old_mfu_dump->version, sizeof(mfu_dump->version));
+ memcpy(mfu_dump->tbo, old_mfu_dump->tbo, sizeof(mfu_dump->tbo));
+ memcpy(mfu_dump->signature, old_mfu_dump->signature, sizeof(mfu_dump->signature));
+
mfu_dump->tbo1[0] = old_mfu_dump->tbo1[0];
- memcpy(mfu_dump->signature, old_mfu_dump->signature, 32);
- for (int i = 0; i < 3; i++)
- mfu_dump->counter_tearing[i][3] = old_mfu_dump->tearing[i];
- memcpy(mfu_dump->data, old_mfu_dump->data, old_data_len);
+ for (int i = 0; i < 3; i++) {
+ mfu_dump->counter_tearing[i][3] = old_mfu_dump->tearing[i];
+ }
+
+ memcpy(mfu_dump->data, old_mfu_dump->data, sizeof(mfu_dump->data));
+
mfu_dump->pages = old_data_len / 4 - 1;
- // free old buffer, return new buffer
- *dumplen = new_dump_len;
+
+ if (verbose) {
+ PrintAndLogEx(SUCCESS, "old mfu dump format was converted to " _GREEN_("%d") " blocks", mfu_dump->pages + 1);
+ }
+
free(*dump);
- *dump = (uint8_t *) mfu_dump;
- PrintAndLogEx(SUCCESS, "old mfu dump format, was converted on load to " _GREEN_("%d") " pages", mfu_dump->pages + 1);
+ *dump = (uint8_t *)mfu_dump;
+ *dumplen = new_dump_len;
return PM3_SUCCESS;
}
+int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
+
+ if (!dump || !dumplen || *dumplen < OLD_MFU_DUMP_PREFIX_LENGTH) {
+ return PM3_EINVARG;
+ }
+
+ mfu_df_e res = detect_mfu_dump_format(dump, dumplen, verbose);
+
+ switch(res) {
+ case MFU_DF_NEWBIN:
+ return PM3_SUCCESS;
+ case MFU_DF_OLDBIN:
+ return convert_old_mfu_dump(dump, dumplen, verbose);
+ case MFU_DF_PLAINBIN:
+ return convert_plain_mfu_dump(dump, dumplen, verbose);
+ case MFU_DF_UNKNOWN:
+ default:
+ return PM3_ESOFT;
+ }
+}
+
static int filelist(const char *path, const char *ext, bool last, bool tentative) {
struct dirent **namelist;
int n;
diff --git a/client/src/fileutils.h b/client/src/fileutils.h
index 603144e67..cf00efb03 100644
--- a/client/src/fileutils.h
+++ b/client/src/fileutils.h
@@ -116,6 +116,7 @@ int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t
* @return 0 for ok, 1 for failz
*/
int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen);
+int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen, bool verbose);
/** STUB
* @brief Utility function to save WAVE data to a file. This method takes a preferred name, but if that
@@ -198,6 +199,8 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen);
* @return 0 for ok, 1 for failz
*/
int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen);
+int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, size_t *datalen, bool verbose);
+
/**
* @brief Utility function to load data from a DICTIONARY textfile. This method takes a preferred name.
@@ -242,14 +245,23 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
*/
int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint32_t *keycnt);
+
+typedef enum {
+ MFU_DF_UNKNOWN,
+ MFU_DF_PLAINBIN,
+ MFU_DF_OLDBIN,
+ MFU_DF_NEWBIN
+} mfu_df_e;
/**
- * @brief Utility function to check and convert old mfu dump format to new
- *
+ * @brief Utility function to check and convert plain mfu dump format to new mfu binary format.
+ * plain dumps doesn't have any extra data, like version, signature etc.
* @param dump pointer to loaded dump to check and convert format
* @param dumplen the number of bytes loaded dump and converted
- * @return 0 for ok, 1 for fails
+ * @param verbose - extra debug output
+ * @return PM3_SUCCESS for ok, PM3_ESOFT for fails
*/
-int convertOldMfuDump(uint8_t **dump, size_t *dumplen);
+int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
+mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
int searchAndList(const char *pm3dir, const char *ext);
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);
From bde4198184d369a68bb88db281bc5430e9e9f1bb Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Sun, 24 May 2020 12:51:51 +0200
Subject: [PATCH 133/527] fix hf mfu
---
client/src/cmdhfmfu.c | 69 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 10 deletions(-)
diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c
index 75afa7641..b9dc8d3a2 100644
--- a/client/src/cmdhfmfu.c
+++ b/client/src/cmdhfmfu.c
@@ -541,7 +541,7 @@ static int ul_print_default(uint8_t *data) {
sprint_bin(data + 10, 2)
);
- PrintAndLogEx(SUCCESS, "OneTimePad: %s - %s\n",
+ PrintAndLogEx(SUCCESS, "OneTimePad: %s - %s",
sprint_hex(data + 12, 4),
sprint_bin(data + 12, 4)
);
@@ -748,11 +748,13 @@ static int ulev1_print_configuration(uint32_t tagtype, uint8_t *data, uint8_t st
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Configuration"));
bool strg_mod_en = (data[0] & 2);
+
uint8_t authlim = (data[4] & 0x07);
- bool nfc_cnf_en = (data[4] & 0x08);
- bool nfc_cnf_prot_pwd = (data[4] & 0x10);
- bool cfglck = (data[4] & 0x40);
- bool prot = (data[4] & 0x80);
+ bool nfc_cnf_prot_pwd = ((data[4] & 0x08) == 0x08);
+ bool nfc_cnf_en = ((data[4] & 0x10) == 0x10);
+ bool cfglck = ((data[4] & 0x40) == 0x40);
+ bool prot = ((data[4] & 0x80) == 0x80);
+
uint8_t vctid = data[5];
PrintAndLogEx(INFO, " cfg0 [%u/0x%02X]: %s", startPage, startPage, sprint_hex(data, 4));
@@ -838,7 +840,7 @@ static int ulev1_print_configuration(uint32_t tagtype, uint8_t *data, uint8_t st
PrintAndLogEx(INFO, " - Max number of password attempts is " _YELLOW_("%d"), authlim);
PrintAndLogEx(INFO, " - NFC counter %s", (nfc_cnf_en) ? "enabled" : "disabled");
- PrintAndLogEx(INFO, " - NFC counter %s", (nfc_cnf_prot_pwd) ? "not protected" : "password protection enabled");
+ PrintAndLogEx(INFO, " - NFC counter %s", (nfc_cnf_prot_pwd) ? "password protection enabled" : "not protected");
PrintAndLogEx(INFO, " - user configuration %s", cfglck ? "permanently locked" : "writeable");
PrintAndLogEx(INFO, " - %s access is protected with password", prot ? "read and write" : "write");
@@ -850,6 +852,7 @@ static int ulev1_print_configuration(uint32_t tagtype, uint8_t *data, uint8_t st
}
static int ulev1_print_counters(void) {
+ PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Counters"));
uint8_t tear[1] = {0};
uint8_t counter[3] = {0, 0, 0};
@@ -859,7 +862,7 @@ static int ulev1_print_counters(void) {
len = ulev1_readCounter(i, counter, sizeof(counter));
if (len == 3) {
PrintAndLogEx(INFO, " [%0d]: %s", i, sprint_hex(counter, 3));
- PrintAndLogEx(SUCCESS, " - %02X tearing %s", tear[0], (tear[0] == 0xBD) ? "Ok" : "failure");
+ PrintAndLogEx(SUCCESS, " - %02X tearing (" _GREEN_("%s") ")", tear[0], (tear[0] == 0xBD) ? "ok" : "failure");
}
}
return len;
@@ -971,6 +974,20 @@ static int ulev1_print_version(uint8_t *data) {
return PM3_SUCCESS;
}
+static int ntag_print_counter(void) {
+ // NTAG has one counter/tearing. At address 0x02.
+ PrintAndLogEx(NORMAL, "");
+ PrintAndLogEx(INFO, "--- " _CYAN_("Tag Counter"));
+ uint8_t tear[1] = {0};
+ uint8_t counter[3] = {0, 0, 0};
+ uint16_t len;
+ len = ulev1_readTearing(0x02, tear, sizeof(tear));
+ len = ulev1_readCounter(0x02, counter, sizeof(counter));
+ PrintAndLogEx(INFO, " [02]: %s", sprint_hex(counter, 3));
+ PrintAndLogEx(SUCCESS, " - %02X tearing (" _GREEN_("%s")")", tear[0], (tear[0] == 0xBD) ? "ok" : "failure");
+ return len;
+}
+
/*
static int ulc_magic_test(){
// Magic Ultralight test
@@ -1271,6 +1288,12 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
}
// NTAG counters?
+ if ((tagtype & (NTAG_213 | NTAG_213_F | NTAG_215 | NTAG_216))) {
+ if (ntag_print_counter()) {
+ // failed - re-select
+ if (ul_auth_select(&card, tagtype, hasAuthKey, authkeyptr, pack, sizeof(pack)) == PM3_ESOFT) return PM3_ESOFT;
+ }
+ }
// Read signature
if ((tagtype & (UL_EV1_48 | UL_EV1_128 | UL_EV1 | UL_NANO_40 | NTAG_213 | NTAG_213_F | NTAG_215 | NTAG_216 | NTAG_216_F | NTAG_I2C_1K | NTAG_I2C_2K | NTAG_I2C_1K_PLUS | NTAG_I2C_2K_PLUS))) {
@@ -1942,16 +1965,42 @@ static int CmdHF14AMfUDump(const char *Cmd) {
if (hasAuthKey) {
uint8_t dummy_pack[] = {0, 0};
ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
- } else
+ } else {
ul_select(&card);
+ }
ulev1_getVersion(get_version, sizeof(get_version));
- for (uint8_t n = 0; n < 3; ++n) {
- ulev1_readTearing(n, &get_counter_tearing[n][3], 1);
+
+ // ULEV-1 has 3 counters
+ uint8_t n = 0;
+
+ // NTAG has 1 counter, at 0x02
+ if ((tagtype & (NTAG_213 | NTAG_213_F | NTAG_215 | NTAG_216))) {
+ n = 2;
+ }
+
+ // NTAG can have nfc counter pwd protection enabled
+ for (; n < 3; n++) {
+
+ if (hasAuthKey) {
+ uint8_t dummy_pack[] = {0, 0};
+ ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
+ } else {
+ ul_select(&card);
+ }
ulev1_readCounter(n, &get_counter_tearing[n][0], 3);
+
+ if (hasAuthKey) {
+ uint8_t dummy_pack[] = {0, 0};
+ ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
+ } else {
+ ul_select(&card);
+ }
+ ulev1_readTearing(n, &get_counter_tearing[n][3], 1);
}
DropField();
+
if (hasAuthKey) {
uint8_t dummy_pack[] = {0, 0};
ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
From 8a72370f509d5338d7b7192491b1bf32a3bcc2e7 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Sun, 24 May 2020 12:52:02 +0200
Subject: [PATCH 134/527] add document
---
doc/mfu_binary_format_notes.md | 101 +++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100644 doc/mfu_binary_format_notes.md
diff --git a/doc/mfu_binary_format_notes.md b/doc/mfu_binary_format_notes.md
new file mode 100644
index 000000000..dfde0da7a
--- /dev/null
+++ b/doc/mfu_binary_format_notes.md
@@ -0,0 +1,101 @@
+# Notes on MFU binary formats
+
+ - new mfu format
+ - old mfu format
+ - plain mfu format
+ - future mfu format
+
+## New mfu format
+The new mfu binary format was created to compensate for different manufactures tag functions.
+Like UL-Ev1 has three counter and tearing bytes, while NTAG only has one counter and tearing byte.
+PACK was removed from header, since its just normally part of the tag memory, unreadable, but when
+a proxmark3 dumps a tag and we have pwd/pack, we add those to their normal location in memory.
+This makes memory not a exact memory dump from a tag, but a "what it should have looked like" if we could read all memory
+
+```
+// New Ultralight/NTAG dump file format
+// Length must be aligned to 4 bytes (UL/NTAG page)
+#define MFU_DUMP_PREFIX_LENGTH 56
+
+typedef struct {
+ uint8_t version[8];
+ uint8_t tbo[2];
+ uint8_t tbo1[1];
+ uint8_t pages; // max page number in dump
+ uint8_t signature[32];
+ uint8_t counter_tearing[3][4]; // 3 bytes counter, 1 byte tearing flag
+ uint8_t data[1024];
+} PACKED mfu_dump_t;
+```
+
+## Old mfu format
+The old binary format saved the extra data on tag in order for the Proxmark3 to able to simulate a real tag.
+
+```
+// Old Ultralight/NTAG dump file format
+#define OLD_MFU_DUMP_PREFIX_LENGTH 48
+
+typedef struct {
+ uint8_t version[8];
+ uint8_t tbo[2];
+ uint8_t tearing[3];
+ uint8_t pack[2];
+ uint8_t tbo1[1];
+ uint8_t signature[32];
+ uint8_t data[1024];
+} old_mfu_dump_t;
+```
+
+## Plain mfu format
+The first binary format for MFU was just a memory dump from the tag block 0 to end.
+No extra data was saved.
+```
+ uint8_t data[1024];
+```
+
+## future mfu format
+For developers of apps and other tools, like libnfc, we don't recommend using binary formats.
+We decided to adopt a JSON based format, which is much more flexible to changes of new tag functionality.
+
+Example
+```
+{
+ "Created": "proxmark3",
+ "FileType": "mfu",
+ "Card": {
+ "UID": "04F654CAFC388",
+ "Version": "0004030101000B0",
+ "TBO_0": "000",
+ "TBO_1": "0",
+ "Signature": "BC9BFD4B550C16B2B5A5ABA10B644A027B4CB03DDB46F94D992DC0FB02E0C3F",
+ "Counter0": "00000",
+ "Tearing0": "BD",
+ "Counter1": "00000",
+ "Tearing1": "BD",
+ "Counter2": "00000",
+ "Tearing2": "BD"
+ },
+ "blocks": {
+ "0": "04F6542",
+ "1": "CAFC388",
+ "2": "8E48000",
+ "3": "E110120",
+ "4": "0103A00",
+ "5": "340300F",
+ "6": "0000000",
+ "7": "0000000",
+ "8": "0000000",
+ "9": "0000000",
+ "10": "0000000",
+ "11": "0000000",
+ "12": "1122334",
+ "13": "0000000",
+ "14": "0000000",
+ "15": "0000000",
+ "16": "000000F",
+ "17": "0005000",
+ "18": "0000000",
+ "19": "0000000"
+ }
+}
+```
From 8aebb8ef8ebf1f6301d8992c9054c87995cf4a01 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Sun, 24 May 2020 12:52:11 +0200
Subject: [PATCH 135/527] textual
---
CHANGELOG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8edd91099..8fd7150b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
## [ice coffee.4.][2020-05-21]
+ - Add doc/mfu_binary_format_notes.md (@iceman1001)
+ - Fix `hf mfu dump` - now reads Ulev1 3counter vs NTAG 1 counters (@iceman1001)
+ - Fix `hf mfu info` - now print correct cfg1 - nfc protection (@iceman1001)
- Fix `hf mfu eload` - now detects and converts between plain/old/new mfu binary format (@iceman1001)
- Change log files moved to subfolders (@doegex)
- Change lib lua unbundled. (@doegex)
From acce16f6487abebb8adc96f1fab135eed743cd84 Mon Sep 17 00:00:00 2001
From: Iceman
Date: Sun, 24 May 2020 12:56:08 +0200
Subject: [PATCH 136/527] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8222032f2..ba17074d3 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@
|[Notes on UART](/doc/uart_notes.md)|[Notes on Termux / Android](/doc/termux_notes.md)|[Notes on paths](/doc/path_notes.md)|
|[Notes on frame format](/doc/new_frame_format.md)|[Notes on tracelog / wireshark](/doc/trace_notes.md)|[Notes on EMV](/doc/emv_notes.md)|
|[Notes on external flash](/doc/ext_flash_notes.md)|[Notes on loclass](/doc/loclass_notes.md)|[Notes on Coverity Scan Config & Run](/doc/md/Development/Coverity-Scan-Config-%26-Run.md)|
-|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|||
+|[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|[Notes on MFU binary format](/doc/mfu_binary_format_notes.md)||
|[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)||
From 243771fa3d51d0e7fa728d654e5b3fe19d59f0f6 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 16:07:17 +0200
Subject: [PATCH 137/527] changelog
---
CHANGELOG.md | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8fd7150b2..be3956739 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,14 +3,17 @@ 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]
-
-## [ice coffee.4.][2020-05-21]
- Add doc/mfu_binary_format_notes.md (@iceman1001)
- Fix `hf mfu dump` - now reads Ulev1 3counter vs NTAG 1 counters (@iceman1001)
- Fix `hf mfu info` - now print correct cfg1 - nfc protection (@iceman1001)
- Fix `hf mfu eload` - now detects and converts between plain/old/new mfu binary format (@iceman1001)
- - Change log files moved to subfolders (@doegex)
- - Change lib lua unbundled. (@doegex)
+ - Change, hitag2crack now integrated into main Makefile, tests added (@doegox)
+ - Add `make check` mechanics (@doegox)
+ - Change, log files moved to subfolders (@doegox)
+ - Change, use system Lua library if available (@doegox)
+ - Fix release version information (@doegox)
+
+## [ice coffee.4.9237][2020-05-21]
- Updated documentation (@doegox, @iceman1001)
- Change `pm3test.sh` - more regression tests to (@doegox, @iceman1001)
- Change `hf 15 dump` - now supports basic json format (@iceman1001)
From 0653feaec85d8256ebd8543ce0c499742caa871d Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 20:35:09 +0200
Subject: [PATCH 138/527] Use system whereami if available
---
client/Makefile | 15 ++++++++++++++-
doc/md/Development/Maintainers.md | 1 +
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/client/Makefile b/client/Makefile
index 363ff0089..f919a9388 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -89,6 +89,14 @@ ifneq ($(SKIPLUASYSTEM),1)
endif
endif
+ifneq ($(SKIPWHEREAMISYSTEM),1)
+ ifneq (,$(wildcard /usr/include/whereami.h))
+ WAILIBINC =
+ WAILIB = -lwhereami
+ WAISYSTEM = 1
+ endif
+endif
+
ifneq ($(SKIPBT),1)
BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
endif
@@ -188,7 +196,10 @@ else
$(info native BT support: Bluez not found, disabled)
endif
ifeq ($(LUASYSTEM),1)
-$(info system LUA: Lua5.2 found)
+$(info Lua library: system library found)
+endif
+ifeq ($(WAISYSTEM),1)
+$(info Whereami library: system library found)
endif
$(info compiler version: $(shell $(CC) --version|head -n 1))
$(info ===================================================================)
@@ -443,8 +454,10 @@ cliparser:
$(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) all
whereami:
+ifneq ($(WAISYSTEM),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) all
+endif
# common libraries:
mbedtls:
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 09cddede7..5d1400a7f 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -62,6 +62,7 @@ It's also possible to skip parts even if libraries are present in the compilatio
* `make client SKIPQT=1` to skip GUI even if Qt is present
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
* `make client SKIPLUASYSTEM=1` to skip system Lua lib even if liblua5.2 is present, use embedded Lua lib instead
+* `make client SKIPWHEREAMISYSTEM=1` to skip system Whereami lib even if libwhereami is present, use embedded whereami lib instead
If you're cross-compiling, these ones might be useful:
From 9d97962759e089e46c3087e92ed3a4e594ea81d3 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 21:51:39 +0200
Subject: [PATCH 139/527] use system jansson if available
---
CHANGELOG.md | 2 +
client/CMakeLists.txt | 1 +
client/Makefile | 24 +++-
client/android/CMakeLists.txt | 1 +
client/deps/jansson.cmake | 1 -
client/deps/jansson/Makefile | 1 -
client/deps/jansson/jansson.h | 8 --
client/src/emv/emvjson.h | 1 +
.../jansson/path.c => src/jansson_path.c} | 105 +++++++++++++++++-
client/src/jansson_path.h | 30 +++++
10 files changed, 158 insertions(+), 16 deletions(-)
rename client/{deps/jansson/path.c => src/jansson_path.c} (71%)
create mode 100644 client/src/jansson_path.h
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be3956739..d9d62254f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Add `make check` mechanics (@doegox)
- Change, log files moved to subfolders (@doegox)
- Change, use system Lua library if available (@doegox)
+ - Change, use system Jansson library if available (@doegox)
+ - Change, use system Whereami library if available (@doegox)
- Fix release version information (@doegox)
## [ice coffee.4.9237][2020-05-21]
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index a56ea5a9a..64cfca623 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -165,6 +165,7 @@ set (TARGET_SOURCES
src/fileutils.c
src/flash.c
src/graph.c
+ src/jansson_path.c
src/preferences.c
src/pm3_binlib.c
src/pm3_bitlib.c
diff --git a/client/Makefile b/client/Makefile
index f919a9388..d3c969b9c 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -82,17 +82,27 @@ ZLIB = $(OBJDIR)/libz.a
ifneq ($(SKIPLUASYSTEM),1)
LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
- ifneq ($(LUAINCLUDES),)
+ ifneq ($(LUALDLIBS),)
LUALIB = $(LUALDLIBS)
LUALIBINC = $(LUAINCLUDES)
LUASYSTEM = 1
endif
endif
+ifneq ($(SKIPJANSSONSYSTEM),1)
+ JANSSONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags jansson 2>/dev/null)
+ JANSSONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs jansson 2>/dev/null)
+ ifneq ($(JANSSONLDLIBS),)
+ JANSSONLIB = $(JANSSONLDLIBS)
+ JANSSONLIBINC = $(JANSSONINCLUDES)
+ JANSSONSYSTEM = 1
+ endif
+endif
+
ifneq ($(SKIPWHEREAMISYSTEM),1)
ifneq (,$(wildcard /usr/include/whereami.h))
- WAILIBINC =
WAILIB = -lwhereami
+ WAILIBINC =
WAISYSTEM = 1
endif
endif
@@ -195,6 +205,9 @@ $(info native BT support: Bluez found, enabled)
else
$(info native BT support: Bluez not found, disabled)
endif
+ifeq ($(JANSSONSYSTEM),1)
+$(info Jansson library: system library found)
+endif
ifeq ($(LUASYSTEM),1)
$(info Lua library: system library found)
endif
@@ -339,9 +352,8 @@ CMDSRCS = crapto1/crapto1.c \
wiegand_formats.c \
wiegand_formatutils.c \
cardhelper.c \
- preferences.c
-
-
+ preferences.c \
+ jansson_path.c
COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
@@ -430,8 +442,10 @@ ifneq ($(LUASYSTEM),1)
endif
jansson:
+ifneq ($(JANSSONSYSTEM),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
+endif
tinycbor:
$(info [*] MAKE $@)
diff --git a/client/android/CMakeLists.txt b/client/android/CMakeLists.txt
index 5b417ff63..ddaae2cd2 100644
--- a/client/android/CMakeLists.txt
+++ b/client/android/CMakeLists.txt
@@ -145,6 +145,7 @@ add_library(pm3rrg_rdv4 SHARED
${PM3_ROOT}/client/src/cmdlfpcf7931.c
${PM3_ROOT}/client/src/cmdhfmfhard.c
${PM3_ROOT}/client/src/cmdusart.c
+ ${PM3_ROOT}/client/src/jansson_path.c
# android resources
jni_tools.c
pm3_main.c
diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake
index a95ff0baf..c91a47047 100644
--- a/client/deps/jansson.cmake
+++ b/client/deps/jansson.cmake
@@ -9,7 +9,6 @@ add_library(pm3rrg_rdv4_jansson STATIC
jansson/strbuffer.c
jansson/strconv.c
jansson/utf.c
- jansson/path.c
jansson/value.c
)
diff --git a/client/deps/jansson/Makefile b/client/deps/jansson/Makefile
index 5073b78a1..b51c4a77c 100644
--- a/client/deps/jansson/Makefile
+++ b/client/deps/jansson/Makefile
@@ -13,7 +13,6 @@ MYSRCS = \
strbuffer.c \
strconv.c \
utf.c \
- path.c \
value.c
LIB_A = libjansson.a
diff --git a/client/deps/jansson/jansson.h b/client/deps/jansson/jansson.h
index 0f868c2f2..75cbb5d51 100644
--- a/client/deps/jansson/jansson.h
+++ b/client/deps/jansson/jansson.h
@@ -302,14 +302,6 @@ int json_equal(const json_t *json1, const json_t *json2);
json_t *json_copy(json_t *json) JANSSON_ATTRS(warn_unused_result);
json_t *json_deep_copy(const json_t *json) JANSSON_ATTRS(warn_unused_result);
-json_t *json_path_get(const json_t *json, const char *path);
-int json_path_set_new(json_t *json, const char *path, json_t *value, size_t flags, json_error_t *error);
-
-static JSON_INLINE
-int json_path_set(json_t *json, const char *path, json_t *value, size_t flags, json_error_t *error) {
- return json_path_set_new(json, path, json_incref(value), flags, error);
-}
-
/* decoding */
#define JSON_REJECT_DUPLICATES 0x1
diff --git a/client/src/emv/emvjson.h b/client/src/emv/emvjson.h
index f4f3d4fb4..e90aa42d8 100644
--- a/client/src/emv/emvjson.h
+++ b/client/src/emv/emvjson.h
@@ -13,6 +13,7 @@
#include "common.h"
#include "jansson.h"
+#include "jansson_path.h"
#include "tlv.h"
typedef struct {
diff --git a/client/deps/jansson/path.c b/client/src/jansson_path.c
similarity index 71%
rename from client/deps/jansson/path.c
rename to client/src/jansson_path.c
index 11964ec6e..0c0d76a05 100644
--- a/client/deps/jansson/path.c
+++ b/client/src/jansson_path.c
@@ -11,7 +11,110 @@
#include
#include "jansson.h"
-#include "jansson_private.h"
+#include "jansson_path.h"
+
+////// memory.c private functions
+
+/* C89 allows these to be macros */
+#undef malloc
+#undef free
+
+/* memory function pointers */
+static json_malloc_t do_malloc = malloc;
+static json_free_t do_free = free;
+
+static void *jsonp_malloc(size_t size) {
+ if (!size)
+ return NULL;
+
+ return (*do_malloc)(size);
+}
+
+static void jsonp_free(void *ptr) {
+ if (!ptr)
+ return;
+
+ (*do_free)(ptr);
+}
+
+static char *jsonp_strndup(const char *str, size_t len) {
+ char *new_str;
+
+ new_str = jsonp_malloc(len + 1);
+ if (!new_str)
+ return NULL;
+
+ memcpy(new_str, str, len);
+ new_str[len] = '\0';
+ return new_str;
+}
+
+static char *jsonp_strdup(const char *str) {
+ return jsonp_strndup(str, strlen(str));
+}
+
+////// error.c private functions
+
+static void jsonp_error_set_source(json_error_t *error, const char *source) {
+ size_t length;
+
+ if (!error || !source)
+ return;
+
+ length = strlen(source);
+ if (length < JSON_ERROR_SOURCE_LENGTH) {
+ strncpy(error->source, source, JSON_ERROR_SOURCE_LENGTH - 1);
+ } else {
+ size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
+ memcpy(error->source, "...", 3);
+ strncpy(error->source + 3, source + extra, length - extra + 1);
+ }
+}
+
+static void jsonp_error_init(json_error_t *error, const char *source) {
+ if (error) {
+ error->text[0] = '\0';
+ error->line = -1;
+ error->column = -1;
+ error->position = 0;
+ if (source)
+ jsonp_error_set_source(error, source);
+ else
+ error->source[0] = '\0';
+ }
+}
+
+static void jsonp_error_vset(json_error_t *error, int line, int column,
+ size_t position, enum json_error_code code,
+ const char *msg, va_list ap) {
+ if (!error)
+ return;
+
+ if (error->text[0] != '\0') {
+ /* error already set */
+ return;
+ }
+
+ error->line = line;
+ error->column = column;
+ error->position = (int)position;
+
+ vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH - 1, msg, ap);
+ error->text[JSON_ERROR_TEXT_LENGTH - 2] = '\0';
+ error->text[JSON_ERROR_TEXT_LENGTH - 1] = code;
+}
+
+static void jsonp_error_set(json_error_t *error, int line, int column,
+ size_t position, enum json_error_code code,
+ const char *msg, ...) {
+ va_list ap;
+ va_start(ap, msg);
+ jsonp_error_vset(error, line, column, position, code, msg, ap);
+ va_end(ap);
+}
+
+
+// original path.c from jansson fork
json_t *json_path_get(const json_t *json, const char *path) {
static const char root_chr = '$', array_open = '[';
diff --git a/client/src/jansson_path.h b/client/src/jansson_path.h
new file mode 100644
index 000000000..7737c1634
--- /dev/null
+++ b/client/src/jansson_path.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2009-2016 Petri Lehtinen
+ *
+ * Jansson is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#ifndef JANSSON_PATH_H
+#define JANSSON_PATH_H
+
+//#include
+#include /* for size_t */
+//#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+json_t *json_path_get(const json_t *json, const char *path);
+int json_path_set_new(json_t *json, const char *path, json_t *value, size_t flags, json_error_t *error);
+
+static JSON_INLINE
+int json_path_set(json_t *json, const char *path, json_t *value, size_t flags, json_error_t *error) {
+ return json_path_set_new(json, path, json_incref(value), flags, error);
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
From 72acec580637862917466a832730c8430a2051d8 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Sun, 24 May 2020 23:23:55 +0200
Subject: [PATCH 140/527] Makefile & CMake rework
---
client/Makefile | 634 ++++++++++++++++-----------
client/deps/CMakeLists.txt | 40 +-
client/deps/amiibo.cmake | 8 +
client/deps/amiitool/Makefile | 2 +-
client/deps/amiitool/amiibo.c | 4 +-
client/deps/amiitool/drbg.c | 2 +-
client/deps/mbedtls.cmake | 1 +
client/deps/zlib.cmake | 1 +
client/src/cmdflashmem.c | 4 +-
client/src/cmdhffelica.c | 2 +-
client/src/cmdhficlass.c | 2 +-
client/src/cmdhfmfdes.c | 2 +-
client/src/cmdhfmfdesfire_disabled.c | 4 +-
client/src/cmdhfmfhard.c | 4 +-
client/src/cmdhfmfu.c | 2 +-
client/src/emv/crypto_polarssl.c | 4 +-
client/src/emv/emv_roca.c | 2 +-
client/src/emv/test/cryptotest.c | 26 +-
client/src/fido/fidocore.c | 2 +-
client/src/loclass/elite_crack.c | 2 +-
client/src/loclass/ikeys.c | 2 +-
client/src/mifare/desfire_crypto.c | 4 +-
client/src/scripting.c | 4 +-
23 files changed, 467 insertions(+), 291 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index d3c969b9c..59c08f144 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -4,11 +4,6 @@
# the license.
#-----------------------------------------------------------------------------
-# reveng will compile without macros, but these may be useful:
-# Add -DBMPMACRO to use bitmap size constant macros (edit config.h)
-# Add -DNOFORCE to disable the -F switch
-# Add -DPRESETS to compile with preset models (edit config.h)
-
# Must be called before any Makefile include
ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
@@ -22,44 +17,45 @@ vpath %.dic dictionaries
OBJDIR = obj
LDLIBS ?= -L/usr/local/lib
-LDLIBS += -lreadline -lm
-ifneq ($(SKIPPTHREAD),1)
-LDLIBS += -lpthread
+
+ifeq ($(platform),Darwin)
+ # cf brew info qt: qt not symlinked anymore
+ PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
endif
-# RPi Zero gcc requires -latomic
-# but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
-# doesn't recognize option --as-needed
-ifneq ($(platform),Darwin)
- LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
-endif
+###################
+# local libraries #
+###################
-# local libraries
-LUALIBPATH = ./deps/liblua
-LUALIBINC = -I$(LUALIBPATH)
-LUALIB = $(LUALIBPATH)/liblua.a
-JANSSONLIBPATH = ./deps/jansson
-JANSSONLIBINC = -I$(JANSSONLIBPATH)
-JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
-CBORLIBPATH = ./deps/tinycbor
-CBORLIBINC = -I$(CBORLIBPATH)
-CBORLIB = $(CBORLIBPATH)/tinycbor.a
-REVENGLIBPATH = ./deps/reveng
-REVENGLIBINC = -I$(REVENGLIBPATH)
-REVENGLIB = $(REVENGLIBPATH)/libreveng.a
+## Amiibo
AMIIBOLIBPATH = ./deps/amiitool
AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
-HARDNESTEDLIBPATH = ./deps/hardnested
-HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
-HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
+
+## Tinycbor
+CBORLIBPATH = ./deps/tinycbor
+CBORLIBINC = -I$(CBORLIBPATH)
+CBORLIB = $(CBORLIBPATH)/tinycbor.a
+
+## Cliparser / Argtable3
CLIPARSERLIBPATH = ./deps/cliparser
CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
-WAILIBPATH = ./deps/whereami
-WAILIBINC = -I$(WAILIBPATH)
-WAILIB = $(WAILIBPATH)/libwhereami.a
+## Hardnested
+HARDNESTEDLIBPATH = ./deps/hardnested
+HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
+HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
+
+## Jansson
+JANSSONLIBPATH = ./deps/jansson
+JANSSONLIBINC = -I$(JANSSONLIBPATH)
+JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
+
+## Lua
+LUALIBPATH = ./deps/liblua
+LUALIBINC = -I$(LUALIBPATH)
+LUALIB = $(LUALIBPATH)/liblua.a
LUAPLATFORM = generic
ifneq (,$(findstring MINGW,$(platform)))
LUAPLATFORM = mingw
@@ -72,85 +68,195 @@ else
endif
endif
-# common libraries
+## Reveng
+REVENGLIBPATH = ./deps/reveng
+REVENGLIBINC = -I$(REVENGLIBPATH)
+REVENGLIB = $(REVENGLIBPATH)/libreveng.a
+
+## Whereami
+WAILIBPATH = ./deps/whereami
+WAILIBINC = -I$(WAILIBPATH)
+WAILIB = $(WAILIBPATH)/libwhereami.a
+
+##########################
+# common local libraries #
+##########################
+
+## mbed TLS
MBEDTLSLIBPATH = ../common/mbedtls
+MBEDTLSLIBINC = -I$(MBEDTLSLIBPATH)
MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
+
+## Zlib
ZLIBPATH = ../common/zlib
+ZLIBINC = -I$(ZLIBPATH)
ZLIB = $(OBJDIR)/libz.a
-# system libraries
-ifneq ($(SKIPLUASYSTEM),1)
- LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
- LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
- ifneq ($(LUALDLIBS),)
- LUALIB = $(LUALDLIBS)
- LUALIBINC = $(LUAINCLUDES)
- LUASYSTEM = 1
- endif
-endif
+########################################################
+# optional system libraries to replace local libraries #
+########################################################
+## Amiibo
+# not distributed as system library
+LDLIBS += $(AMIIBOLIB)
+INCLUDES += $(AMIIBOLIBINC)
+
+## Tinycbor
+# not distributed as system library
+LDLIBS += $(CBORLIB)
+INCLUDES += $(CBORLIBINC)
+
+## Cliparser / Argtable3
+# not distributed as system library
+LDLIBS += $(CLIPARSERLIB)
+INCLUDES += $(CLIPARSERLIBINC)
+
+## Hardnested
+# not distributed as system library
+LDLIBS += $(HARDNESTEDLIB)
+INCLUDES += $(HARDNESTEDLIBINC)
+
+## Jansson
ifneq ($(SKIPJANSSONSYSTEM),1)
JANSSONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags jansson 2>/dev/null)
JANSSONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs jansson 2>/dev/null)
ifneq ($(JANSSONLDLIBS),)
JANSSONLIB = $(JANSSONLDLIBS)
JANSSONLIBINC = $(JANSSONINCLUDES)
- JANSSONSYSTEM = 1
+ JANSSON_FOUND = 1
endif
endif
+LDLIBS += $(JANSSONLIB)
+INCLUDES += $(JANSSONLIBINC)
+## Lua
+ifneq ($(SKIPLUASYSTEM),1)
+ LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
+ LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
+ ifneq ($(LUALDLIBS),)
+ LUALIB = $(LUALDLIBS)
+ LUALIBINC = $(LUAINCLUDES)
+ LUA_FOUND = 1
+ endif
+endif
+LDLIBS += $(LUALIB)
+INCLUDES += $(LUALIBINC)
+
+## mbed TLS
+# system library cannot be used because it is compiled by default without CMAC support
+LDLIBS +=$(MBEDTLSLIB)
+INCLUDES += $(MBEDTLSLIBINC)
+
+## Reveng
+# not distributed as system library
+LDLIBS += $(REVENGLIB)
+INCLUDES += $(REVENGLIBINC)
+
+## Whereami
ifneq ($(SKIPWHEREAMISYSTEM),1)
ifneq (,$(wildcard /usr/include/whereami.h))
WAILIB = -lwhereami
WAILIBINC =
- WAISYSTEM = 1
+ WAI_FOUND = 1
endif
endif
+LDLIBS += $(WAILIB)
+INCLUDES += $(WAILIBINC)
-ifneq ($(SKIPBT),1)
- BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
+## Zlib
+# system library useable? Need to recompress hardnested tables?
+LDLIBS +=$(ZLIB)
+INCLUDES += $(ZLIBINC)
+
+####################
+# system libraries #
+####################
+
+## Atomic
+# RPi Zero gcc requires -latomic
+# but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
+# doesn't recognize option --as-needed
+ifneq ($(platform),Darwin)
+ LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
endif
+## Bluez (optional)
+ifneq ($(SKIPBT),1)
+ BTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags bluez 2>/dev/null)
+ BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
+ ifneq ($(BTLDLIBS),)
+ BTLIB = $(BTLDLIBS)
+ BTLIBINC = $(BTINCLUDES)
+ BT_FOUND = 1
+ endif
+endif
+LDLIBS += $(BTLIB)
+INCLUDES += $(BTLIBINC)
+
+## Readline
+ifeq ($(platform),Darwin)
+ LDLIBS += -L/usr/local/opt/readline/lib
+ INCLUDES += -I/usr/local/opt/readline/include
+endif
+LDLIBS += -lreadline
+
+## Math
+LDLIBS += -lm
+
+## Pthread
+# Some have no pthread, e.g. termux
+ifneq ($(SKIPPTHREAD),1)
+ LDLIBS += -lpthread
+endif
+
+## QT5 (or QT4 fallback) (optional)
ifneq ($(SKIPQT),1)
# Check for correctly configured Qt5
QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/moc
UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/uic
- ifeq ($(QTINCLUDES), )
- # if Qt5 not found check for correctly configured Qt4
+ ifneq ($(QTLDLIBS),)
+ QT5_FOUND = 1
+ else
+ # if Qt5 not found check for correctly configured Qt4
QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags QtCore QtGui 2>/dev/null)
QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs QtCore QtGui 2>/dev/null)
MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=moc_location QtCore)
UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
- else
- # On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
- QT5FOUND = 1
endif
- ifeq ($(QTINCLUDES), )
- # if both pkg-config commands failed, search in common places
- ifneq ($(QTDIR), )
- QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
- QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
+ ifeq ($(QTLDLIBS),)
+ # if both pkg-config commands failed, search in common places
+ ifneq ($(QTDIR),)
ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
- QTINCLUDES += -I$(QTDIR)/include/QtWidgets
- QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
- QT5FOUND = 1
+ # QT5
+ QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
+ QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
+ QT5_FOUND = 1
+ else
+ # QT4
+ QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
+ QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
endif
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
endif
endif
+ ifneq ($(QTLDLIBS),)
+ QT_FOUND = 1
+ endif
endif
+LDLIBS += $(QTLDLIBS)
+CXXINCLUDES += $(QTINCLUDES)
-LIBS = $(LUALIBINC) $(MBEDTLSLIBINC) $(JANSSONLIBINC) $(CBORLIBINC) $(ZLIBINC) $(REVENGLIBINC) $(AMIIBOLIBINC) $(HARDNESTEDLIBINC) $(CLIPARSERLIBINC) $(WAILIBINC)
-INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
+#######################################################################################################
CFLAGS ?= $(DEFCFLAGS)
-
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
-PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
+PM3CFLAGS = $(CFLAGS)
+PM3CFLAGS += -I./src -I../include -I../common -I../common_fpga $(INCLUDES)
# WIP Testing
-#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
+#PM3CFLAGS += -std=c11 -pedantic
+
PREFIX ?= /usr/local
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
@@ -160,220 +266,254 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -D_ISOC99_SOURCE
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif
-ifeq ($(platform),Darwin)
- OBJCSRCS = util_darwin.m
- LDFLAGS += -framework Foundation -framework AppKit
- LDLIBS := -L/usr/local/opt/readline/lib $(LDLIBS)
- LIBS := -I/usr/local/opt/readline/include $(LIBS)
- # cf brew info qt: qt not symlinked anymore
- PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
-endif
-CXXFLAGS ?= -Wall -Werror -O3
-PM3CXXFLAGS = $(CXXFLAGS) -I../include
-
-ifneq ($(BTLDLIBS),)
+ifeq ($(BT_FOUND),1)
PM3CFLAGS += -DHAVE_BLUEZ
endif
-ifneq ($(QTLDLIBS),)
- QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
- QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
+CXXFLAGS ?= -Wall -Werror -O3
+PM3CXXFLAGS = $(CXXFLAGS)
+PM3CXXFLAGS += -I../include
+
+ifeq ($(QT_FOUND),1)
PM3CFLAGS += -DHAVE_GUI
PM3CXXFLAGS += -DQT_NO_DEBUG
- ifeq ($(QT5FOUND),1)
+ ifeq ($(QT5_FOUND),1)
+ # On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
PM3CXXFLAGS += -fPIC -std=c++11
endif
-else
- QTGUISRCS = guidummy.cpp
- QTGUIOBJS = $(OBJDIR)/guidummy.o
endif
+PM3LDFLAGS = $(LDFLAGS)
+ifeq ($(platform),Darwin)
+ PM3LDFLAGS += -framework Foundation -framework AppKit
+endif
+
+###################
+# printing status #
+###################
+
$(info ===================================================================)
$(info Client platform: $(platform))
+
ifeq ($(SKIPQT),1)
-$(info GUI support: skipped)
-else ifneq ($(QTLDLIBS),)
-$(info GUI support: QT found, enabled)
+ $(info GUI support: skipped)
+else ifeq ($(QT_FOUND),1)
+ ifeq ($(QT5_FOUND),1)
+ $(info GUI support: QT5 found, enabled)
+ else
+ $(info GUI support: QT4 found, enabled)
+ endif
else
-$(info GUI support: QT not found, disabled)
+ $(info GUI support: QT not found, disabled)
endif
+
ifeq ($(SKIPBT),1)
-$(info native BT support: skipped)
+ $(info native BT support: skipped)
else ifneq ($(BTLDLIBS),)
-$(info native BT support: Bluez found, enabled)
+ $(info native BT support: Bluez found, enabled)
else
-$(info native BT support: Bluez not found, disabled)
+ $(info native BT support: Bluez not found, disabled)
endif
-ifeq ($(JANSSONSYSTEM),1)
-$(info Jansson library: system library found)
+
+ifeq ($(JANSSON_FOUND),1)
+ $(info Jansson library: system library found)
endif
-ifeq ($(LUASYSTEM),1)
-$(info Lua library: system library found)
+
+ifeq ($(LUA_FOUND),1)
+ $(info Lua library: system library found)
endif
-ifeq ($(WAISYSTEM),1)
-$(info Whereami library: system library found)
+
+ifeq ($(WAI_FOUND),1)
+ $(info Whereami library: system library found)
endif
+
$(info compiler version: $(shell $(CC) --version|head -n 1))
$(info ===================================================================)
+################
+# dependencies #
+################
+
# Flags to generate temporary dependency files
DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
# make temporary to final dependency files after successful compilation
POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
-CORESRCS = uart/uart_posix.c \
- uart/uart_win32.c \
- ui.c \
- commonutil.c \
- util.c \
- util_posix.c \
- scandir.c \
- crc16.c \
- crc32.c \
- comms.c \
- version.c
+################
+# enumerations #
+################
-CMDSRCS = crapto1/crapto1.c \
- crapto1/crypto1.c \
- mifare/mifaredefault.c \
- mifare/mfkey.c \
- tea.c \
- fido/additional_ca.c \
- fido/cose.c \
- fido/cbortools.c \
- fido/fidocore.c \
- crypto/asn1dump.c \
- crypto/libpcrypto.c\
- crypto/asn1utils.c\
- loclass/cipher.c \
- loclass/cipherutils.c \
- loclass/ikeys.c \
- loclass/elite_crack.c \
- fileutils.c \
- mifare/mifarehost.c \
- parity.c \
- crc.c \
- crc64.c \
- legic_prng.c \
- iso15693tools.c \
- prng.c \
- generator.c \
- graph.c \
- cmddata.c \
- lfdemod.c \
- emv/crypto_polarssl.c\
- emv/crypto.c\
- emv/emv_pk.c\
- emv/emv_pki.c\
- emv/emv_pki_priv.c\
- emv/test/cryptotest.c\
- emv/apduinfo.c \
- emv/dump.c \
- emv/tlv.c \
- emv/emv_tags.c \
- emv/dol.c \
- emv/emvjson.c\
- emv/emvcore.c \
- emv/test/crypto_test.c\
- emv/test/sda_test.c\
- emv/test/dda_test.c\
- emv/test/cda_test.c\
- emv/cmdemv.c \
- emv/emv_roca.c \
- mifare/mifare4.c \
- mifare/mad.c \
- mifare/ndef.c \
- mifare/desfire_crypto.c \
- cmdanalyse.c \
- cmdhf.c \
- cmdhflist.c \
- aidsearch.c \
- cmdhf14a.c \
- cmdhf14b.c \
- cmdhf15.c \
- cmdhfepa.c \
- cmdhflegic.c \
- cmdhficlass.c \
- cmdhfmf.c \
- cmdhfmfu.c \
- cmdhfmfp.c \
- cmdhfmfhard.c \
- cmdhfmfdes.c \
- cmdhftopaz.c \
- cmdhffido.c \
- cmdhffelica.c \
- cmdhfthinfilm.c \
- cmdhfcryptorf.c \
- cmdhflto.c \
- cmdhw.c \
- cmdlf.c \
- cmdlfawid.c \
- cmdlfcotag.c \
- cmdlfem4x.c \
- cmdlffdx.c \
- cmdlfguard.c \
- cmdlfgallagher.c \
- cmdlfhid.c \
- cmdlfhitag.c \
- cmdlfio.c \
- cmdlfindala.c \
- cmdlfjablotron.c \
- cmdlfkeri.c \
- cmdlfnexwatch.c \
- cmdlfnedap.c \
- cmdlfnoralsy.c \
- cmdlfpac.c \
- cmdlfparadox.c \
- cmdlfpcf7931.c \
- cmdlfpresco.c \
- cmdlfpyramid.c \
- cmdlfsecurakey.c \
- cmdlft55xx.c \
- cmdlfti.c \
- cmdlfviking.c \
- cmdlfvisa2000.c \
- cmdlfmotorola.c \
- cmdtrace.c \
- cmdflashmem.c \
- cmdflashmemspiffs.c \
- cmdsmartcard.c \
- cmdusart.c \
- cmdwiegand.c \
- cmdparser.c \
- cmdmain.c \
- pm3_binlib.c \
- scripting.c \
- cmdscript.c \
- pm3_bitlib.c \
- cmdcrc.c \
- bucketsort.c \
- flash.c \
- wiegand_formats.c \
- wiegand_formatutils.c \
- cardhelper.c \
- preferences.c \
- jansson_path.c
+SRCS = aidsearch.c \
+ cmdanalyse.c \
+ cmdcrc.c \
+ cmddata.c \
+ cmdflashmem.c \
+ cmdflashmemspiffs.c \
+ cmdhf.c \
+ cmdhf14a.c \
+ cmdhf14b.c \
+ cmdhf15.c \
+ cmdhfcryptorf.c \
+ cmdhfepa.c \
+ cmdhffelica.c \
+ cmdhffido.c \
+ cmdhficlass.c \
+ cmdhflegic.c \
+ cmdhflist.c \
+ cmdhflto.c \
+ cmdhfmf.c \
+ cmdhfmfdes.c \
+ cmdhfmfhard.c \
+ cmdhfmfu.c \
+ cmdhfmfp.c \
+ cmdhfthinfilm.c \
+ cmdhftopaz.c \
+ cmdhw.c \
+ cmdlf.c \
+ cmdlfawid.c \
+ cmdlfcotag.c \
+ cmdlfem4x.c \
+ cmdlffdx.c \
+ cmdlfguard.c \
+ cmdlfgallagher.c \
+ cmdlfhid.c \
+ cmdlfhitag.c \
+ cmdlfindala.c \
+ cmdlfio.c \
+ cmdlfjablotron.c \
+ cmdlfkeri.c \
+ cmdlfmotorola.c \
+ cmdlfnedap.c \
+ cmdlfnexwatch.c \
+ cmdlfnoralsy.c \
+ cmdlfpac.c \
+ cmdlfparadox.c \
+ cmdlfpcf7931.c \
+ cmdlfpresco.c \
+ cmdlfpyramid.c \
+ cmdlfsecurakey.c \
+ cmdlft55xx.c \
+ cmdlfti.c \
+ cmdlfviking.c \
+ cmdlfvisa2000.c \
+ cmdmain.c \
+ cmdparser.c \
+ cmdscript.c \
+ cmdsmartcard.c \
+ cmdtrace.c \
+ cmdusart.c \
+ cmdwiegand.c \
+ comms.c \
+ crypto/asn1dump.c \
+ crypto/asn1utils.c\
+ crypto/libpcrypto.c\
+ emv/apduinfo.c \
+ emv/cmdemv.c \
+ emv/crypto.c\
+ emv/crypto_polarssl.c\
+ emv/dol.c \
+ emv/dump.c \
+ emv/emv_pk.c\
+ emv/emv_pki.c\
+ emv/emv_pki_priv.c\
+ emv/emv_roca.c \
+ emv/emv_tags.c \
+ emv/emvcore.c \
+ emv/emvjson.c\
+ emv/tlv.c \
+ emv/test/crypto_test.c\
+ emv/test/cryptotest.c\
+ emv/test/cda_test.c\
+ emv/test/dda_test.c\
+ emv/test/sda_test.c\
+ fido/additional_ca.c \
+ fido/cose.c \
+ fido/cbortools.c \
+ fido/fidocore.c \
+ fileutils.c \
+ flash.c \
+ generator.c \
+ graph.c \
+ jansson_path.c \
+ loclass/cipher.c \
+ loclass/cipherutils.c \
+ loclass/elite_crack.c \
+ loclass/ikeys.c \
+ mifare/desfire_crypto.c \
+ mifare/mad.c \
+ mifare/mfkey.c \
+ mifare/mifare4.c \
+ mifare/mifaredefault.c \
+ mifare/mifarehost.c \
+ mifare/ndef.c \
+ pm3_binlib.c \
+ pm3_bitlib.c \
+ preferences.c \
+ prng.c \
+ proxmark3.c \
+ scandir.c \
+ uart/uart_posix.c \
+ uart/uart_win32.c \
+ scripting.c \
+ tea.c \
+ ui.c \
+ util.c \
+ version.c \
+ wiegand_formats.c \
+ wiegand_formatutils.c
-COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
-CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
-OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
+# common
+SRCS += bucketsort.c \
+ cardhelper.c \
+ crapto1/crapto1.c \
+ crapto1/crypto1.c \
+ crc.c \
+ crc16.c \
+ crc32.c \
+ crc64.c \
+ commonutil.c \
+ iso15693tools.c \
+ legic_prng.c \
+ lfdemod.c \
+ parity.c \
+ util_posix.c
+
+# gui
+ifeq ($(QT_FOUND),1)
+ CXXSRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
+else
+ CXXSRCS = guidummy.cpp
+endif
+
+# OS X
+ifeq ($(platform),Darwin)
+ OBJCSRCS = util_darwin.m
+endif
+
+OBJS = $(SRCS:%.c=$(OBJDIR)/%.o)
+OBJS += $(CXXSRCS:%.cpp=$(OBJDIR)/%.o)
+OBJS += $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
BINS = proxmark3
+
CLEAN = $(BINS) src/version.c src/*.moc.cpp src/ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
# transition: cleaning also old path stuff
CLEAN += flasher *.moc.cpp ui/ui_overlays.h
+###########
+# targets #
+###########
+
# need to assign dependancies to build these first...
all: $(BINS)
all-static: LDLIBS:=-static $(LDLIBS)
all-static: $(BINS)
-proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(ZLIB) $(REVENGLIB) $(AMIIBOLIB) $(HARDNESTEDLIB) $(CLIPARSERLIB) $(WAILIB) $(BTLDLIBS) $(QTLDLIBS)
-proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) liblua jansson tinycbor reveng mbedtls zlib amiibo hardnested cliparser whereami lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
+proxmark3: $(OBJS) liblua jansson tinycbor reveng mbedtls zlib amiibo hardnested cliparser whereami lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
$(info [=] LD $@)
- $(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(LDLIBS) -o $@
+ $(Q)$(LD) $(PM3LDFLAGS) $(OBJS) $(LDLIBS) -o $@
src/proxgui.cpp: src/ui/ui_overlays.h
@@ -434,15 +574,18 @@ tarbin: $(BINS)
$(info [=] TAR ../proxmark3-$(platform)-bin.tar)
$(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
-# local libraries:
+###########################
+# local libraries targets #
+###########################
+
liblua:
-ifneq ($(LUASYSTEM),1)
+ifneq ($(LUA_FOUND),1)
$(info [*] MAKE $@ for $(LUAPLATFORM))
$(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
endif
jansson:
-ifneq ($(JANSSONSYSTEM),1)
+ifneq ($(JANSSON_FOUND),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
endif
@@ -468,7 +611,7 @@ cliparser:
$(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) all
whereami:
-ifneq ($(WAISYSTEM),1)
+ifneq ($(WAI_FOUND),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) all
endif
@@ -482,6 +625,10 @@ zlib:
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(ZLIBPATH) OBJDIR=$(ROOT_DIR)$(OBJDIR) BINDIR=$(ROOT_DIR)$(OBJDIR) all
+########
+# misc #
+########
+
.PHONY: all clean install uninstall tarbin liblua jansson tinycbor reveng hardnested amiibo cliparser whereami mbedtls zlib
# version.c should be remade on every compilation
@@ -503,7 +650,7 @@ $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
$(info [-] CXX $<)
$(Q)$(MKDIR) $(dir $@)
- $(Q)$(CXX) $(DEPFLAGS) $(PM3CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
+ $(Q)$(CXX) $(DEPFLAGS) $(PM3CXXFLAGS) $(CXXINCLUDES) -c -o $@ $<
$(Q)$(POSTCOMPILE)
%.o: %.m
@@ -513,10 +660,9 @@ $(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
$(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -c -o $@ $<
$(Q)$(POSTCOMPILE)
-DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS)) \
- $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
- $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS)) \
- $(OBJDIR)/proxmark3.d
+DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS)) \
+ $(patsubst %.cpp, $(OBJDIR)/%.d, $(CXXSRCS)) \
+ $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS))
$(DEPENDENCY_FILES): ;
.PRECIOUS: $(DEPENDENCY_FILES)
diff --git a/client/deps/CMakeLists.txt b/client/deps/CMakeLists.txt
index ac42065bf..a3908ec26 100644
--- a/client/deps/CMakeLists.txt
+++ b/client/deps/CMakeLists.txt
@@ -1,10 +1,30 @@
-include(cliparser.cmake)
-include(tinycbor.cmake)
-include(jansson.cmake)
-include(lua.cmake)
-include(mbedtls.cmake)
-include(amiibo.cmake)
-include(reveng.cmake)
-include(zlib.cmake)
-include(hardnested.cmake)
-include(whereami.cmake)
+if (NOT TARGET pm3rrg_rdv4_amiibo)
+ include(amiibo.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_cliparser)
+ include(cliparser.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_hardnested)
+ include(hardnested.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_jansson)
+ include(jansson.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_lua)
+ include(lua.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_mbedtls)
+ include(mbedtls.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_reveng)
+ include(reveng.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_tinycbor)
+ include(tinycbor.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_whereami)
+ include(whereami.cmake)
+endif()
+if (NOT TARGET pm3rrg_rdv4_z)
+ include(zlib.cmake)
+endif()
diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake
index 34780f597..23c7a7b57 100644
--- a/client/deps/amiibo.cmake
+++ b/client/deps/amiibo.cmake
@@ -11,6 +11,14 @@ add_library(pm3rrg_rdv4_amiibo STATIC
amiitool/keygen.c
)
+if (NOT TARGET pm3rrg_rdv4_mbedtls)
+ include(mbedtls.cmake)
+endif()
+find_library(pm3rrg_rdv4_mbedtls REQUIRED)
+target_link_libraries(pm3rrg_rdv4_amiibo PRIVATE
+ readline
+ m
+ pm3rrg_rdv4_mbedtls)
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE ../../include ../../common)
target_include_directories(pm3rrg_rdv4_amiibo INTERFACE amiitool)
target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
diff --git a/client/deps/amiitool/Makefile b/client/deps/amiitool/Makefile
index 7fe532878..dd064227e 100644
--- a/client/deps/amiitool/Makefile
+++ b/client/deps/amiitool/Makefile
@@ -1,5 +1,5 @@
MYSRCPATHS =
-MYINCLUDES = -I. -I.. -I../jansson -I../../../common -I../../../include
+MYINCLUDES = -I. -I.. -I../jansson -I../../../common -I../../../common/mbedtls -I../../../include
MYCFLAGS =
MYDEFS =
MYSRCS = \
diff --git a/client/deps/amiitool/amiibo.c b/client/deps/amiitool/amiibo.c
index ad41220bb..cbe3a0ba0 100644
--- a/client/deps/amiitool/amiibo.c
+++ b/client/deps/amiitool/amiibo.c
@@ -6,8 +6,8 @@
*/
#include "amiibo.h"
-#include "mbedtls/md.h"
-#include "mbedtls/aes.h"
+#include "md.h"
+#include "aes.h"
#include "commonutil.h"
#define HMAC_POS_DATA 0x008
diff --git a/client/deps/amiitool/drbg.c b/client/deps/amiitool/drbg.c
index c1297920f..1aaba0a7f 100644
--- a/client/deps/amiitool/drbg.c
+++ b/client/deps/amiitool/drbg.c
@@ -8,7 +8,7 @@
#include "drbg.h"
#include
#include
-#include "mbedtls/md.h"
+#include "md.h"
void nfc3d_drbg_init(nfc3d_drbg_ctx *ctx, const uint8_t *hmacKey, size_t hmacKeySize, const uint8_t *seed, size_t seedSize) {
assert(ctx != NULL);
diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake
index 63e706889..b18537c84 100644
--- a/client/deps/mbedtls.cmake
+++ b/client/deps/mbedtls.cmake
@@ -45,5 +45,6 @@ add_library(pm3rrg_rdv4_mbedtls STATIC
)
target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common)
+target_include_directories(pm3rrg_rdv4_mbedtls INTERFACE ../../common/mbedtls)
target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/deps/zlib.cmake b/client/deps/zlib.cmake
index 645cbc88d..3a77c35aa 100644
--- a/client/deps/zlib.cmake
+++ b/client/deps/zlib.cmake
@@ -9,5 +9,6 @@ add_library(pm3rrg_rdv4_z STATIC
)
target_compile_definitions(pm3rrg_rdv4_z PRIVATE Z_SOLO NO_GZIP ZLIB_PM3_TUNED)
+target_include_directories(pm3rrg_rdv4_z INTERFACE ../../common/zlib)
target_compile_options(pm3rrg_rdv4_z PRIVATE -Wall -Werror -O3)
set_property(TARGET pm3rrg_rdv4_z PROPERTY POSITION_INDEPENDENT_CODE ON)
diff --git a/client/src/cmdflashmem.c b/client/src/cmdflashmem.c
index e1761a81b..e90e6025c 100644
--- a/client/src/cmdflashmem.c
+++ b/client/src/cmdflashmem.c
@@ -18,8 +18,8 @@
#include "comms.h" //getfromdevice
#include "cmdflashmemspiffs.h" // spiffs commands
-#include "mbedtls/rsa.h"
-#include "mbedtls/sha1.h"
+#include "rsa.h"
+#include "sha1.h"
#define MCK 48000000
#define FLASH_MINFAST 24000000 //33000000
diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c
index f7b7b00e3..1fcf23fa3 100644
--- a/client/src/cmdhffelica.c
+++ b/client/src/cmdhffelica.c
@@ -22,7 +22,7 @@
#include "util.h"
#include "ui.h"
#include "mifare.h" // felica_card_select_t struct
-#include "mbedtls/des.h"
+#include "des.h"
#define AddCrc(data, len) compute_crc(CRC_FELICA, (data), (len), (data)+(len)+1, (data)+(len))
static int CmdHelp(const char *Cmd);
diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c
index 61aea9de6..3026f3964 100644
--- a/client/src/cmdhficlass.c
+++ b/client/src/cmdhficlass.c
@@ -18,7 +18,7 @@
#include "cmdtrace.h"
#include "util_posix.h"
#include "comms.h"
-#include "mbedtls/des.h"
+#include "des.h"
#include "loclass/cipherutils.h"
#include "loclass/cipher.h"
#include "loclass/ikeys.h"
diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c
index a39bd85c0..5e9a49c26 100644
--- a/client/src/cmdhfmfdes.c
+++ b/client/src/cmdhfmfdes.c
@@ -17,7 +17,7 @@
#include "comms.h"
#include "ui.h"
#include "cmdhf14a.h"
-#include "mbedtls/aes.h"
+#include "aes.h"
#include "crypto/libpcrypto.h"
#include "protocols.h"
#include "cmdtrace.h"
diff --git a/client/src/cmdhfmfdesfire_disabled.c b/client/src/cmdhfmfdesfire_disabled.c
index e2d43630f..e2de33485 100644
--- a/client/src/cmdhfmfdesfire_disabled.c
+++ b/client/src/cmdhfmfdesfire_disabled.c
@@ -14,8 +14,8 @@
#include "cmdhfmf.h"
#include "util.h"
-#include "mbedtls/des.h"
-#include "mbedtls/aes.h"
+#include "des.h"
+#include "aes.h"
static int CmdHelp(const char *Cmd);
diff --git a/client/src/cmdhfmfhard.c b/client/src/cmdhfmfhard.c
index 52e3e4108..383a9676f 100644
--- a/client/src/cmdhfmfhard.c
+++ b/client/src/cmdhfmfhard.c
@@ -35,7 +35,7 @@
#include "hardnested_bruteforce.h"
#include "hardnested_bf_core.h"
#include "hardnested_bitarray_core.h"
-#include "zlib/zlib.h"
+#include "zlib.h"
#include "fileutils.h"
#define NUM_CHECK_BITFLIPS_THREADS (num_CPUs())
@@ -220,7 +220,7 @@ static void inflate_free(voidpf opaque, voidpf address) {
#define INPUT_BUFFER_LEN 80
//----------------------------------------------------------------------------
-// Initialize decompression of the respective (HF or LF) FPGA stream
+// Initialize decompression of the respective bitflip_bitarray stream
//----------------------------------------------------------------------------
static void init_inflate(z_streamp compressed_stream, uint8_t *input_buffer, uint32_t insize, uint8_t *output_buffer, uint32_t outsize) {
diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c
index b9dc8d3a2..efd10210d 100644
--- a/client/src/cmdhfmfu.c
+++ b/client/src/cmdhfmfu.c
@@ -12,7 +12,7 @@
#include "cmdparser.h"
#include "commonutil.h"
#include "crypto/libpcrypto.h"
-#include "mbedtls/des.h"
+#include "des.h"
#include "cmdhfmf.h"
#include "cmdhf14a.h"
#include "comms.h"
diff --git a/client/src/emv/crypto_polarssl.c b/client/src/emv/crypto_polarssl.c
index 9d18a370b..0d582c7b3 100644
--- a/client/src/emv/crypto_polarssl.c
+++ b/client/src/emv/crypto_polarssl.c
@@ -23,8 +23,8 @@
#include
#include
-#include "mbedtls/rsa.h"
-#include "mbedtls/sha1.h"
+#include "rsa.h"
+#include "sha1.h"
struct crypto_hash_polarssl {
struct crypto_hash ch;
diff --git a/client/src/emv/emv_roca.c b/client/src/emv/emv_roca.c
index 521120b05..1bebcacbf 100644
--- a/client/src/emv/emv_roca.c
+++ b/client/src/emv/emv_roca.c
@@ -24,7 +24,7 @@
#include "emv_roca.h"
#include "ui.h" // Print...
-#include "mbedtls/bignum.h"
+#include "bignum.h"
static uint8_t g_primes[ROCA_PRINTS_LENGTH] = {
11, 13, 17, 19, 37, 53, 61, 71, 73, 79, 97, 103, 107, 109, 127, 151, 157
diff --git a/client/src/emv/test/cryptotest.c b/client/src/emv/test/cryptotest.c
index f343ebbea..bb59de7fa 100644
--- a/client/src/emv/test/cryptotest.c
+++ b/client/src/emv/test/cryptotest.c
@@ -12,19 +12,19 @@
#include "util.h"
#include "ui.h"
-#include "mbedtls/bignum.h"
-#include "mbedtls/aes.h"
-#include "mbedtls/cmac.h"
-#include "mbedtls/des.h"
-#include "mbedtls/ecp.h"
-#include "mbedtls/rsa.h"
-#include "mbedtls/sha1.h"
-#include "mbedtls/md5.h"
-#include "mbedtls/x509.h"
-#include "mbedtls/base64.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/timing.h"
+#include "bignum.h"
+#include "aes.h"
+#include "cmac.h"
+#include "des.h"
+#include "ecp.h"
+#include "rsa.h"
+#include "sha1.h"
+#include "md5.h"
+#include "x509.h"
+#include "base64.h"
+#include "ctr_drbg.h"
+#include "entropy.h"
+#include "timing.h"
#include "crypto_test.h"
#include "sda_test.h"
diff --git a/client/src/fido/fidocore.c b/client/src/fido/fidocore.c
index 32d7c9ff0..3cddbc5a9 100644
--- a/client/src/fido/fidocore.c
+++ b/client/src/fido/fidocore.c
@@ -17,7 +17,7 @@
#include "emv/emvcore.h"
#include "emv/emvjson.h"
#include "cbortools.h"
-#include "mbedtls/x509_crt.h"
+#include "x509_crt.h"
#include "crypto/asn1utils.h"
#include "crypto/libpcrypto.h"
#include "additional_ca.h"
diff --git a/client/src/loclass/elite_crack.c b/client/src/loclass/elite_crack.c
index cc9570351..83e2a9146 100644
--- a/client/src/loclass/elite_crack.c
+++ b/client/src/loclass/elite_crack.c
@@ -45,7 +45,7 @@
#include "ikeys.h"
#include "elite_crack.h"
#include "fileutils.h"
-#include "mbedtls/des.h"
+#include "des.h"
#include "util_posix.h"
/**
diff --git a/client/src/loclass/ikeys.c b/client/src/loclass/ikeys.c
index f50d276dc..cf14450bd 100644
--- a/client/src/loclass/ikeys.c
+++ b/client/src/loclass/ikeys.c
@@ -70,7 +70,7 @@ From "Dismantling iclass":
#include "fileutils.h"
#include "cipherutils.h"
-#include "mbedtls/des.h"
+#include "des.h"
uint8_t pi[35] = {
0x0F, 0x17, 0x1B, 0x1D, 0x1E, 0x27, 0x2B, 0x2D,
diff --git a/client/src/mifare/desfire_crypto.c b/client/src/mifare/desfire_crypto.c
index 2cb9d7c3a..6dd2de26d 100644
--- a/client/src/mifare/desfire_crypto.c
+++ b/client/src/mifare/desfire_crypto.c
@@ -29,8 +29,8 @@
#include
#include
#include "commonutil.h"
-#include "mbedtls/aes.h"
-#include "mbedtls/des.h"
+#include "aes.h"
+#include "des.h"
#include "ui.h"
#include "crc.h"
#include "crc16.h" // crc16 ccitt
diff --git a/client/src/scripting.c b/client/src/scripting.c
index 4a3bab49c..a5c466ea4 100644
--- a/client/src/scripting.c
+++ b/client/src/scripting.c
@@ -21,8 +21,8 @@
#include "mifare/mifarehost.h"
#include "crc.h"
#include "crc64.h"
-#include "mbedtls/sha1.h"
-#include "mbedtls/aes.h"
+#include "sha1.h"
+#include "aes.h"
#include "cmdcrc.h"
#include "cmdhfmfhard.h"
#include "cmdhfmfu.h"
From b4716f78a82bc50394f1b55a51ab8d5867e1975e Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 25 May 2020 02:18:16 +0200
Subject: [PATCH 141/527] remove unused polarssl file
---
client/src/polarssl_config.h | 2179 ----------------------------------
1 file changed, 2179 deletions(-)
delete mode 100644 client/src/polarssl_config.h
diff --git a/client/src/polarssl_config.h b/client/src/polarssl_config.h
deleted file mode 100644
index 5bd88fc07..000000000
--- a/client/src/polarssl_config.h
+++ /dev/null
@@ -1,2179 +0,0 @@
-/**
- * \file config.h
- *
- * \brief Configuration options (set of defines)
- *
- * Copyright (C) 2006-2014, Brainspark B.V.
- *
- * This file is part of PolarSSL (http://www.polarssl.org)
- * Lead Maintainer: Paul Bakker
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This set of compile-time options may be used to enable
- * or disable features selectively, and reduce the global
- * memory footprint.
- */
-#ifndef POLARSSL_CONFIG_H
-#define POLARSSL_CONFIG_H
-
-#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-/**
- * \name SECTION: System support
- *
- * This section sets system specific settings.
- * \{
- */
-
-/**
- * \def POLARSSL_HAVE_INT8
- *
- * The system uses 8-bit wide native integers.
- *
- * Uncomment if native integers are 8-bit wide.
- */
-//#define POLARSSL_HAVE_INT8
-
-/**
- * \def POLARSSL_HAVE_INT16
- *
- * The system uses 16-bit wide native integers.
- *
- * Uncomment if native integers are 16-bit wide.
- */
-//#define POLARSSL_HAVE_INT16
-
-/**
- * \def POLARSSL_HAVE_LONGLONG
- *
- * The compiler supports the 'long long' type.
- * (Only used on 32-bit platforms)
- */
-#define POLARSSL_HAVE_LONGLONG
-
-/**
- * \def POLARSSL_HAVE_ASM
- *
- * The compiler has support for asm().
- *
- * Requires support for asm() in compiler.
- *
- * Used in:
- * library/timing.c
- * library/padlock.c
- * include/polarssl/bn_mul.h
- *
- * Comment to disable the use of assembly code.
- */
-#define POLARSSL_HAVE_ASM
-
-/**
- * \def POLARSSL_HAVE_SSE2
- *
- * CPU supports SSE2 instruction set.
- *
- * Uncomment if the CPU supports SSE2 (IA-32 specific).
- */
-//#define POLARSSL_HAVE_SSE2
-
-/**
- * \def POLARSSL_HAVE_TIME
- *
- * System has time.h and time() / localtime() / gettimeofday().
- *
- * Comment if your system does not support time functions
- */
-#define POLARSSL_HAVE_TIME
-
-/**
- * \def POLARSSL_HAVE_IPV6
- *
- * System supports the basic socket interface for IPv6 (RFC 3493),
- * specifically getaddrinfo(), freeaddrinfo() and struct sockaddr_storage.
- *
- * Note: on Windows/MingW, XP or higher is required.
- *
- * Comment if your system does not support the IPv6 socket interface
- */
-#define POLARSSL_HAVE_IPV6
-
-/**
- * \def POLARSSL_PLATFORM_MEMORY
- *
- * Enable the memory allocation layer.
- *
- * By default PolarSSL uses the system-provided malloc() and free().
- * This allows different allocators (self-implemented or provided) to be
- * provided to the platform abstraction layer.
- *
- * Enabling POLARSSL_PLATFORM_MEMORY will provide "platform_set_malloc_free()"
- * to allow you to set an alternative malloc() and free() function pointer.
- *
- * Requires: POLARSSL_PLATFORM_C
- *
- * Enable this layer to allow use of alternative memory allocators.
- */
-//#define POLARSSL_PLATFORM_MEMORY
-
-/**
- * \def POLARSSL_PLATFORM_NO_STD_FUNCTIONS
- *
- * Do not assign standard functions in the platform layer (e.g. malloc() to
- * POLARSSL_PLATFORM_STD_MALLOC and printf() to POLARSSL_PLATFORM_STD_PRINTF)
- *
- * This makes sure there are no linking errors on platforms that do not support
- * these functions. You will HAVE to provide alternatives, either at runtime
- * via the platform_set_xxx() functions or at compile time by setting
- * the POLARSSL_PLATFORM_STD_XXX defines.
- *
- * Requires: POLARSSL_PLATFORM_C
- *
- * Uncomment to prevent default assignment of standard functions in the
- * platform layer.
- */
-//#define POLARSSL_PLATFORM_NO_STD_FUNCTIONS
-
-/**
- * \def POLARSSL_PLATFORM_XXX_ALT
- *
- * Uncomment a macro to let PolarSSL support the function in the platform
- * abstraction layer.
- *
- * Example: In case you uncomment POLARSSL_PLATFORM_PRINTF_ALT, PolarSSL will
- * provide a function "platform_set_printf()" that allows you to set an
- * alternative printf function pointer.
- *
- * All these define require POLARSSL_PLATFORM_C to be defined!
- *
- * Uncomment a macro to enable alternate implementation of specific base
- * platform function
- */
-//#define POLARSSL_PLATFORM_PRINTF_ALT
-//#define POLARSSL_PLATFORM_FPRINTF_ALT
-/* \} name SECTION: System support */
-
-/**
- * \name SECTION: PolarSSL feature support
- *
- * This section sets support for features that are or are not needed
- * within the modules that are enabled.
- * \{
- */
-
-/**
- * \def POLARSSL_TIMING_ALT
- *
- * Uncomment to provide your own alternate implementation for hardclock(),
- * get_timer(), set_alarm() and m_sleep().
- *
- * Only works if you have POLARSSL_TIMING_C enabled.
- *
- * You will need to provide a header "timing_alt.h" and an implementation at
- * compile time.
- */
-//#define POLARSSL_TIMING_ALT
-
-/**
- * \def POLARSSL_XXX_ALT
- *
- * Uncomment a macro to let PolarSSL use your alternate core implementation of
- * a symmetric or hash algorithm (e.g. platform specific assembly optimized
- * implementations). Keep in mind that the function prototypes should remain
- * the same.
- *
- * Example: In case you uncomment POLARSSL_AES_ALT, PolarSSL will no longer
- * provide the "struct aes_context" definition and omit the base function
- * declarations and implementations. "aes_alt.h" will be included from
- * "aes.h" to include the new function definitions.
- *
- * Uncomment a macro to enable alternate implementation for core algorithm
- * functions
- */
-//#define POLARSSL_AES_ALT
-//#define POLARSSL_ARC4_ALT
-//#define POLARSSL_BLOWFISH_ALT
-//#define POLARSSL_CAMELLIA_ALT
-//#define POLARSSL_DES_ALT
-//#define POLARSSL_XTEA_ALT
-//#define POLARSSL_MD2_ALT
-//#define POLARSSL_MD4_ALT
-//#define POLARSSL_MD5_ALT
-//#define POLARSSL_RIPEMD160_ALT
-//#define POLARSSL_SHA1_ALT
-//#define POLARSSL_SHA256_ALT
-//#define POLARSSL_SHA512_ALT
-
-/**
- * \def POLARSSL_AES_ROM_TABLES
- *
- * Store the AES tables in ROM.
- *
- * Uncomment this macro to store the AES tables in ROM.
- *
- */
-//#define POLARSSL_AES_ROM_TABLES
-
-/**
- * \def POLARSSL_CIPHER_MODE_CBC
- *
- * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers.
- */
-#define POLARSSL_CIPHER_MODE_CBC
-
-/**
- * \def POLARSSL_CIPHER_MODE_CFB
- *
- * Enable Cipher Feedback mode (CFB) for symmetric ciphers.
- */
-#define POLARSSL_CIPHER_MODE_CFB
-
-/**
- * \def POLARSSL_CIPHER_MODE_CTR
- *
- * Enable Counter Block Cipher mode (CTR) for symmetric ciphers.
- */
-#define POLARSSL_CIPHER_MODE_CTR
-
-/**
- * \def POLARSSL_CIPHER_NULL_CIPHER
- *
- * Enable NULL cipher.
- * Warning: Only do so when you know what you are doing. This allows for
- * encryption or channels without any security!
- *
- * Requires POLARSSL_ENABLE_WEAK_CIPHERSUITES as well to enable
- * the following ciphersuites:
- * TLS_ECDH_ECDSA_WITH_NULL_SHA
- * TLS_ECDH_RSA_WITH_NULL_SHA
- * TLS_ECDHE_ECDSA_WITH_NULL_SHA
- * TLS_ECDHE_RSA_WITH_NULL_SHA
- * TLS_ECDHE_PSK_WITH_NULL_SHA384
- * TLS_ECDHE_PSK_WITH_NULL_SHA256
- * TLS_ECDHE_PSK_WITH_NULL_SHA
- * TLS_DHE_PSK_WITH_NULL_SHA384
- * TLS_DHE_PSK_WITH_NULL_SHA256
- * TLS_DHE_PSK_WITH_NULL_SHA
- * TLS_RSA_WITH_NULL_SHA256
- * TLS_RSA_WITH_NULL_SHA
- * TLS_RSA_WITH_NULL_MD5
- * TLS_RSA_PSK_WITH_NULL_SHA384
- * TLS_RSA_PSK_WITH_NULL_SHA256
- * TLS_RSA_PSK_WITH_NULL_SHA
- * TLS_PSK_WITH_NULL_SHA384
- * TLS_PSK_WITH_NULL_SHA256
- * TLS_PSK_WITH_NULL_SHA
- *
- * Uncomment this macro to enable the NULL cipher and ciphersuites
- */
-//#define POLARSSL_CIPHER_NULL_CIPHER
-
-/**
- * \def POLARSSL_CIPHER_PADDING_XXX
- *
- * Uncomment or comment macros to add support for specific padding modes
- * in the cipher layer with cipher modes that support padding (e.g. CBC)
- *
- * If you disable all padding modes, only full blocks can be used with CBC.
- *
- * Enable padding modes in the cipher layer.
- */
-#define POLARSSL_CIPHER_PADDING_PKCS7
-#define POLARSSL_CIPHER_PADDING_ONE_AND_ZEROS
-#define POLARSSL_CIPHER_PADDING_ZEROS_AND_LEN
-#define POLARSSL_CIPHER_PADDING_ZEROS
-
-/**
- * \def POLARSSL_ENABLE_WEAK_CIPHERSUITES
- *
- * Enable weak ciphersuites in SSL / TLS.
- * Warning: Only do so when you know what you are doing. This allows for
- * channels with virtually no security at all!
- *
- * This enables the following ciphersuites:
- * TLS_RSA_WITH_DES_CBC_SHA
- * TLS_DHE_RSA_WITH_DES_CBC_SHA
- *
- * Uncomment this macro to enable weak ciphersuites
- */
-//#define POLARSSL_ENABLE_WEAK_CIPHERSUITES
-
-/**
- * \def POLARSSL_REMOVE_ARC4_CIPHERSUITES
- *
- * Remove RC4 ciphersuites by default in SSL / TLS.
- * This flag removes the ciphersuites based on RC4 from the default list as
- * returned by ssl_list_ciphersuites(). However, it is still possible to
- * enable (some of) them with ssl_set_ciphersuites() by including them
- * explicitly.
- *
- * Uncomment this macro to remove RC4 ciphersuites by default.
- */
-//#define POLARSSL_REMOVE_ARC4_CIPHERSUITES
-
-/**
- * \def POLARSSL_ECP_XXXX_ENABLED
- *
- * Enables specific curves within the Elliptic Curve module.
- * By default all supported curves are enabled.
- *
- * Comment macros to disable the curve and functions for it
- */
-#define POLARSSL_ECP_DP_SECP192R1_ENABLED
-#define POLARSSL_ECP_DP_SECP224R1_ENABLED
-#define POLARSSL_ECP_DP_SECP256R1_ENABLED
-#define POLARSSL_ECP_DP_SECP384R1_ENABLED
-#define POLARSSL_ECP_DP_SECP521R1_ENABLED
-#define POLARSSL_ECP_DP_SECP192K1_ENABLED
-#define POLARSSL_ECP_DP_SECP224K1_ENABLED
-#define POLARSSL_ECP_DP_SECP256K1_ENABLED
-#define POLARSSL_ECP_DP_BP256R1_ENABLED
-#define POLARSSL_ECP_DP_BP384R1_ENABLED
-#define POLARSSL_ECP_DP_BP512R1_ENABLED
-//#define POLARSSL_ECP_DP_M221_ENABLED // Not implemented yet!
-#define POLARSSL_ECP_DP_M255_ENABLED
-//#define POLARSSL_ECP_DP_M383_ENABLED // Not implemented yet!
-//#define POLARSSL_ECP_DP_M511_ENABLED // Not implemented yet!
-
-/**
- * \def POLARSSL_ECP_NIST_OPTIM
- *
- * Enable specific 'modulo p' routines for each NIST prime.
- * Depending on the prime and architecture, makes operations 4 to 8 times
- * faster on the corresponding curve.
- *
- * Comment this macro to disable NIST curves optimisation.
- */
-#define POLARSSL_ECP_NIST_OPTIM
-
-/**
- * \def POLARSSL_ECDSA_DETERMINISTIC
- *
- * Enable deterministic ECDSA (RFC 6979).
- * Standard ECDSA is "fragile" in the sense that lack of entropy when signing
- * may result in a compromise of the long-term signing key. This is avoided by
- * the deterministic variant.
- *
- * Requires: POLARSSL_HMAC_DRBG_C
- *
- * Comment this macro to disable deterministic ECDSA.
- */
-#define POLARSSL_ECDSA_DETERMINISTIC
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_PSK_ENABLED
- *
- * Enable the PSK based ciphersuite modes in SSL / TLS.
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_PSK_WITH_AES_256_GCM_SHA384
- * TLS_PSK_WITH_AES_256_CBC_SHA384
- * TLS_PSK_WITH_AES_256_CBC_SHA
- * TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_PSK_WITH_AES_128_GCM_SHA256
- * TLS_PSK_WITH_AES_128_CBC_SHA256
- * TLS_PSK_WITH_AES_128_CBC_SHA
- * TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_PSK_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_PSK_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED
- *
- * Enable the DHE-PSK based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_DHM_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
- * TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
- * TLS_DHE_PSK_WITH_AES_256_CBC_SHA
- * TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
- * TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
- * TLS_DHE_PSK_WITH_AES_128_CBC_SHA
- * TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_DHE_PSK_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED
- *
- * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_ECDH_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384
- * TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA
- * TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA
- * TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_PSK_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED
- *
- * Enable the RSA-PSK based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_RSA_C, POLARSSL_PKCS1_V15,
- * POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_RSA_PSK_WITH_AES_256_GCM_SHA384
- * TLS_RSA_PSK_WITH_AES_256_CBC_SHA384
- * TLS_RSA_PSK_WITH_AES_256_CBC_SHA
- * TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_RSA_PSK_WITH_AES_128_GCM_SHA256
- * TLS_RSA_PSK_WITH_AES_128_CBC_SHA256
- * TLS_RSA_PSK_WITH_AES_128_CBC_SHA
- * TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_RSA_PSK_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_RSA_ENABLED
- *
- * Enable the RSA-only based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_RSA_C, POLARSSL_PKCS1_V15,
- * POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_RSA_WITH_AES_256_GCM_SHA384
- * TLS_RSA_WITH_AES_256_CBC_SHA256
- * TLS_RSA_WITH_AES_256_CBC_SHA
- * TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
- * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
- * TLS_RSA_WITH_AES_128_GCM_SHA256
- * TLS_RSA_WITH_AES_128_CBC_SHA256
- * TLS_RSA_WITH_AES_128_CBC_SHA
- * TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
- * TLS_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_RSA_WITH_RC4_128_SHA
- * TLS_RSA_WITH_RC4_128_MD5
- */
-#define POLARSSL_KEY_EXCHANGE_RSA_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED
- *
- * Enable the DHE-RSA based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_DHM_C, POLARSSL_RSA_C, POLARSSL_PKCS1_V15,
- * POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
- * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
- * TLS_DHE_RSA_WITH_AES_256_CBC_SHA
- * TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
- * TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
- * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
- * TLS_DHE_RSA_WITH_AES_128_CBC_SHA
- * TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
- * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED
- *
- * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_ECDH_C, POLARSSL_RSA_C, POLARSSL_PKCS1_V15,
- * POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
- * TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
- * TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_RSA_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
- *
- * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_ECDH_C, POLARSSL_ECDSA_C, POLARSSL_X509_CRT_PARSE_C,
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
- */
-#define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
- *
- * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_ECDH_C, POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_ECDSA_WITH_RC4_128_SHA
- * TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
- * TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
- * TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
- */
-#define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
-
-/**
- * \def POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED
- *
- * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS.
- *
- * Requires: POLARSSL_ECDH_C, POLARSSL_X509_CRT_PARSE_C
- *
- * This enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_RSA_WITH_RC4_128_SHA
- * TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
- * TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
- * TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384
- */
-#define POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED
-
-/**
- * \def POLARSSL_PK_PARSE_EC_EXTENDED
- *
- * Enhance support for reading EC keys using variants of SEC1 not allowed by
- * RFC 5915 and RFC 5480.
- *
- * Currently this means parsing the SpecifiedECDomain choice of EC
- * parameters (only known groups are supported, not arbitrary domains, to
- * avoid validation issues).
- *
- * Disable if you only need to support RFC 5915 + 5480 key formats.
- */
-#define POLARSSL_PK_PARSE_EC_EXTENDED
-
-/**
- * \def POLARSSL_ERROR_STRERROR_BC
- *
- * Make available the backward compatible error_strerror() next to the
- * current polarssl_strerror().
- *
- * For new code, it is recommended to use polarssl_strerror() instead and
- * disable this.
- *
- * Disable if you run into name conflicts and want to really remove the
- * error_strerror()
- */
-#define POLARSSL_ERROR_STRERROR_BC
-
-/**
- * \def POLARSSL_ERROR_STRERROR_DUMMY
- *
- * Enable a dummy error function to make use of polarssl_strerror() in
- * third party libraries easier when POLARSSL_ERROR_C is disabled
- * (no effect when POLARSSL_ERROR_C is enabled).
- *
- * You can safely disable this if POLARSSL_ERROR_C is enabled, or if you're
- * not using polarssl_strerror() or error_strerror() in your application.
- *
- * Disable if you run into name conflicts and want to really remove the
- * polarssl_strerror()
- */
-#define POLARSSL_ERROR_STRERROR_DUMMY
-
-/**
- * \def POLARSSL_GENPRIME
- *
- * Enable the prime-number generation code.
- *
- * Requires: POLARSSL_BIGNUM_C
- */
-#define POLARSSL_GENPRIME
-
-/**
- * \def POLARSSL_FS_IO
- *
- * Enable functions that use the filesystem.
- */
-#define POLARSSL_FS_IO
-
-/**
- * \def POLARSSL_NO_DEFAULT_ENTROPY_SOURCES
- *
- * Do not add default entropy sources. These are the platform specific,
- * hardclock and HAVEGE based poll functions.
- *
- * This is useful to have more control over the added entropy sources in an
- * application.
- *
- * Uncomment this macro to prevent loading of default entropy functions.
- */
-//#define POLARSSL_NO_DEFAULT_ENTROPY_SOURCES
-
-/**
- * \def POLARSSL_NO_PLATFORM_ENTROPY
- *
- * Do not use built-in platform entropy functions.
- * This is useful if your platform does not support
- * standards like the /dev/urandom or Windows CryptoAPI.
- *
- * Uncomment this macro to disable the built-in platform entropy functions.
- */
-//#define POLARSSL_NO_PLATFORM_ENTROPY
-
-/**
- * \def POLARSSL_ENTROPY_FORCE_SHA256
- *
- * Force the entropy accumulator to use a SHA-256 accumulator instead of the
- * default SHA-512 based one (if both are available).
- *
- * Requires: POLARSSL_SHA256_C
- *
- * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option
- * if you have performance concerns.
- *
- * This option is only useful if both POLARSSL_SHA256_C and
- * POLARSSL_SHA512_C are defined. Otherwise the available hash module is used.
- */
-//#define POLARSSL_ENTROPY_FORCE_SHA256
-
-/**
- * \def POLARSSL_MEMORY_DEBUG
- *
- * Enable debugging of buffer allocator memory issues. Automatically prints
- * (to stderr) all (fatal) messages on memory allocation issues. Enables
- * function for 'debug output' of allocated memory.
- *
- * Requires: POLARSSL_MEMORY_BUFFER_ALLOC_C
- *
- * Uncomment this macro to let the buffer allocator print out error messages.
- */
-//#define POLARSSL_MEMORY_DEBUG
-
-/**
- * \def POLARSSL_MEMORY_BACKTRACE
- *
- * Include backtrace information with each allocated block.
- *
- * Requires: POLARSSL_MEMORY_BUFFER_ALLOC_C
- * GLIBC-compatible backtrace() an backtrace_symbols() support
- *
- * Uncomment this macro to include backtrace information
- */
-//#define POLARSSL_MEMORY_BACKTRACE
-
-/**
- * \def POLARSSL_PKCS1_V15
- *
- * Enable support for PKCS#1 v1.5 encoding.
- *
- * Requires: POLARSSL_RSA_C
- *
- * This enables support for PKCS#1 v1.5 operations.
- */
-#define POLARSSL_PKCS1_V15
-
-/**
- * \def POLARSSL_PKCS1_V21
- *
- * Enable support for PKCS#1 v2.1 encoding.
- *
- * Requires: POLARSSL_MD_C, POLARSSL_RSA_C
- *
- * This enables support for RSAES-OAEP and RSASSA-PSS operations.
- */
-#define POLARSSL_PKCS1_V21
-
-/**
- * \def POLARSSL_RSA_NO_CRT
- *
- * Do not use the Chinese Remainder Theorem for the RSA private operation.
- *
- * Uncomment this macro to disable the use of CRT in RSA.
- *
- */
-//#define POLARSSL_RSA_NO_CRT
-
-/**
- * \def POLARSSL_SELF_TEST
- *
- * Enable the checkup functions (*_self_test).
- */
-#define POLARSSL_SELF_TEST
-
-/**
- * \def POLARSSL_SSL_ALL_ALERT_MESSAGES
- *
- * Enable sending of alert messages in case of encountered errors as per RFC.
- * If you choose not to send the alert messages, PolarSSL can still communicate
- * with other servers, only debugging of failures is harder.
- *
- * The advantage of not sending alert messages, is that no information is given
- * about reasons for failures thus preventing adversaries of gaining intel.
- *
- * Enable sending of all alert messages
- */
-#define POLARSSL_SSL_ALERT_MESSAGES
-
-/**
- * \def POLARSSL_SSL_DEBUG_ALL
- *
- * Enable the debug messages in SSL module for all issues.
- * Debug messages have been disabled in some places to prevent timing
- * attacks due to (unbalanced) debugging function calls.
- *
- * If you need all error reporting you should enable this during debugging,
- * but remove this for production servers that should log as well.
- *
- * Uncomment this macro to report all debug messages on errors introducing
- * a timing side-channel.
- *
- */
-//#define POLARSSL_SSL_DEBUG_ALL
-
-/**
- * \def POLARSSL_SSL_HW_RECORD_ACCEL
- *
- * Enable hooking functions in SSL module for hardware acceleration of
- * individual records.
- *
- * Uncomment this macro to enable hooking functions.
- */
-//#define POLARSSL_SSL_HW_RECORD_ACCEL
-
-/**
- * \def POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO
- *
- * Enable support for receiving and parsing SSLv2 Client Hello messages for the
- * SSL Server module (POLARSSL_SSL_SRV_C).
- *
- * Comment this macro to disable support for SSLv2 Client Hello messages.
- */
-#define POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO
-
-/**
- * \def POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE
- *
- * Pick the ciphersuite according to the client's preferences rather than ours
- * in the SSL Server module (POLARSSL_SSL_SRV_C).
- *
- * Uncomment this macro to respect client's ciphersuite order
- */
-//#define POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE
-
-/**
- * \def POLARSSL_SSL_MAX_FRAGMENT_LENGTH
- *
- * Enable support for RFC 6066 max_fragment_length extension in SSL.
- *
- * Comment this macro to disable support for the max_fragment_length extension
- */
-#define POLARSSL_SSL_MAX_FRAGMENT_LENGTH
-
-/**
- * \def POLARSSL_SSL_PROTO_SSL3
- *
- * Enable support for SSL 3.0.
- *
- * Requires: POLARSSL_MD5_C
- * POLARSSL_SHA1_C
- *
- * Comment this macro to disable support for SSL 3.0
- */
-#define POLARSSL_SSL_PROTO_SSL3
-
-/**
- * \def POLARSSL_SSL_PROTO_TLS1
- *
- * Enable support for TLS 1.0.
- *
- * Requires: POLARSSL_MD5_C
- * POLARSSL_SHA1_C
- *
- * Comment this macro to disable support for TLS 1.0
- */
-#define POLARSSL_SSL_PROTO_TLS1
-
-/**
- * \def POLARSSL_SSL_PROTO_TLS1_1
- *
- * Enable support for TLS 1.1.
- *
- * Requires: POLARSSL_MD5_C
- * POLARSSL_SHA1_C
- *
- * Comment this macro to disable support for TLS 1.1
- */
-#define POLARSSL_SSL_PROTO_TLS1_1
-
-/**
- * \def POLARSSL_SSL_PROTO_TLS1_2
- *
- * Enable support for TLS 1.2.
- *
- * Requires: POLARSSL_SHA1_C or POLARSSL_SHA256_C or POLARSSL_SHA512_C
- * (Depends on ciphersuites)
- *
- * Comment this macro to disable support for TLS 1.2
- */
-#define POLARSSL_SSL_PROTO_TLS1_2
-
-/**
- * \def POLARSSL_SSL_ALPN
- *
- * Enable support for Application Layer Protocol Negotiation.
- * draft-ietf-tls-applayerprotoneg-05
- *
- * Comment this macro to disable support for ALPN.
- */
-#define POLARSSL_SSL_ALPN
-
-/**
- * \def POLARSSL_SSL_SESSION_TICKETS
- *
- * Enable support for RFC 5077 session tickets in SSL.
- *
- * Requires: POLARSSL_AES_C
- * POLARSSL_SHA256_C
- * POLARSSL_CIPHER_MODE_CBC
- *
- * Comment this macro to disable support for SSL session tickets
- */
-#define POLARSSL_SSL_SESSION_TICKETS
-
-/**
- * \def POLARSSL_SSL_SERVER_NAME_INDICATION
- *
- * Enable support for RFC 6066 server name indication (SNI) in SSL.
- *
- * Comment this macro to disable support for server name indication in SSL
- */
-#define POLARSSL_SSL_SERVER_NAME_INDICATION
-
-/**
- * \def POLARSSL_SSL_TRUNCATED_HMAC
- *
- * Enable support for RFC 6066 truncated HMAC in SSL.
- *
- * Comment this macro to disable support for truncated HMAC in SSL
- */
-#define POLARSSL_SSL_TRUNCATED_HMAC
-
-/**
- * \def POLARSSL_SSL_SET_CURVES
- *
- * Enable ssl_set_curves().
- *
- * This is disabled by default since it breaks binary compatibility with the
- * 1.3.x line. If you choose to enable it, you will need to rebuild your
- * application against the new header files, relinking will not be enough.
- * It will be enabled by default, or no longer an option, in the 1.4 branch.
- *
- * Uncomment to make ssl_set_curves() available.
- */
-//#define POLARSSL_SSL_SET_CURVES
-
-/**
- * \def POLARSSL_THREADING_ALT
- *
- * Provide your own alternate threading implementation.
- *
- * Requires: POLARSSL_THREADING_C
- *
- * Uncomment this to allow your own alternate threading implementation.
- */
-//#define POLARSSL_THREADING_ALT
-
-/**
- * \def POLARSSL_THREADING_PTHREAD
- *
- * Enable the pthread wrapper layer for the threading layer.
- *
- * Requires: POLARSSL_THREADING_C
- *
- * Uncomment this to enable pthread mutexes.
- */
-//#define POLARSSL_THREADING_PTHREAD
-
-/**
- * \def POLARSSL_VERSION_FEATURES
- *
- * Allow run-time checking of compile-time enabled features. Thus allowing users
- * to check at run-time if the library is for instance compiled with threading
- * support via version_check_feature().
- *
- * Requires: POLARSSL_VERSION_C
- *
- * Comment this to disable run-time checking and save ROM space
- */
-#define POLARSSL_VERSION_FEATURES
-
-/**
- * \def POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3
- *
- * If set, the X509 parser will not break-off when parsing an X509 certificate
- * and encountering an extension in a v1 or v2 certificate.
- *
- * Uncomment to prevent an error.
- */
-//#define POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3
-
-/**
- * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
- *
- * If set, the X509 parser will not break-off when parsing an X509 certificate
- * and encountering an unknown critical extension.
- *
- * Uncomment to prevent an error.
- */
-//#define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
-
-/**
- * \def POLARSSL_X509_CHECK_KEY_USAGE
- *
- * Enable verification of the keyUsage extension (CA and leaf certificates).
- *
- * Disabling this avoids problems with mis-issued and/or misused
- * (intermediate) CA and leaf certificates.
- *
- * \warning Depending on your PKI use, disabling this can be a security risk!
- *
- * Comment to skip keyUsage checking for both CA and leaf certificates.
- */
-#define POLARSSL_X509_CHECK_KEY_USAGE
-
-/**
- * \def POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE
- *
- * Enable verification of the extendedKeyUsage extension (leaf certificates).
- *
- * Disabling this avoids problems with mis-issued and/or misused certificates.
- *
- * \warning Depending on your PKI use, disabling this can be a security risk!
- *
- * Comment to skip extendedKeyUsage checking for certificates.
- */
-#define POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE
-
-/**
- * \def POLARSSL_X509_RSASSA_PSS_SUPPORT
- *
- * Enable parsing and verification of X.509 certificates, CRLs and CSRS
- * signed with RSASSA-PSS (aka PKCS#1 v2.1).
- *
- * Comment this macro to disallow using RSASSA-PSS in certificates.
- */
-#define POLARSSL_X509_RSASSA_PSS_SUPPORT
-
-/**
- * \def POLARSSL_ZLIB_SUPPORT
- *
- * If set, the SSL/TLS module uses ZLIB to support compression and
- * decompression of packet data.
- *
- * \warning TLS-level compression MAY REDUCE SECURITY! See for example the
- * CRIME attack. Before enabling this option, you should examine with care if
- * CRIME or similar exploits may be a applicable to your use case.
- *
- * Used in: library/ssl_tls.c
- * library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This feature requires zlib library and headers to be present.
- *
- * Uncomment to enable use of ZLIB
- */
-//#define POLARSSL_ZLIB_SUPPORT
-/* \} name SECTION: PolarSSL feature support */
-
-/**
- * \name SECTION: PolarSSL modules
- *
- * This section enables or disables entire modules in PolarSSL
- * \{
- */
-
-/**
- * \def POLARSSL_AESNI_C
- *
- * Enable AES-NI support on x86-64.
- *
- * Module: library/aesni.c
- * Caller: library/aes.c
- *
- * Requires: POLARSSL_HAVE_ASM
- *
- * This modules adds support for the AES-NI instructions on x86-64
- */
-//#define POLARSSL_AESNI_C
-
-/**
- * \def POLARSSL_AES_C
- *
- * Enable the AES block cipher.
- *
- * Module: library/aes.c
- * Caller: library/ssl_tls.c
- * library/pem.c
- * library/ctr_drbg.c
- *
- * This module enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
- * TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
- * TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
- * TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
- * TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
- * TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
- * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
- * TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
- * TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
- * TLS_DHE_RSA_WITH_AES_256_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- * TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
- * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
- * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
- * TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
- * TLS_DHE_RSA_WITH_AES_128_CBC_SHA
- * TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
- * TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384
- * TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
- * TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA
- * TLS_DHE_PSK_WITH_AES_256_CBC_SHA
- * TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
- * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
- * TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
- * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA
- * TLS_DHE_PSK_WITH_AES_128_CBC_SHA
- * TLS_RSA_WITH_AES_256_GCM_SHA384
- * TLS_RSA_WITH_AES_256_CBC_SHA256
- * TLS_RSA_WITH_AES_256_CBC_SHA
- * TLS_RSA_WITH_AES_128_GCM_SHA256
- * TLS_RSA_WITH_AES_128_CBC_SHA256
- * TLS_RSA_WITH_AES_128_CBC_SHA
- * TLS_RSA_PSK_WITH_AES_256_GCM_SHA384
- * TLS_RSA_PSK_WITH_AES_256_CBC_SHA384
- * TLS_RSA_PSK_WITH_AES_256_CBC_SHA
- * TLS_RSA_PSK_WITH_AES_128_GCM_SHA256
- * TLS_RSA_PSK_WITH_AES_128_CBC_SHA256
- * TLS_RSA_PSK_WITH_AES_128_CBC_SHA
- * TLS_PSK_WITH_AES_256_GCM_SHA384
- * TLS_PSK_WITH_AES_256_CBC_SHA384
- * TLS_PSK_WITH_AES_256_CBC_SHA
- * TLS_PSK_WITH_AES_128_GCM_SHA256
- * TLS_PSK_WITH_AES_128_CBC_SHA256
- * TLS_PSK_WITH_AES_128_CBC_SHA
- *
- * PEM_PARSE uses AES for decrypting encrypted keys.
- */
-#define POLARSSL_AES_C
-
-/**
- * \def POLARSSL_ARC4_C
- *
- * Enable the ARCFOUR stream cipher.
- *
- * Module: library/arc4.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_ECDSA_WITH_RC4_128_SHA
- * TLS_ECDH_RSA_WITH_RC4_128_SHA
- * TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
- * TLS_ECDHE_RSA_WITH_RC4_128_SHA
- * TLS_ECDHE_PSK_WITH_RC4_128_SHA
- * TLS_DHE_PSK_WITH_RC4_128_SHA
- * TLS_RSA_WITH_RC4_128_SHA
- * TLS_RSA_WITH_RC4_128_MD5
- * TLS_RSA_PSK_WITH_RC4_128_SHA
- * TLS_PSK_WITH_RC4_128_SHA
- */
-#define POLARSSL_ARC4_C
-
-/**
- * \def POLARSSL_ASN1_PARSE_C
- *
- * Enable the generic ASN1 parser.
- *
- * Module: library/asn1.c
- * Caller: library/x509.c
- * library/dhm.c
- * library/pkcs12.c
- * library/pkcs5.c
- * library/pkparse.c
- */
-#define POLARSSL_ASN1_PARSE_C
-
-/**
- * \def POLARSSL_ASN1_WRITE_C
- *
- * Enable the generic ASN1 writer.
- *
- * Module: library/asn1write.c
- * Caller: library/ecdsa.c
- * library/pkwrite.c
- * library/x509_create.c
- * library/x509write_crt.c
- * library/x509write_csr.c
- */
-#define POLARSSL_ASN1_WRITE_C
-
-/**
- * \def POLARSSL_BASE64_C
- *
- * Enable the Base64 module.
- *
- * Module: library/base64.c
- * Caller: library/pem.c
- *
- * This module is required for PEM support (required by X.509).
- */
-#define POLARSSL_BASE64_C
-
-/**
- * \def POLARSSL_BIGNUM_C
- *
- * Enable the multi-precision integer library.
- *
- * Module: library/bignum.c
- * Caller: library/dhm.c
- * library/ecp.c
- * library/ecdsa.c
- * library/rsa.c
- * library/ssl_tls.c
- *
- * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support.
- */
-#define POLARSSL_BIGNUM_C
-
-/**
- * \def POLARSSL_BLOWFISH_C
- *
- * Enable the Blowfish block cipher.
- *
- * Module: library/blowfish.c
- */
-#define POLARSSL_BLOWFISH_C
-
-/**
- * \def POLARSSL_CAMELLIA_C
- *
- * Enable the Camellia block cipher.
- *
- * Module: library/camellia.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
- * TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
- * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
- * TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
- * TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384
- * TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
- */
-#define POLARSSL_CAMELLIA_C
-
-/**
- * \def POLARSSL_CCM_C
- *
- * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher.
- *
- * Module: library/ccm.c
- *
- * Requires: POLARSSL_AES_C or POLARSSL_CAMELLIA_C
- *
- * This module enables the AES-CCM ciphersuites, if other requisites are
- * enabled as well.
- */
-#define POLARSSL_CCM_C
-
-/**
- * \def POLARSSL_CERTS_C
- *
- * Enable the test certificates.
- *
- * Module: library/certs.c
- * Caller:
- *
- * Requires: POLARSSL_PEM_PARSE_C
- *
- * This module is used for testing (ssl_client/server).
- */
-#define POLARSSL_CERTS_C
-
-/**
- * \def POLARSSL_CIPHER_C
- *
- * Enable the generic cipher layer.
- *
- * Module: library/cipher.c
- * Caller: library/ssl_tls.c
- *
- * Uncomment to enable generic cipher wrappers.
- */
-#define POLARSSL_CIPHER_C
-
-/**
- * \def POLARSSL_CTR_DRBG_C
- *
- * Enable the CTR_DRBG AES-256-based random generator.
- *
- * Module: library/ctr_drbg.c
- * Caller:
- *
- * Requires: POLARSSL_AES_C
- *
- * This module provides the CTR_DRBG AES-256 random number generator.
- */
-#define POLARSSL_CTR_DRBG_C
-
-/**
- * \def POLARSSL_DEBUG_C
- *
- * Enable the debug functions.
- *
- * Module: library/debug.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module provides debugging functions.
- */
-#define POLARSSL_DEBUG_C
-
-/**
- * \def POLARSSL_DES_C
- *
- * Enable the DES block cipher.
- *
- * Module: library/des.c
- * Caller: library/pem.c
- * library/ssl_tls.c
- *
- * This module enables the following ciphersuites (if other requisites are
- * enabled as well):
- * TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_PSK_WITH_3DES_EDE_CBC_SHA
- *
- * PEM_PARSE uses DES/3DES for decrypting encrypted keys.
- */
-#define POLARSSL_DES_C
-
-/**
- * \def POLARSSL_DHM_C
- *
- * Enable the Diffie-Hellman-Merkle module.
- *
- * Module: library/dhm.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module is used by the following key exchanges:
- * DHE-RSA, DHE-PSK
- */
-#define POLARSSL_DHM_C
-
-/**
- * \def POLARSSL_ECDH_C
- *
- * Enable the elliptic curve Diffie-Hellman library.
- *
- * Module: library/ecdh.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module is used by the following key exchanges:
- * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK
- *
- * Requires: POLARSSL_ECP_C
- */
-#define POLARSSL_ECDH_C
-
-/**
- * \def POLARSSL_ECDSA_C
- *
- * Enable the elliptic curve DSA library.
- *
- * Module: library/ecdsa.c
- * Caller:
- *
- * This module is used by the following key exchanges:
- * ECDHE-ECDSA
- *
- * Requires: POLARSSL_ECP_C, POLARSSL_ASN1_WRITE_C, POLARSSL_ASN1_PARSE_C
- */
-#define POLARSSL_ECDSA_C
-
-/**
- * \def POLARSSL_ECP_C
- *
- * Enable the elliptic curve over GF(p) library.
- *
- * Module: library/ecp.c
- * Caller: library/ecdh.c
- * library/ecdsa.c
- *
- * Requires: POLARSSL_BIGNUM_C and at least one POLARSSL_ECP_DP_XXX_ENABLED
- */
-#define POLARSSL_ECP_C
-
-/**
- * \def POLARSSL_ENTROPY_C
- *
- * Enable the platform-specific entropy code.
- *
- * Module: library/entropy.c
- * Caller:
- *
- * Requires: POLARSSL_SHA512_C or POLARSSL_SHA256_C
- *
- * This module provides a generic entropy pool
- */
-#define POLARSSL_ENTROPY_C
-
-/**
- * \def POLARSSL_ERROR_C
- *
- * Enable error code to error string conversion.
- *
- * Module: library/error.c
- * Caller:
- *
- * This module enables polarssl_strerror().
- */
-#define POLARSSL_ERROR_C
-
-/**
- * \def POLARSSL_GCM_C
- *
- * Enable the Galois/Counter Mode (GCM) for AES.
- *
- * Module: library/gcm.c
- *
- * Requires: POLARSSL_AES_C or POLARSSL_CAMELLIA_C
- *
- * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other
- * requisites are enabled as well.
- */
-#define POLARSSL_GCM_C
-
-/**
- * \def POLARSSL_HAVEGE_C
- *
- * Enable the HAVEGE random generator.
- *
- * Warning: the HAVEGE random generator is not suitable for virtualized
- * environments
- *
- * Warning: the HAVEGE random generator is dependent on timing and specific
- * processor traits. It is therefore not advised to use HAVEGE as
- * your applications primary random generator or primary entropy pool
- * input. As a secondary input to your entropy pool, it IS able add
- * the (limited) extra entropy it provides.
- *
- * Module: library/havege.c
- * Caller:
- *
- * Requires: POLARSSL_TIMING_C
- *
- * Uncomment to enable the HAVEGE random generator.
- */
-//#define POLARSSL_HAVEGE_C
-
-/**
- * \def POLARSSL_HMAC_DRBG_C
- *
- * Enable the HMAC_DRBG random generator.
- *
- * Module: library/hmac_drbg.c
- * Caller:
- *
- * Requires: POLARSSL_MD_C
- *
- * Uncomment to enable the HMAC_DRBG random number geerator.
- */
-#define POLARSSL_HMAC_DRBG_C
-
-/**
- * \def POLARSSL_MD_C
- *
- * Enable the generic message digest layer.
- *
- * Module: library/md.c
- * Caller:
- *
- * Uncomment to enable generic message digest wrappers.
- */
-#define POLARSSL_MD_C
-
-/**
- * \def POLARSSL_MD2_C
- *
- * Enable the MD2 hash algorithm.
- *
- * Module: library/md2.c
- * Caller:
- *
- * Uncomment to enable support for (rare) MD2-signed X.509 certs.
- */
-//#define POLARSSL_MD2_C
-
-/**
- * \def POLARSSL_MD4_C
- *
- * Enable the MD4 hash algorithm.
- *
- * Module: library/md4.c
- * Caller:
- *
- * Uncomment to enable support for (rare) MD4-signed X.509 certs.
- */
-//#define POLARSSL_MD4_C
-
-/**
- * \def POLARSSL_MD5_C
- *
- * Enable the MD5 hash algorithm.
- *
- * Module: library/md5.c
- * Caller: library/md.c
- * library/pem.c
- * library/ssl_tls.c
- *
- * This module is required for SSL/TLS and X.509.
- * PEM_PARSE uses MD5 for decrypting encrypted keys.
- */
-#define POLARSSL_MD5_C
-
-/**
- * \def POLARSSL_MEMORY_C
- * Deprecated since 1.3.5. Please use POLARSSL_PLATFORM_MEMORY instead.
- */
-//#define POLARSSL_MEMORY_C
-
-/**
- * \def POLARSSL_MEMORY_BUFFER_ALLOC_C
- *
- * Enable the buffer allocator implementation that makes use of a (stack)
- * based buffer to 'allocate' dynamic memory. (replaces malloc() and free()
- * calls)
- *
- * Module: library/memory_buffer_alloc.c
- *
- * Requires: POLARSSL_PLATFORM_C
- * POLARSSL_PLATFORM_MEMORY (to use it within PolarSSL)
- *
- * Enable this module to enable the buffer memory allocator.
- */
-//#define POLARSSL_MEMORY_BUFFER_ALLOC_C
-
-/**
- * \def POLARSSL_NET_C
- *
- * Enable the TCP/IP networking routines.
- *
- * Module: library/net.c
- *
- * This module provides TCP/IP networking routines.
- */
-#define POLARSSL_NET_C
-
-/**
- * \def POLARSSL_OID_C
- *
- * Enable the OID database.
- *
- * Module: library/oid.c
- * Caller: library/asn1write.c
- * library/pkcs5.c
- * library/pkparse.c
- * library/pkwrite.c
- * library/rsa.c
- * library/x509.c
- * library/x509_create.c
- * library/x509_crl.c
- * library/x509_crt.c
- * library/x509_csr.c
- * library/x509write_crt.c
- * library/x509write_csr.c
- *
- * This modules translates between OIDs and internal values.
- */
-#define POLARSSL_OID_C
-
-/**
- * \def POLARSSL_PADLOCK_C
- *
- * Enable VIA Padlock support on x86.
- *
- * Module: library/padlock.c
- * Caller: library/aes.c
- *
- * Requires: POLARSSL_HAVE_ASM
- *
- * This modules adds support for the VIA PadLock on x86.
- */
-//#define POLARSSL_PADLOCK_C
-
-/**
- * \def POLARSSL_PBKDF2_C
- *
- * Enable PKCS#5 PBKDF2 key derivation function.
- * DEPRECATED: Use POLARSSL_PKCS5_C instead
- *
- * Module: library/pbkdf2.c
- *
- * Requires: POLARSSL_PKCS5_C
- *
- * This module adds support for the PKCS#5 PBKDF2 key derivation function.
- */
-#define POLARSSL_PBKDF2_C
-
-/**
- * \def POLARSSL_PEM_PARSE_C
- *
- * Enable PEM decoding / parsing.
- *
- * Module: library/pem.c
- * Caller: library/dhm.c
- * library/pkparse.c
- * library/x509_crl.c
- * library/x509_crt.c
- * library/x509_csr.c
- *
- * Requires: POLARSSL_BASE64_C
- *
- * This modules adds support for decoding / parsing PEM files.
- */
-#define POLARSSL_PEM_PARSE_C
-
-/**
- * \def POLARSSL_PEM_WRITE_C
- *
- * Enable PEM encoding / writing.
- *
- * Module: library/pem.c
- * Caller: library/pkwrite.c
- * library/x509write_crt.c
- * library/x509write_csr.c
- *
- * Requires: POLARSSL_BASE64_C
- *
- * This modules adds support for encoding / writing PEM files.
- */
-#define POLARSSL_PEM_WRITE_C
-
-/**
- * \def POLARSSL_PK_C
- *
- * Enable the generic public (asymetric) key layer.
- *
- * Module: library/pk.c
- * Caller: library/ssl_tls.c
- * library/ssl_cli.c
- * library/ssl_srv.c
- *
- * Requires: POLARSSL_RSA_C or POLARSSL_ECP_C
- *
- * Uncomment to enable generic public key wrappers.
- */
-#define POLARSSL_PK_C
-
-/**
- * \def POLARSSL_PK_PARSE_C
- *
- * Enable the generic public (asymetric) key parser.
- *
- * Module: library/pkparse.c
- * Caller: library/x509_crt.c
- * library/x509_csr.c
- *
- * Requires: POLARSSL_PK_C
- *
- * Uncomment to enable generic public key parse functions.
- */
-#define POLARSSL_PK_PARSE_C
-
-/**
- * \def POLARSSL_PK_WRITE_C
- *
- * Enable the generic public (asymetric) key writer.
- *
- * Module: library/pkwrite.c
- * Caller: library/x509write.c
- *
- * Requires: POLARSSL_PK_C
- *
- * Uncomment to enable generic public key write functions.
- */
-#define POLARSSL_PK_WRITE_C
-
-/**
- * \def POLARSSL_PKCS5_C
- *
- * Enable PKCS#5 functions.
- *
- * Module: library/pkcs5.c
- *
- * Requires: POLARSSL_MD_C
- *
- * This module adds support for the PKCS#5 functions.
- */
-#define POLARSSL_PKCS5_C
-
-/**
- * \def POLARSSL_PKCS11_C
- *
- * Enable wrapper for PKCS#11 smartcard support.
- *
- * Module: library/pkcs11.c
- * Caller: library/pk.c
- *
- * Requires: POLARSSL_PK_C
- *
- * This module enables SSL/TLS PKCS #11 smartcard support.
- * Requires the presence of the PKCS#11 helper library (libpkcs11-helper)
- */
-//#define POLARSSL_PKCS11_C
-
-/**
- * \def POLARSSL_PKCS12_C
- *
- * Enable PKCS#12 PBE functions.
- * Adds algorithms for parsing PKCS#8 encrypted private keys
- *
- * Module: library/pkcs12.c
- * Caller: library/pkparse.c
- *
- * Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_CIPHER_C, POLARSSL_MD_C
- * Can use: POLARSSL_ARC4_C
- *
- * This module enables PKCS#12 functions.
- */
-#define POLARSSL_PKCS12_C
-
-/**
- * \def POLARSSL_PLATFORM_C
- *
- * Enable the platform abstraction layer that allows you to re-assign
- * functions like malloc(), free(), printf(), fprintf()
- *
- * Module: library/platform.c
- * Caller: Most other .c files
- *
- * This module enables abstraction of common (libc) functions.
- */
-//#define POLARSSL_PLATFORM_C
-
-/**
- * \def POLARSSL_RIPEMD160_C
- *
- * Enable the RIPEMD-160 hash algorithm.
- *
- * Module: library/ripemd160.c
- * Caller: library/md.c
- *
- */
-#define POLARSSL_RIPEMD160_C
-
-/**
- * \def POLARSSL_RSA_C
- *
- * Enable the RSA public-key cryptosystem.
- *
- * Module: library/rsa.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509.c
- *
- * This module is used by the following key exchanges:
- * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK
- *
- * Requires: POLARSSL_BIGNUM_C, POLARSSL_OID_C
- */
-#define POLARSSL_RSA_C
-
-/**
- * \def POLARSSL_SHA1_C
- *
- * Enable the SHA1 cryptographic hash algorithm.
- *
- * Module: library/sha1.c
- * Caller: library/md.c
- * library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509write_crt.c
- *
- * This module is required for SSL/TLS and SHA1-signed certificates.
- */
-#define POLARSSL_SHA1_C
-
-/**
- * \def POLARSSL_SHA256_C
- *
- * Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
- * (Used to be POLARSSL_SHA2_C)
- *
- * Module: library/sha256.c
- * Caller: library/entropy.c
- * library/md.c
- * library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module adds support for SHA-224 and SHA-256.
- * This module is required for the SSL/TLS 1.2 PRF function.
- */
-#define POLARSSL_SHA256_C
-
-/**
- * \def POLARSSL_SHA512_C
- *
- * Enable the SHA-384 and SHA-512 cryptographic hash algorithms.
- * (Used to be POLARSSL_SHA4_C)
- *
- * Module: library/sha512.c
- * Caller: library/entropy.c
- * library/md.c
- * library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module adds support for SHA-384 and SHA-512.
- */
-#define POLARSSL_SHA512_C
-
-/**
- * \def POLARSSL_SSL_CACHE_C
- *
- * Enable simple SSL cache implementation.
- *
- * Module: library/ssl_cache.c
- * Caller:
- *
- * Requires: POLARSSL_SSL_CACHE_C
- */
-#define POLARSSL_SSL_CACHE_C
-
-/**
- * \def POLARSSL_SSL_CLI_C
- *
- * Enable the SSL/TLS client code.
- *
- * Module: library/ssl_cli.c
- * Caller:
- *
- * Requires: POLARSSL_SSL_TLS_C
- *
- * This module is required for SSL/TLS client support.
- */
-#define POLARSSL_SSL_CLI_C
-
-/**
- * \def POLARSSL_SSL_SRV_C
- *
- * Enable the SSL/TLS server code.
- *
- * Module: library/ssl_srv.c
- * Caller:
- *
- * Requires: POLARSSL_SSL_TLS_C
- *
- * This module is required for SSL/TLS server support.
- */
-#define POLARSSL_SSL_SRV_C
-
-/**
- * \def POLARSSL_SSL_TLS_C
- *
- * Enable the generic SSL/TLS code.
- *
- * Module: library/ssl_tls.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * Requires: POLARSSL_CIPHER_C, POLARSSL_MD_C
- * and at least one of the POLARSSL_SSL_PROTO_* defines
- *
- * This module is required for SSL/TLS.
- */
-#define POLARSSL_SSL_TLS_C
-
-/**
- * \def POLARSSL_THREADING_C
- *
- * Enable the threading abstraction layer.
- * By default PolarSSL assumes it is used in a non-threaded environment or that
- * contexts are not shared between threads. If you do intend to use contexts
- * between threads, you will need to enable this layer to prevent race
- * conditions.
- *
- * Module: library/threading.c
- *
- * This allows different threading implementations (self-implemented or
- * provided).
- *
- * You will have to enable either POLARSSL_THREADING_ALT or
- * POLARSSL_THREADING_PTHREAD.
- *
- * Enable this layer to allow use of mutexes within PolarSSL
- */
-//#define POLARSSL_THREADING_C
-
-/**
- * \def POLARSSL_TIMING_C
- *
- * Enable the portable timing interface.
- *
- * Module: library/timing.c
- * Caller: library/havege.c
- *
- * This module is used by the HAVEGE random number generator.
- */
-#define POLARSSL_TIMING_C
-
-/**
- * \def POLARSSL_VERSION_C
- *
- * Enable run-time version information.
- *
- * Module: library/version.c
- *
- * This module provides run-time version information.
- */
-#define POLARSSL_VERSION_C
-
-/**
- * \def POLARSSL_X509_USE_C
- *
- * Enable X.509 core for using certificates.
- *
- * Module: library/x509.c
- * Caller: library/x509_crl.c
- * library/x509_crt.c
- * library/x509_csr.c
- *
- * Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_BIGNUM_C, POLARSSL_OID_C,
- * POLARSSL_PK_PARSE_C
- *
- * This module is required for the X.509 parsing modules.
- */
-#define POLARSSL_X509_USE_C
-
-/**
- * \def POLARSSL_X509_CRT_PARSE_C
- *
- * Enable X.509 certificate parsing.
- *
- * Module: library/x509_crt.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * Requires: POLARSSL_X509_USE_C
- *
- * This module is required for X.509 certificate parsing.
- */
-#define POLARSSL_X509_CRT_PARSE_C
-
-/**
- * \def POLARSSL_X509_CRL_PARSE_C
- *
- * Enable X.509 CRL parsing.
- *
- * Module: library/x509_crl.c
- * Caller: library/x509_crt.c
- *
- * Requires: POLARSSL_X509_USE_C
- *
- * This module is required for X.509 CRL parsing.
- */
-#define POLARSSL_X509_CRL_PARSE_C
-
-/**
- * \def POLARSSL_X509_CSR_PARSE_C
- *
- * Enable X.509 Certificate Signing Request (CSR) parsing.
- *
- * Module: library/x509_csr.c
- * Caller: library/x509_crt_write.c
- *
- * Requires: POLARSSL_X509_USE_C
- *
- * This module is used for reading X.509 certificate request.
- */
-#define POLARSSL_X509_CSR_PARSE_C
-
-/**
- * \def POLARSSL_X509_CREATE_C
- *
- * Enable X.509 core for creating certificates.
- *
- * Module: library/x509_create.c
- *
- * Requires: POLARSSL_BIGNUM_C, POLARSSL_OID_C, POLARSSL_PK_WRITE_C
- *
- * This module is the basis for creating X.509 certificates and CSRs.
- */
-#define POLARSSL_X509_CREATE_C
-
-/**
- * \def POLARSSL_X509_CRT_WRITE_C
- *
- * Enable creating X.509 certificates.
- *
- * Module: library/x509_crt_write.c
- *
- * Requires: POLARSSL_CREATE_C
- *
- * This module is required for X.509 certificate creation.
- */
-#define POLARSSL_X509_CRT_WRITE_C
-
-/**
- * \def POLARSSL_X509_CSR_WRITE_C
- *
- * Enable creating X.509 Certificate Signing Requests (CSR).
- *
- * Module: library/x509_csr_write.c
- *
- * Requires: POLARSSL_CREATE_C
- *
- * This module is required for X.509 certificate request writing.
- */
-#define POLARSSL_X509_CSR_WRITE_C
-
-/**
- * \def POLARSSL_XTEA_C
- *
- * Enable the XTEA block cipher.
- *
- * Module: library/xtea.c
- * Caller:
- */
-#define POLARSSL_XTEA_C
-
-/* \} name SECTION: PolarSSL modules */
-
-/**
- * \name SECTION: Module configuration options
- *
- * This section allows for the setting of module specific sizes and
- * configuration options. The default values are already present in the
- * relevant header files and should suffice for the regular use cases.
- *
- * Our advice is to enable options and change their values here
- * only if you have a good reason and know the consequences.
- *
- * Please check the respective header file for documentation on these
- * parameters (to prevent duplicate documentation).
- * \{
- */
-
-/* MPI / BIGNUM options */
-//#define POLARSSL_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */
-//#define POLARSSL_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
-
-/* CTR_DRBG options */
-//#define CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
-//#define CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */
-//#define CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */
-//#define CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */
-//#define CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
-
-/* HMAC_DRBG options */
-//#define POLARSSL_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */
-//#define POLARSSL_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */
-//#define POLARSSL_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */
-//#define POLARSSL_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
-
-/* ECP options */
-//#define POLARSSL_ECP_MAX_BITS 521 /**< Maximum bit size of groups */
-//#define POLARSSL_ECP_WINDOW_SIZE 6 /**< Maximum window size used */
-//#define POLARSSL_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */
-
-/* Entropy options */
-//#define ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
-//#define ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
-
-/* Memory buffer allocator options */
-//#define POLARSSL_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
-
-/* Platform options */
-//#define POLARSSL_PLATFORM_STD_MEM_HDR /**< Header to include if POLARSSL_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
-//#define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use, can be undefined */
-//#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
-//#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
-//#define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
-
-/* SSL Cache options */
-//#define SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
-//#define SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */
-
-/* SSL options */
-//#define SSL_MAX_CONTENT_LEN 16384 /**< Size of the input / output buffer */
-//#define SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
-//#define POLARSSL_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
-
-/**
- * Complete list of ciphersuites to use, in order of preference.
- *
- * \warning No dependency checking is done on that field! This option can only
- * be used to restrict the set of available ciphersuites. It is your
- * responsibility to make sure the needed modules are active.
- *
- * Use this to save a few hundred bytes of ROM (default ordering of all
- * available ciphersuites) and a few to a few hundred bytes of RAM.
- *
- * The value below is only an example, not the default.
- */
-//#define SSL_CIPHERSUITES TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
-
-/* Debug options */
-//#define POLARSSL_DEBUG_DFL_MODE POLARSSL_DEBUG_LOG_FULL /**< Default log: Full or Raw */
-
-/* \} name SECTION: Module configuration options */
-
-
-#endif /* POLARSSL_CONFIG_H */
From 79f3cec717301e0ba9ee89a9cc0b41df677b06ce Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 25 May 2020 02:30:00 +0200
Subject: [PATCH 142/527] use system zlib if available (client only)
---
CHANGELOG.md | 1 +
client/Makefile | 15 +++++++++++++++
doc/md/Development/Maintainers.md | 2 ++
3 files changed, 18 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9d62254f..fdb0b7c05 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Change, use system Lua library if available (@doegox)
- Change, use system Jansson library if available (@doegox)
- Change, use system Whereami library if available (@doegox)
+ - Change, use system Zlib library if available (@doegox)
- Fix release version information (@doegox)
## [ice coffee.4.9237][2020-05-21]
diff --git a/client/Makefile b/client/Makefile
index 59c08f144..c1713e74c 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -165,6 +165,15 @@ INCLUDES += $(WAILIBINC)
## Zlib
# system library useable? Need to recompress hardnested tables?
+ifneq ($(SKIPZLIBSYSTEM),1)
+ ZLIBINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags zlib 2>/dev/null)
+ ZLIBLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs zlib 2>/dev/null)
+ ifneq ($(ZLIBLDLIBS),)
+ ZLIB = $(ZLIBLDLIBS)
+ ZLIBINC = $(ZLIBINCLUDES)
+ ZLIB_FOUND = 1
+ endif
+endif
LDLIBS +=$(ZLIB)
INCLUDES += $(ZLIBINC)
@@ -328,6 +337,10 @@ ifeq ($(WAI_FOUND),1)
$(info Whereami library: system library found)
endif
+ifeq ($(ZLIB_FOUND),1)
+ $(info Zlib library: system library found)
+endif
+
$(info compiler version: $(shell $(CC) --version|head -n 1))
$(info ===================================================================)
@@ -622,8 +635,10 @@ mbedtls:
$(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) OBJDIR=$(ROOT_DIR)$(OBJDIR) BINDIR=$(ROOT_DIR)$(OBJDIR) all
zlib:
+ifneq ($(ZLIB_FOUND),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(ZLIBPATH) OBJDIR=$(ROOT_DIR)$(OBJDIR) BINDIR=$(ROOT_DIR)$(OBJDIR) all
+endif
########
# misc #
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 5d1400a7f..0ea33b924 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -62,7 +62,9 @@ It's also possible to skip parts even if libraries are present in the compilatio
* `make client SKIPQT=1` to skip GUI even if Qt is present
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
* `make client SKIPLUASYSTEM=1` to skip system Lua lib even if liblua5.2 is present, use embedded Lua lib instead
+* `make client SKIPJANSSONSYSTEM=1` to skip system Jansson lib even if libjansson is present, use embedded Jansson lib instead
* `make client SKIPWHEREAMISYSTEM=1` to skip system Whereami lib even if libwhereami is present, use embedded whereami lib instead
+* `make client SKIPZLIBSYSTEM=1` to skip system Zlib even if libz is present, use embedded Zlib instead
If you're cross-compiling, these ones might be useful:
From 68da06f721f0f907c2582e6f58be959f29b87ea2 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 25 May 2020 10:15:51 +0200
Subject: [PATCH 143/527] makefile reorder
---
client/Makefile | 93 ++++++++++++++++++++++++-------------------------
1 file changed, 46 insertions(+), 47 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index c1713e74c..c97cd6181 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -32,11 +32,6 @@ AMIIBOLIBPATH = ./deps/amiitool
AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
-## Tinycbor
-CBORLIBPATH = ./deps/tinycbor
-CBORLIBINC = -I$(CBORLIBPATH)
-CBORLIB = $(CBORLIBPATH)/tinycbor.a
-
## Cliparser / Argtable3
CLIPARSERLIBPATH = ./deps/cliparser
CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
@@ -73,6 +68,11 @@ REVENGLIBPATH = ./deps/reveng
REVENGLIBINC = -I$(REVENGLIBPATH)
REVENGLIB = $(REVENGLIBPATH)/libreveng.a
+## Tinycbor
+TINYCBORLIBPATH = ./deps/tinycbor
+TINYCBORLIBINC = -I$(TINYCBORLIBPATH)
+TINYCBORLIB = $(TINYCBORLIBPATH)/tinycbor.a
+
## Whereami
WAILIBPATH = ./deps/whereami
WAILIBINC = -I$(WAILIBPATH)
@@ -101,11 +101,6 @@ ZLIB = $(OBJDIR)/libz.a
LDLIBS += $(AMIIBOLIB)
INCLUDES += $(AMIIBOLIBINC)
-## Tinycbor
-# not distributed as system library
-LDLIBS += $(CBORLIB)
-INCLUDES += $(CBORLIBINC)
-
## Cliparser / Argtable3
# not distributed as system library
LDLIBS += $(CLIPARSERLIB)
@@ -152,6 +147,11 @@ INCLUDES += $(MBEDTLSLIBINC)
LDLIBS += $(REVENGLIB)
INCLUDES += $(REVENGLIBINC)
+## Tinycbor
+# not distributed as system library
+LDLIBS += $(TINYCBORLIB)
+INCLUDES += $(TINYCBORLIBINC)
+
## Whereami
ifneq ($(SKIPWHEREAMISYSTEM),1)
ifneq (,$(wildcard /usr/include/whereami.h))
@@ -524,7 +524,7 @@ all: $(BINS)
all-static: LDLIBS:=-static $(LDLIBS)
all-static: $(BINS)
-proxmark3: $(OBJS) liblua jansson tinycbor reveng mbedtls zlib amiibo hardnested cliparser whereami lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
+proxmark3: $(OBJS) amiibo cliparser jansson hardnested lua mbedtls reveng tinycbor whereami zlib lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
$(info [=] LD $@)
$(Q)$(LD) $(PM3LDFLAGS) $(OBJS) $(LDLIBS) -o $@
@@ -549,17 +549,17 @@ lualibs/mfc_default_keys.lua : mfc_default_keys.dic
clean:
$(Q)$(RM) $(CLEAN)
$(Q)$(RMDIR) $(OBJDIR)
- $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) clean
- $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
- $(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) clean
- $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) clean
- $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) clean
@# Just in case someone compiled within these dirs:
- $(Q)$(MAKE) --no-print-directory -C $(ZLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(ZLIBPATH) clean
install: all
$(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
@@ -591,30 +591,6 @@ tarbin: $(BINS)
# local libraries targets #
###########################
-liblua:
-ifneq ($(LUA_FOUND),1)
- $(info [*] MAKE $@ for $(LUAPLATFORM))
- $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
-endif
-
-jansson:
-ifneq ($(JANSSON_FOUND),1)
- $(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
-endif
-
-tinycbor:
- $(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(CBORLIBPATH) all
-
-reveng:
- $(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) all
-
-hardnested:
- $(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) all
-
amiibo:
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) all
@@ -623,17 +599,40 @@ cliparser:
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) all
+hardnested:
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) all
+
+jansson:
+ifneq ($(JANSSON_FOUND),1)
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
+endif
+
+lua:
+ifneq ($(LUA_FOUND),1)
+ $(info [*] MAKE $@ for $(LUAPLATFORM))
+ $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
+endif
+
+mbedtls:
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) OBJDIR=$(ROOT_DIR)$(OBJDIR) BINDIR=$(ROOT_DIR)$(OBJDIR) all
+
+reveng:
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) all
+
+tinycbor:
+ $(info [*] MAKE $@)
+ $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) all
+
whereami:
ifneq ($(WAI_FOUND),1)
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) all
endif
-# common libraries:
-mbedtls:
- $(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) OBJDIR=$(ROOT_DIR)$(OBJDIR) BINDIR=$(ROOT_DIR)$(OBJDIR) all
-
zlib:
ifneq ($(ZLIB_FOUND),1)
$(info [*] MAKE $@)
@@ -644,7 +643,7 @@ endif
# misc #
########
-.PHONY: all clean install uninstall tarbin liblua jansson tinycbor reveng hardnested amiibo cliparser whereami mbedtls zlib
+.PHONY: all clean install uninstall tarbin amiibo cliparser hardnested jansson lua mbedtls reveng tinycbor whereami zlib
# version.c should be remade on every compilation
src/version.c: default_version.c
From fc2ff7bb0affdfa122954a5f3ac73b3ad0bd6b02 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 25 May 2020 13:05:44 +0200
Subject: [PATCH 144/527] Makefile: remove /usr/local/lib
---
client/Makefile | 2 --
1 file changed, 2 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index c97cd6181..ab109714b 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -16,8 +16,6 @@ VPATH = ../common src
vpath %.dic dictionaries
OBJDIR = obj
-LDLIBS ?= -L/usr/local/lib
-
ifeq ($(platform),Darwin)
# cf brew info qt: qt not symlinked anymore
PKG_CONFIG_ENV := PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig
From 162b7b58dff473e846d7bb0398642c6f78d4fe5c Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Mon, 25 May 2020 13:11:44 +0200
Subject: [PATCH 145/527] Makefile: more info
---
client/Makefile | 82 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 54 insertions(+), 28 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index ab109714b..35adc71eb 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -72,9 +72,9 @@ TINYCBORLIBINC = -I$(TINYCBORLIBPATH)
TINYCBORLIB = $(TINYCBORLIBPATH)/tinycbor.a
## Whereami
-WAILIBPATH = ./deps/whereami
-WAILIBINC = -I$(WAILIBPATH)
-WAILIB = $(WAILIBPATH)/libwhereami.a
+WHEREAMILIBPATH = ./deps/whereami
+WHEREAMILIBINC = -I$(WHEREAMILIBPATH)
+WHEREAMILIB = $(WHEREAMILIBPATH)/libwhereami.a
##########################
# common local libraries #
@@ -153,13 +153,13 @@ INCLUDES += $(TINYCBORLIBINC)
## Whereami
ifneq ($(SKIPWHEREAMISYSTEM),1)
ifneq (,$(wildcard /usr/include/whereami.h))
- WAILIB = -lwhereami
- WAILIBINC =
- WAI_FOUND = 1
+ WHEREAMILIB = -lwhereami
+ WHEREAMILIBINC =
+ WHEREAMI_FOUND = 1
endif
endif
-LDLIBS += $(WAILIB)
-INCLUDES += $(WAILIBINC)
+LDLIBS += $(WHEREAMILIB)
+INCLUDES += $(WHEREAMILIBINC)
## Zlib
# system library useable? Need to recompress hardnested tables?
@@ -305,38 +305,64 @@ $(info Client platform: $(platform))
ifeq ($(SKIPQT),1)
$(info GUI support: skipped)
-else ifeq ($(QT_FOUND),1)
- ifeq ($(QT5_FOUND),1)
- $(info GUI support: QT5 found, enabled)
- else
- $(info GUI support: QT4 found, enabled)
- endif
else
- $(info GUI support: QT not found, disabled)
+ ifeq ($(QT_FOUND),1)
+ ifeq ($(QT5_FOUND),1)
+ $(info GUI support: QT5 found, enabled)
+ else
+ $(info GUI support: QT4 found, enabled)
+ endif
+ else
+ $(info GUI support: QT not found, disabled)
+ endif
endif
ifeq ($(SKIPBT),1)
$(info native BT support: skipped)
-else ifneq ($(BTLDLIBS),)
- $(info native BT support: Bluez found, enabled)
else
- $(info native BT support: Bluez not found, disabled)
+ ifeq ($(BT_FOUND),1)
+ $(info native BT support: Bluez found, enabled)
+ else
+ $(info native BT support: Bluez not found, disabled)
+ endif
endif
-ifeq ($(JANSSON_FOUND),1)
+ifeq ($(SKIPJANSSONSYSTEM),1)
+ $(info Jansson library: local library forced)
+else ifeq ($(JANSSON_FOUND),1)
$(info Jansson library: system library found)
+else
+ $(info Jansson library: system library not found, using local library)
endif
-ifeq ($(LUA_FOUND),1)
- $(info Lua library: system library found)
+ifeq ($(SKIPLUASYSTEM),1)
+ $(info Lua library: local library forced)
+else
+ ifeq ($(LUA_FOUND),1)
+ $(info Lua library: system library found)
+ else
+ $(info Lua library: system library not found, using local library)
+ endif
endif
-ifeq ($(WAI_FOUND),1)
- $(info Whereami library: system library found)
+ifeq ($(SKIPWHEREAMISYSTEM),1)
+ $(info Whereami library: local library forced)
+else
+ ifeq ($(WHEREAMI_FOUND),1)
+ $(info Whereami library: system library found)
+ else
+ $(info Whereami library: system library not found, using local library)
+ endif
endif
-ifeq ($(ZLIB_FOUND),1)
- $(info Zlib library: system library found)
+ifeq ($(SKIPZLIBSYSTEM),1)
+ $(info Zlib library: local library forced)
+else
+ ifeq ($(ZLIB_FOUND),1)
+ $(info Zlib library: system library found)
+ else
+ $(info Zlib library: system library not found, using local library)
+ endif
endif
$(info compiler version: $(shell $(CC) --version|head -n 1))
@@ -554,7 +580,7 @@ clean:
$(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) clean
- $(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) clean
+ $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) clean
@# Just in case someone compiled within these dirs:
$(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) clean
$(Q)$(MAKE) --no-print-directory -C $(ZLIBPATH) clean
@@ -626,9 +652,9 @@ tinycbor:
$(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) all
whereami:
-ifneq ($(WAI_FOUND),1)
+ifneq ($(WHEREAMI_FOUND),1)
$(info [*] MAKE $@)
- $(Q)$(MAKE) --no-print-directory -C $(WAILIBPATH) all
+ $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) all
endif
zlib:
From b3ff89e41ed08c5cebd88c39a6fe30be1060e41c Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 10:57:11 +0200
Subject: [PATCH 146/527] sign-compare
---
client/src/aidsearch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/aidsearch.c b/client/src/aidsearch.c
index 291d2035c..7361442b0 100644
--- a/client/src/aidsearch.c
+++ b/client/src/aidsearch.c
@@ -122,8 +122,8 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
goto out;
json_t *elm = NULL;
- int maxaidlen = 0;
- for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
+ uint32_t maxaidlen = 0;
+ for (uint32_t elmindx = 0; elmindx < json_array_size(root); elmindx++) {
json_t *data = AIDSearchGetElm(root, elmindx);
if (data == NULL)
continue;
From e95f8072517acf4fff0b4bfe3ba4b2754cf84a56 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 10:59:12 +0200
Subject: [PATCH 147/527] sign-compare
---
client/src/cmddata.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/cmddata.c b/client/src/cmddata.c
index 55fac1d0b..5aba8e537 100644
--- a/client/src/cmddata.c
+++ b/client/src/cmddata.c
@@ -1624,7 +1624,7 @@ int getSamples(uint32_t n, bool verbose) {
if (verbose) PrintAndLogEx(INFO, "Unpacking...");
BitstreamOut bout = { got, bits_per_sample * n, 0};
- int j = 0;
+ uint32_t j = 0;
for (j = 0; j * bits_per_sample < n * 8 && j < n; j++) {
uint8_t sample = getByte(bits_per_sample, &bout);
GraphBuffer[j] = ((int) sample) - 127;
@@ -1634,7 +1634,7 @@ int getSamples(uint32_t n, bool verbose) {
if (verbose) PrintAndLogEx(INFO, "Unpacked %d samples", j);
} else {
- for (int j = 0; j < n; j++) {
+ for (uint32_t j = 0; j < n; j++) {
GraphBuffer[j] = ((int)got[j]) - 127;
}
GraphTraceLen = n;
From 26e8a5a1e051bae20845d92487d6af310d50ce09 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 11:29:44 +0200
Subject: [PATCH 148/527] added check for systemlib python3 in makefile
---
client/Makefile | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/client/Makefile b/client/Makefile
index 35adc71eb..adc07c88b 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -10,7 +10,7 @@ ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
include ../Makefile.defs
INSTALLBIN = proxmark3
-INSTALLSHARE = cmdscripts lualibs luascripts resources dictionaries
+INSTALLSHARE = cmdscripts lualibs luascripts pyscripts resources dictionaries
VPATH = ../common src
vpath %.dic dictionaries
@@ -135,6 +135,18 @@ endif
LDLIBS += $(LUALIB)
INCLUDES += $(LUALIBINC)
+## Python3
+#PYTHON_CONFIG := python3-config
+PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
+PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
+ifneq ($(PYTHONLDLIBS),)
+ PYTHONLIB = $(PYTHONLDLIBS)
+ PYTHONLIBINC = $(PYTHONINCLUDES)
+ PYTHON_FOUND = 1
+endif
+LDLIBS += $(PYTHONLIB)
+INCLUDES += $(PYTHONLIBINC)
+
## mbed TLS
# system library cannot be used because it is compiled by default without CMAC support
LDLIBS +=$(MBEDTLSLIB)
@@ -256,6 +268,9 @@ endif
LDLIBS += $(QTLDLIBS)
CXXINCLUDES += $(QTINCLUDES)
+## Python
+
+
#######################################################################################################
CFLAGS ?= $(DEFCFLAGS)
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
@@ -345,6 +360,12 @@ else
endif
endif
+ifeq ($(PYTHON_FOUND),1)
+ $(info Python library: system library found)
+else
+ $(info Python library: system library not found, disabled)
+endif
+
ifeq ($(SKIPWHEREAMISYSTEM),1)
$(info Whereami library: local library forced)
else
From 06927f983a3f20bfc2c5e6a120c0ec659eda1ce2 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 11:30:17 +0200
Subject: [PATCH 149/527] added python3 as script engine, if installed on
system
---
client/src/cmdscript.c | 113 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 106 insertions(+), 7 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 4f4a372d8..b2ad53f50 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -7,10 +7,17 @@
//-----------------------------------------------------------------------------
// Some lua scripting glue to proxmark core.
//-----------------------------------------------------------------------------
+// 2020, added Python support (@iceman100)
+
#include
#include
+#define PY_SSIZE_T_CLEAN
+#include
+#include
+
+
#include "cmdparser.h" // command_t
#include "scripting.h"
#include "comms.h"
@@ -24,6 +31,12 @@
#include "ui.h"
#include "fileutils.h"
+typedef enum {
+ PM3_LUA,
+ PM3_CMD,
+ PM3_PY
+} pm3_scriptfile_t;
+
static int CmdHelp(const char *Cmd);
/**
@@ -36,7 +49,12 @@ static int CmdScriptList(const char *Cmd) {
int ret = searchAndList(LUA_SCRIPTS_SUBDIR, ".lua");
if (ret != PM3_SUCCESS)
return ret;
- return searchAndList(CMD_SCRIPTS_SUBDIR, ".cmd");
+
+ ret = searchAndList(CMD_SCRIPTS_SUBDIR, ".cmd");
+ if (ret != PM3_SUCCESS)
+ return ret;
+
+ return searchAndList(PYTHON_SCRIPTS_SUBDIR, ".py");
}
/**
@@ -54,9 +72,18 @@ static int CmdScriptRun(const char *Cmd) {
int arg_len = 0;
static uint8_t luascriptfile_idx = 0;
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
-
+
+ char *extension_chk;
+ extension_chk = str_dup(preferredName);
+ str_lower(extension_chk);
+ pm3_scriptfile_t ext = PM3_LUA;
+ if (str_endswith(preferredName, ".cmd"))
+ ext = PM3_CMD;
+ if (str_endswith(preferredName, ".py"))
+ ext = PM3_PY;
+
char *script_path = NULL;
- if ((!str_endswith(preferredName, ".cmd")) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
+ if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
int error;
if (luascriptfile_idx == MAX_NESTED_LUASCRIPT) {
PrintAndLogEx(ERR, "too many nested scripts, skipping %s\n", script_path);
@@ -112,7 +139,7 @@ static int CmdScriptRun(const char *Cmd) {
return PM3_SUCCESS;
}
- if ((!str_endswith(preferredName, ".lua")) && (searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", true) == PM3_SUCCESS)) {
+ if ((ext == PM3_CMD) && (searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", true) == PM3_SUCCESS)) {
PrintAndLogEx(SUCCESS, "executing Cmd " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
@@ -123,11 +150,83 @@ static int CmdScriptRun(const char *Cmd) {
free(script_path);
return ret;
}
+
+ /*
+
+ For apt (Ubuntu, Debian...):
+ sudo apt-get install python3-dev # for python3.x installs
+
+ For yum (CentOS, RHEL...):
+ sudo yum install python3-devel # for python3.x installs
+
+ For dnf (Fedora...):
+ sudo dnf install python3-devel # for python3.x installs
+
+ For zypper (openSUSE...):
+ sudo zypper in python3-devel # for python3.x installs
+
+ For apk (Alpine...):
+
+ # This is a departure from the normal Alpine naming
+ # scheme, which uses py2- and py3- prefixes
+
+ sudo apk add python3-dev # for python3.x installs
+
+ For apt-cyg (Cygwin...):
+ apt-cyg install python3-devel # for python3.x installs
+
+ */
+
+ if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
+
+ PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
+ PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
+
+ wchar_t *program = Py_DecodeLocale(script_path, NULL);
+ if (program == NULL) {
+ PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), script_path);
+ free(script_path);
+ return PM3_ESOFT;
+ }
+
+ // optional but recommended
+ Py_SetProgramName(program);
+ Py_Initialize();
+// PySys_SetArgv(arguments, script_path); // we dont have argc , argv here
+
+ FILE *f = fopen(script_path, "r");
+ if (f == NULL) {
+ PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), script_path);
+ free(script_path);
+ return PM3_ESOFT;
+ }
+
+ PyRun_SimpleFile(f, script_path);
+
+ fclose(f);
+
+ if (Py_FinalizeEx() < 0) {
+ free(script_path);
+ return PM3_ESOFT;
+ }
+
+ PyMem_RawFree(program);
+ free(script_path);
+ PrintAndLogEx(SUCCESS, "\nfinished " _YELLOW_("%s"), preferredName);
+ return PM3_SUCCESS;
+ }
// file not found, let's search again to display the error messages
int ret = PM3_EUNDEF;
- if (!str_endswith(preferredName, ".cmd")) ret = searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", false);
- if (!str_endswith(preferredName, ".lua")) ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
+ if (ext == PM3_LUA)
+ ret = searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", false);
+
+ if (ext == PM3_CMD)
+ ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
+
+ if (ext == PM3_PY)
+ ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
+
free(script_path);
return ret;
}
@@ -135,7 +234,7 @@ static int CmdScriptRun(const char *Cmd) {
static command_t CommandTable[] = {
{"help", CmdHelp, AlwaysAvailable, "This help"},
{"list", CmdScriptList, AlwaysAvailable, "List available scripts"},
- {"run", CmdScriptRun, AlwaysAvailable, " -- Execute a script"},
+ {"run", CmdScriptRun, AlwaysAvailable, " -- execute a script"},
{NULL, NULL, NULL, NULL}
};
From 00ece05e79b4a74de8dcad1857cb9574a5687276 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 11:30:37 +0200
Subject: [PATCH 150/527] added python3 scripts has their own folder
---
include/common.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/common.h b/include/common.h
index 4d6efcce2..9f04d75c7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -24,6 +24,7 @@
#define PM3_USER_DIRECTORY PATHSEP ".proxmark3" PATHSEP
// PM3 subdirectories:
+#define PYTHON_SCRIPTS_SUBDIR "pyscripts" PATHSEP
#define CMD_SCRIPTS_SUBDIR "cmdscripts" PATHSEP
#define DICTIONARIES_SUBDIR "dictionaries" PATHSEP
#define LUA_LIBRARIES_SUBDIR "lualibs" PATHSEP
From 0e57a1c6cda97648ae42d5ac7bf605f28215e154 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 11:48:37 +0200
Subject: [PATCH 151/527] optional python.. Thanks @doegox!
---
client/Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/client/Makefile b/client/Makefile
index adc07c88b..9ee678a4b 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -293,6 +293,11 @@ ifeq ($(BT_FOUND),1)
PM3CFLAGS += -DHAVE_BLUEZ
endif
+ifeq ($(PYTHON_FOUND),1)
+ PM3CFLAGS += -DHAVE_PYTHON
+endif
+
+
CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS)
PM3CXXFLAGS += -I../include
From f852bf41c3a5bfde85f3f729bb6da75436839d9a Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 11:49:26 +0200
Subject: [PATCH 152/527] adapt to optional python, Thanks @doegox!
---
client/src/cmdscript.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index b2ad53f50..0264a16f6 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -13,9 +13,11 @@
#include
#include
-#define PY_SSIZE_T_CLEAN
+#ifdef DHAVE_PYTHON
+//#define PY_SSIZE_T_CLEAN
#include
#include
+#endif
#include "cmdparser.h" // command_t
@@ -79,8 +81,10 @@ static int CmdScriptRun(const char *Cmd) {
pm3_scriptfile_t ext = PM3_LUA;
if (str_endswith(preferredName, ".cmd"))
ext = PM3_CMD;
+#ifdef DHAVE_PYTHON
if (str_endswith(preferredName, ".py"))
ext = PM3_PY;
+#endif
char *script_path = NULL;
if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
@@ -151,8 +155,7 @@ static int CmdScriptRun(const char *Cmd) {
return ret;
}
- /*
-
+ /*
For apt (Ubuntu, Debian...):
sudo apt-get install python3-dev # for python3.x installs
@@ -177,6 +180,7 @@ static int CmdScriptRun(const char *Cmd) {
*/
+#ifdef DHAVE_PYTHON
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
@@ -215,6 +219,7 @@ static int CmdScriptRun(const char *Cmd) {
PrintAndLogEx(SUCCESS, "\nfinished " _YELLOW_("%s"), preferredName);
return PM3_SUCCESS;
}
+#endif
// file not found, let's search again to display the error messages
int ret = PM3_EUNDEF;
@@ -223,10 +228,10 @@ static int CmdScriptRun(const char *Cmd) {
if (ext == PM3_CMD)
ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
-
+#ifdef DHAVE_PYTHON
if (ext == PM3_PY)
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
-
+#endif
free(script_path);
return ret;
}
From 6e3e1baef76bf60a1ff2b256386ba6eea341fb72 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 12:00:42 +0200
Subject: [PATCH 153/527] logsss
---
client/src/cmdscript.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 0264a16f6..f8fde1a40 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -13,7 +13,7 @@
#include
#include
-#ifdef DHAVE_PYTHON
+#ifdef HAVE_PYTHON
//#define PY_SSIZE_T_CLEAN
#include
#include
@@ -79,11 +79,15 @@ static int CmdScriptRun(const char *Cmd) {
extension_chk = str_dup(preferredName);
str_lower(extension_chk);
pm3_scriptfile_t ext = PM3_LUA;
- if (str_endswith(preferredName, ".cmd"))
+
+ if (str_endswith(extension_chk, ".cmd")) {
ext = PM3_CMD;
-#ifdef DHAVE_PYTHON
- if (str_endswith(preferredName, ".py"))
+ }
+
+#ifdef HAVE_PYTHON
+ if (str_endswith(extension_chk, ".py")) {
ext = PM3_PY;
+ }
#endif
char *script_path = NULL;
@@ -180,9 +184,15 @@ static int CmdScriptRun(const char *Cmd) {
*/
-#ifdef DHAVE_PYTHON
+#ifdef HAVE_PYTHON
+
+ PrintAndLogEx(SUCCESS, "script engine detected: %s", ( ext == PM3_PY) ? "PYTHON" : ( ext == PM3_CMD) ? "CMD" : "LUA");
+ PrintAndLogEx(SUCCESS, "script engine, folder %s", PYTHON_SCRIPTS_SUBDIR);
+
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
+ PrintAndLogEx(SUCCESS, "ICE");
+
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
@@ -200,7 +210,7 @@ static int CmdScriptRun(const char *Cmd) {
FILE *f = fopen(script_path, "r");
if (f == NULL) {
- PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), script_path);
+ PrintAndLogEx(ERR, "Could open file " _YELLOW_("%s"), script_path);
free(script_path);
return PM3_ESOFT;
}
@@ -228,7 +238,7 @@ static int CmdScriptRun(const char *Cmd) {
if (ext == PM3_CMD)
ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
-#ifdef DHAVE_PYTHON
+#ifdef HAVE_PYTHON
if (ext == PM3_PY)
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
#endif
From 6b8f1b141e9531334123001a3227ecaf62e20341 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 12:07:01 +0200
Subject: [PATCH 154/527] change, search in python dir..
---
client/src/fileutils.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/client/src/fileutils.c b/client/src/fileutils.c
index a650e3929..d5315e3b9 100644
--- a/client/src/fileutils.c
+++ b/client/src/fileutils.c
@@ -1446,6 +1446,7 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
(strcmp(LUA_LIBRARIES_SUBDIR, pm3dir) == 0) ||
(strcmp(LUA_SCRIPTS_SUBDIR, pm3dir) == 0) ||
(strcmp(CMD_SCRIPTS_SUBDIR, pm3dir) == 0) ||
+ (strcmp(PYTHON_SCRIPTS_SUBDIR, pm3dir) == 0) ||
(strcmp(RESOURCES_SUBDIR, pm3dir) == 0))) {
char *path = calloc(strlen(exec_path) + strlen(pm3dir) + strlen(filename) + 1, sizeof(char));
if (path == NULL)
From e106a5717c7c464751aa28d1c2160b61992d5f41 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 12:17:41 +0200
Subject: [PATCH 155/527] simple script working
---
client/pyscripts/ice.py | 5 +++++
client/src/cmdscript.c | 5 -----
2 files changed, 5 insertions(+), 5 deletions(-)
create mode 100644 client/pyscripts/ice.py
diff --git a/client/pyscripts/ice.py b/client/pyscripts/ice.py
new file mode 100644
index 000000000..a9d486813
--- /dev/null
+++ b/client/pyscripts/ice.py
@@ -0,0 +1,5 @@
+
+lrc= 0x00
+for i in range(5):
+ lrc ^= 42
+print('\n final LRC XOR byte value: %02X\n' % (lrc))
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index f8fde1a40..b5929c0ae 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -185,13 +185,8 @@ static int CmdScriptRun(const char *Cmd) {
*/
#ifdef HAVE_PYTHON
-
- PrintAndLogEx(SUCCESS, "script engine detected: %s", ( ext == PM3_PY) ? "PYTHON" : ( ext == PM3_CMD) ? "CMD" : "LUA");
- PrintAndLogEx(SUCCESS, "script engine, folder %s", PYTHON_SCRIPTS_SUBDIR);
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
-
- PrintAndLogEx(SUCCESS, "ICE");
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
From 366ac6a41f8a49b5de09a3555ca0030df200547b Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 12:35:26 +0200
Subject: [PATCH 156/527] creating argc/argv
---
client/src/cmdscript.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index b5929c0ae..52b24562a 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -191,9 +191,9 @@ static int CmdScriptRun(const char *Cmd) {
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
- wchar_t *program = Py_DecodeLocale(script_path, NULL);
+ wchar_t *program = Py_DecodeLocale(preferredName, NULL);
if (program == NULL) {
- PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), script_path);
+ PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), preferredName);
free(script_path);
return PM3_ESOFT;
}
@@ -201,7 +201,20 @@ static int CmdScriptRun(const char *Cmd) {
// optional but recommended
Py_SetProgramName(program);
Py_Initialize();
-// PySys_SetArgv(arguments, script_path); // we dont have argc , argv here
+
+
+ int argc = 6;
+ wchar_t *args[argc];
+ args[0] = Py_DecodeLocale(preferredName, NULL);
+ args[1] = Py_DecodeLocale("04", NULL);
+ args[2] = Py_DecodeLocale("00", NULL);
+ args[3] = Py_DecodeLocale("80", NULL);
+ args[4] = Py_DecodeLocale("64", NULL);
+ args[5] = Py_DecodeLocale("ba", NULL);
+
+ PySys_SetArgv(argc, args);
+
+ //PySys_SetArgv(arguments, script_path);
FILE *f = fopen(script_path, "r");
if (f == NULL) {
@@ -210,7 +223,7 @@ static int CmdScriptRun(const char *Cmd) {
return PM3_ESOFT;
}
- PyRun_SimpleFile(f, script_path);
+ PyRun_SimpleFile(f, preferredName);
fclose(f);
From 4aa40061671fbfaa8564a3fe8aebc1d813e2ffd9 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 13:09:18 +0200
Subject: [PATCH 157/527] chg, python should close the script file
---
client/src/cmdscript.c | 61 +++++++++++++++++++++++++++++++-----------
1 file changed, 46 insertions(+), 15 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 52b24562a..6fef662f3 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -36,11 +36,39 @@
typedef enum {
PM3_LUA,
PM3_CMD,
+#ifdef HAVE_PYTHON
PM3_PY
+#endif
} pm3_scriptfile_t;
static int CmdHelp(const char *Cmd);
+#ifdef HAVE_PYTHON
+static int split(char *str, char **arr) {
+ int begin_index = 0;
+ int word_cnt = 0;
+
+ while (1) {
+ while (isspace(str[begin_index])) {
+ ++begin_index;
+ }
+ if (str[begin_index] == '\0') {
+ break;
+ }
+ int end_index = begin_index;
+ while (str[end_index] && !isspace(str[end_index])) {
+ ++end_index;
+ }
+ int len = end_index - begin_index;
+ char *tmp = calloc(len + 1, sizeof(char));
+ memcpy(tmp, &str[begin_index], len);
+ arr[word_cnt++] = tmp;
+ begin_index = end_index;
+ }
+ return word_cnt;
+}
+#endif
+
/**
* Generate a sorted list of available commands, what it does is
* generate a file listing of the script-directory for files
@@ -188,7 +216,7 @@ static int CmdScriptRun(const char *Cmd) {
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
- PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
+ PrintAndLogEx(SUCCESS, "executing python " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
wchar_t *program = Py_DecodeLocale(preferredName, NULL);
@@ -202,19 +230,22 @@ static int CmdScriptRun(const char *Cmd) {
Py_SetProgramName(program);
Py_Initialize();
+ //int argc, char ** argv
+ char *argv[128];
+ int argc = split(arguments, argv);
+
+ wchar_t *py_args[argc];
+ py_args[0] = Py_DecodeLocale(preferredName, NULL);
+ for (int i = 0; i < argc; i++) {
+ py_args[i+1] = Py_DecodeLocale(argv[i], NULL);
+ }
- int argc = 6;
- wchar_t *args[argc];
- args[0] = Py_DecodeLocale(preferredName, NULL);
- args[1] = Py_DecodeLocale("04", NULL);
- args[2] = Py_DecodeLocale("00", NULL);
- args[3] = Py_DecodeLocale("80", NULL);
- args[4] = Py_DecodeLocale("64", NULL);
- args[5] = Py_DecodeLocale("ba", NULL);
-
- PySys_SetArgv(argc, args);
+ PySys_SetArgv(argc, py_args);
- //PySys_SetArgv(arguments, script_path);
+ // clean up
+ for (int i = 0; i < argc; ++i) {
+ free(argv[i]);
+ }
FILE *f = fopen(script_path, "r");
if (f == NULL) {
@@ -223,9 +254,9 @@ static int CmdScriptRun(const char *Cmd) {
return PM3_ESOFT;
}
- PyRun_SimpleFile(f, preferredName);
-
- fclose(f);
+ // to we need to manually call all importmodules?
+ //PyImport_ImportModule("requests");
+ PyRun_SimpleFileExFlags(f, preferredName, 1, NULL);
if (Py_FinalizeEx() < 0) {
free(script_path);
From 5fcb031a681403d0a1d23b7f089a1e45cfc298c3 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 13:10:33 +0200
Subject: [PATCH 158/527] chg, python scripts can not have "exit" calls...
---
client/pyscripts/xorcheck.py | 51 ++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100755 client/pyscripts/xorcheck.py
diff --git a/client/pyscripts/xorcheck.py b/client/pyscripts/xorcheck.py
new file mode 100755
index 000000000..f4605a5e7
--- /dev/null
+++ b/client/pyscripts/xorcheck.py
@@ -0,0 +1,51 @@
+# xorcheck.py - find xor values for 8-bit LRC
+#
+# Adam Laurie
+# http://rfidiot.org/
+#
+# This code is copyright (c) Adam Laurie, 2009, All rights reserved.
+# For non-commercial use only, the following terms apply - for all other
+# uses, please contact the author:
+#
+# This code is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This code is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 2020, Modified (@iceman1001)
+
+import sys
+
+def main():
+ if(len(sys.argv) < 3):
+ print("""
+ \t{0} - Generate final byte for XOR LRC
+
+ Usage: {0} ...
+
+ \tSpecifying the bytes of a UID with a known LRC will find the last byte value
+ \tneeded to generate that LRC with a rolling XOR. All bytes should be specified in HEX.
+
+ Example:
+
+ \t{0} 04 00 80 64 ba
+
+ Should produce the output:
+
+ \tTarget (BA) requires final LRC XOR byte value: 5A\n""".format(sys.argv[0]))
+ return 0
+
+ target= int(sys.argv[len(sys.argv) - 1],16)
+
+ lrc= 0x00
+ for i in range(len(sys.argv) - 1):
+ lrc ^= int(sys.argv[i + 1],16)
+ print('\nTarget (%02X) requires final LRC XOR byte value: %02X\n' % (target,lrc))
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
From 3f02fa6e34844ef7c0e170b863e2e3a7c1e5fc46 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 13:37:28 +0200
Subject: [PATCH 159/527] chg, right number of args..
---
client/src/cmdscript.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 6fef662f3..4bbe3b631 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -233,14 +233,14 @@ static int CmdScriptRun(const char *Cmd) {
//int argc, char ** argv
char *argv[128];
int argc = split(arguments, argv);
-
+
wchar_t *py_args[argc];
py_args[0] = Py_DecodeLocale(preferredName, NULL);
for (int i = 0; i < argc; i++) {
py_args[i+1] = Py_DecodeLocale(argv[i], NULL);
}
- PySys_SetArgv(argc, py_args);
+ PySys_SetArgv(argc+1, py_args);
// clean up
for (int i = 0; i < argc; ++i) {
From f7537519ff10909349fd1ea47372e69dd44f7966 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 14:41:58 +0200
Subject: [PATCH 160/527] chg, make python aware of pm3 search paths
---
client/pyscripts/ice.py | 7 +++--
client/src/cmdscript.c | 58 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/client/pyscripts/ice.py b/client/pyscripts/ice.py
index a9d486813..9a223a059 100644
--- a/client/pyscripts/ice.py
+++ b/client/pyscripts/ice.py
@@ -1,5 +1,4 @@
+import os
+import sys
-lrc= 0x00
-for i in range(5):
- lrc ^= 42
-print('\n final LRC XOR byte value: %02X\n' % (lrc))
+print("SP %s" % sys.path)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 4bbe3b631..cad94cafe 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -44,6 +44,9 @@ typedef enum {
static int CmdHelp(const char *Cmd);
#ifdef HAVE_PYTHON
+
+#define PYTHON_LIBRARIES_WILDCARD "?.py"
+
static int split(char *str, char **arr) {
int begin_index = 0;
int word_cnt = 0;
@@ -67,6 +70,58 @@ static int split(char *str, char **arr) {
}
return word_cnt;
}
+
+static void set_python_path(char *path) {
+ PyObject *syspath = PySys_GetObject("path");
+ if (syspath == 0) {
+ PrintAndLogEx(WARNING, "Python failed to getobject");
+ }
+
+ PyObject *pName = PyUnicode_FromString(path);
+ if (PyList_Insert(syspath, 0, pName)) {
+ PrintAndLogEx(WARNING, "Error inserting extra path into sys.path list");
+ }
+
+ if (PySys_SetObject("path", syspath)) {
+ PrintAndLogEx(WARNING,"Error setting sys.path object");
+ }
+}
+
+static void set_python_paths(void) {
+ //--add to the LUA_PATH (package.path in lua)
+ // so we can load scripts from various places:
+ const char *exec_path = get_my_executable_directory();
+ if (exec_path != NULL) {
+ // from the ./luascripts/ directory
+ char scripts_path[strlen(exec_path) + strlen(PYTHON_SCRIPTS_SUBDIR) + strlen(PYTHON_LIBRARIES_WILDCARD) + 1];
+ strcpy(scripts_path, exec_path);
+ strcat(scripts_path, PYTHON_SCRIPTS_SUBDIR);
+// strcat(scripts_path, PYTHON_LIBRARIES_WILDCARD);
+ set_python_path(scripts_path);
+ }
+
+ const char *user_path = get_my_user_directory();
+ if (user_path != NULL) {
+ // from the $HOME/.proxmark3/luascripts/ directory
+ char scripts_path[strlen(user_path) + strlen(PM3_USER_DIRECTORY) + strlen(PYTHON_SCRIPTS_SUBDIR) + strlen(PYTHON_LIBRARIES_WILDCARD) + 1];
+ strcpy(scripts_path, user_path);
+ strcat(scripts_path, PM3_USER_DIRECTORY);
+ strcat(scripts_path, PYTHON_SCRIPTS_SUBDIR);
+// strcat(scripts_path, PYTHON_LIBRARIES_WILDCARD);
+ set_python_path(scripts_path);
+
+ }
+
+ if (exec_path != NULL) {
+ // from the $PREFIX/share/proxmark3/luascripts/ directory
+ char scripts_path[strlen(exec_path) + strlen(PM3_SHARE_RELPATH) + strlen(PYTHON_SCRIPTS_SUBDIR) + strlen(PYTHON_LIBRARIES_WILDCARD) + 1];
+ strcpy(scripts_path, exec_path);
+ strcat(scripts_path, PM3_SHARE_RELPATH);
+ strcat(scripts_path, PYTHON_SCRIPTS_SUBDIR);
+// strcat(scripts_path, PYTHON_LIBRARIES_WILDCARD);
+ set_python_path(scripts_path);
+ }
+}
#endif
/**
@@ -247,6 +302,9 @@ static int CmdScriptRun(const char *Cmd) {
free(argv[i]);
}
+ // setup search paths.
+ set_python_paths();
+
FILE *f = fopen(script_path, "r");
if (f == NULL) {
PrintAndLogEx(ERR, "Could open file " _YELLOW_("%s"), script_path);
From 698a56a91978c02cd0665eed2af6fc81bcf1be35 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 14:43:40 +0200
Subject: [PATCH 161/527] moved and modified some existing pyton scripts for
testing
---
client/pyscripts/findbits.py | 99 ++++++++++++++++++++++++++++
client/pyscripts/parity.py | 78 ++++++++++++++++++++++
client/pyscripts/pm3_eml2mfd.py | 26 ++++++++
client/pyscripts/pm3_eml_mfd_test.py | 51 ++++++++++++++
client/pyscripts/pm3_mfd2eml.py | 28 ++++++++
5 files changed, 282 insertions(+)
create mode 100755 client/pyscripts/findbits.py
create mode 100644 client/pyscripts/parity.py
create mode 100755 client/pyscripts/pm3_eml2mfd.py
create mode 100755 client/pyscripts/pm3_eml_mfd_test.py
create mode 100755 client/pyscripts/pm3_mfd2eml.py
diff --git a/client/pyscripts/findbits.py b/client/pyscripts/findbits.py
new file mode 100755
index 000000000..809465a2e
--- /dev/null
+++ b/client/pyscripts/findbits.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python3
+
+# findbits.py - find Binary, Octal, Decimal or Hex number in bitstream
+#
+# Adam Laurie
+# http://rfidiot.org/
+#
+# This code is copyright (c) Adam Laurie, 2009, All rights reserved.
+# For non-commercial use only, the following terms apply - for all other
+# uses, please contact the author:
+#
+# This code is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This code is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+import sys
+import os
+
+# invert binary string
+def invert(data):
+ return ''.join('0' if c == '1' else '1' for c in data)
+
+# do the actual search
+def search(target,data):
+ location = data.find(target)
+ if location >= 0:
+ print('*** Match at bit {:d}: {}<{}>{}'.format(location, data[:location],target,data[location+len(target):]))
+ else:
+ print('Not found')
+
+# convert integer to binary string
+def binstring(number):
+ return bin(number)[2:] if number > 0 else ''
+
+# reverse string order
+def stringreverse(data):
+ return data[::-1]
+
+# match forward, backward and inverted
+def domatch(binary,number):
+ reversed= stringreverse(number)
+ inverted= invert(binary)
+
+ print(' Forward: (%s) ' % number, end = '')
+ search(binary,number)
+ print(' Reverse: (%s) ' % reversed, end = '')
+ search(binary,reversed)
+ print(' Inverse: (%s) ' % inverted)
+ print(' Forward: (%s) ' % number, end = '')
+ search(inverted,number)
+ print(' Reverse: (%s) ' % reversed, end = '')
+ search(inverted,reversed)
+
+def main():
+ if(len(sys.argv) < 3):
+ print("""
+\t{0} - Search bitstream for a known number
+
+Usage: {0}
+
+\tNUMBER will be converted to it\'s BINARY equivalent for all valid
+\tinstances of BINARY, OCTAL, DECIMAL and HEX, and the bitstream
+\tand it\'s inverse will be searched for a pattern match. Note that
+\tNUMBER must be specified in BINARY to match leading zeros.
+
+Example:
+
+\t{0} 73 0110010101110011
+""".format(sys.argv[0]))
+ os._exit(True)
+
+ bases= {
+ 2:'BINARY',
+ 8:'OCTAL',
+ 10:'DECIMAL',
+ 16:'HEX',
+ }
+
+ for base, base_name in sorted(bases.items()):
+ try:
+ number= int(sys.argv[1],base)
+ print('\nTrying ' + base_name)
+ # do BINARY as specified to preserve leading zeros
+ if base == 2:
+ domatch(sys.argv[1],sys.argv[2])
+ else:
+ domatch(binstring(number),sys.argv[2])
+ except:
+ continue
+
+if __name__ == '__main__':
+ main()
diff --git a/client/pyscripts/parity.py b/client/pyscripts/parity.py
new file mode 100644
index 000000000..6be9d979d
--- /dev/null
+++ b/client/pyscripts/parity.py
@@ -0,0 +1,78 @@
+# This code is contributed by
+# Shubham Singh(SHUBHAMSINGH10)
+# 2020, modified (@iceman1001)
+
+import sys
+
+# Python3 program to illustrate Compute the
+# parity of a number using XOR
+# Generating the look-up table while pre-processing
+def P2(n, table):
+ table.extend([n, n ^ 1, n ^ 1, n])
+def P4(n, table):
+ return (P2(n, table), P2(n ^ 1, table),
+ P2(n ^ 1, table), P2(n, table))
+def P6(n, table):
+ return (P4(n, table), P4(n ^ 1, table),
+ P4(n ^ 1, table), P4(n, table))
+def LOOK_UP(table):
+ return (P6(0, table), P6(1, table),
+ P6(1, table), P6(0, table))
+
+# LOOK_UP is the macro expansion to generate the table
+table = [0] * 256
+LOOK_UP(table)
+
+# Function to find the parity
+def Parity(num) :
+ # Number is considered to be of 32 bits
+ max = 16
+
+ # Dividing the number o 8-bit
+ # chunks while performing X-OR
+ while (max >= 8):
+ num = num ^ (num >> max)
+ max = max // 2
+
+ # Masking the number with 0xff (11111111)
+ # to produce valid 8-bit result
+ return table[num & 0xff]
+
+def main():
+ if(len(sys.argv) < 2):
+ print("""
+ \t{0} - Calculate parity of a given number
+
+ Usage: {0} <2,10,16>
+
+ \t Specify type as in 2 Bin, 10 Decimal, 16 Hex, and number in that particular format
+ \t number can only be 32bit long.
+
+ Example:
+
+ \t{0} 10 1234
+
+ Should produce the output:
+
+ \tOdd parity\n""".format(sys.argv[0]))
+ return 0
+
+
+ numtype= int(sys.argv[1], 10)
+ print("numtype: {0}".format(numtype))
+ input= int(sys.argv[2], numtype)
+ print("num: {0} 0x{0:X}".format(input))
+
+ #num = "001111100010100011101010111101011110"
+ # Result is 1 for odd parity
+ # 0 for even parity
+# result = Parity( int(input, numtype) )
+ result = Parity(input)
+ print("Odd parity") if result else print("Even parity")
+
+
+if __name__ == "__main__":
+ main()
+
+
+
diff --git a/client/pyscripts/pm3_eml2mfd.py b/client/pyscripts/pm3_eml2mfd.py
new file mode 100755
index 000000000..90803cf5e
--- /dev/null
+++ b/client/pyscripts/pm3_eml2mfd.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+'''
+# Andrei Costin , 2011
+# pm3_eml2mfd.py
+# Converts PM3 Mifare Classic emulator EML text file to MFD binary dump file
+'''
+
+import sys
+import binascii
+
+def main(argv):
+ argc = len(argv)
+ if argc < 3:
+ print('Usage:', argv[0], 'input.eml output.mfd')
+ return 1
+
+ with open(argv[1], "r") as file_inp, open(argv[2], "wb") as file_out:
+ for line in file_inp:
+ line = line.rstrip('\n').rstrip('\r')
+ print(line)
+ data = binascii.unhexlify(line)
+ file_out.write(data)
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/client/pyscripts/pm3_eml_mfd_test.py b/client/pyscripts/pm3_eml_mfd_test.py
new file mode 100755
index 000000000..8fae5965e
--- /dev/null
+++ b/client/pyscripts/pm3_eml_mfd_test.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+
+from tempfile import mkdtemp
+from shutil import rmtree
+from string import hexdigits
+import unittest, os
+import pm3_eml2mfd, pm3_mfd2eml
+
+class TestEmlMfd(unittest.TestCase):
+ def setUp(self):
+ self.tmpdir = mkdtemp()
+
+ def tearDown(self):
+ rmtree(self.tmpdir)
+
+ EML2MFD_TESTCASES = [
+ ('', ''),
+ ("41424344\r\n45464748\n494A4B4C\n", "ABCDEFGHIJKL")
+ ]
+ def test_eml2mfd(self):
+ self.three_argument_test(pm3_eml2mfd.main, self.EML2MFD_TESTCASES)
+
+ def test_mfd2eml(self):
+ self.three_argument_test(pm3_mfd2eml.main,
+ map(reversed, self.EML2MFD_TESTCASES), c14n=hex_c14n)
+
+ def three_argument_test(self, operation, cases, c14n=str):
+ for case_input, case_output in cases:
+ try:
+ inp_name = os.path.join(self.tmpdir, 'input')
+ out_name = os.path.join(self.tmpdir, 'output')
+ with open(inp_name, 'w') as in_file:
+ in_file.write(case_input)
+ operation(['', inp_name, out_name])
+ with open(out_name, 'r') as out_file:
+ self.assertEqual(c14n(case_output), c14n(out_file.read()))
+ finally:
+ for file_name in inp_name, out_name:
+ if os.path.exists(file_name):
+ os.remove(file_name)
+
+
+def hex_c14n(inp):
+ """
+ Canonicalizes the input string by removing non-hexadecimal
+ characters and making everything uppercase
+ """
+ return ''.join(c.upper() for c in inp if c in hexdigits)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/client/pyscripts/pm3_mfd2eml.py b/client/pyscripts/pm3_mfd2eml.py
new file mode 100755
index 000000000..ae7a79825
--- /dev/null
+++ b/client/pyscripts/pm3_mfd2eml.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+'''
+# Andrei Costin , 2011
+# pm3_eml2mfd.py
+# Converts PM3 Mifare Classic MFD binary dump file to emulator EML text file
+'''
+import sys
+
+READ_BLOCKSIZE = 16
+
+def main(argv):
+ argc = len(argv)
+ if argc < 3:
+ print('Usage:', argv[0], 'input.mfd output.eml')
+ return 1
+
+ with open(argv[1], "rb") as file_inp, open(argv[2], "w") as file_out:
+ while True:
+ byte_s = file_inp.read(READ_BLOCKSIZE)
+ if not byte_s:
+ break
+ hex_char_repr = byte_s.hex()
+ file_out.write(hex_char_repr)
+ file_out.write("\n")
+
+if __name__ == '__main__':
+ main(sys.argv)
From 748c0772680725f4e6073cd6d6d522dc142dd823 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 15:49:28 +0200
Subject: [PATCH 162/527] chg, python3 in cmake?
---
client/CMakeLists.txt | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 64cfca623..3938f76d5 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -38,6 +38,8 @@ endforeach()
find_package(PkgConfig)
pkg_search_module(BLUEZ QUIET bluez)
+pkg_search_module(PYTHON3 QUIET python3)
+
SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
add_subdirectory(deps)
@@ -224,6 +226,14 @@ if (BLUEZ_FOUND)
set(ADDITIONAL_LNK bluetooth ${ADDITIONAL_LNK})
endif (BLUEZ_FOUND)
+if (PYTHON3_FOUND)
+ message("Python3 library found, building with python3 support :)")
+ add_definitions("-DHAVE_PYTHON")
+# include_directories ( ${PYTHON_INCLUDE_DIRS} )
+ set(ADDITIONAL_LNK python3 ${PYTHON_LIBRARIES})
+endif (PYTHON3_FOUND)
+
+
add_executable(
proxmark3
${TARGET_SOURCES}
@@ -286,7 +296,7 @@ target_link_libraries(proxmark3 PRIVATE
${ADDITIONAL_LNK})
install(TARGETS proxmark3 DESTINATION "bin")
-install(DIRECTORY cmdscripts lualibs luascripts resources dictionaries DESTINATION "share/proxmark3")
+install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
add_custom_command(OUTPUT lualibs/pm3_cmd.lua
COMMAND "awk -f pm3_cmd_h2lua.awk ../include/pm3_cmd.h > lualibs/pm3_cmd.lua"
From e7230fa5d7a3a17b3e26a4add3bc1dd98a09413c Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 16:47:54 +0200
Subject: [PATCH 163/527] chg, cmake woodo. almost there
---
client/CMakeLists.txt | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 3938f76d5..20cb1cbbe 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -37,7 +37,6 @@ endforeach()
find_package(PkgConfig)
pkg_search_module(BLUEZ QUIET bluez)
-
pkg_search_module(PYTHON3 QUIET python3)
SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -190,7 +189,6 @@ add_custom_command(
set(ADDITIONAL_SRC "")
set(ADDITIONAL_LNK "")
-
set(X86_CPUS x86 x86_64 i686)
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
@@ -229,10 +227,19 @@ endif (BLUEZ_FOUND)
if (PYTHON3_FOUND)
message("Python3 library found, building with python3 support :)")
add_definitions("-DHAVE_PYTHON")
-# include_directories ( ${PYTHON_INCLUDE_DIRS} )
- set(ADDITIONAL_LNK python3 ${PYTHON_LIBRARIES})
-endif (PYTHON3_FOUND)
+ #PYTHON3_LIBRARIES ... only the libraries (w/o the '-l')
+ #PYTHON3_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
+ #PYTHON3_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
+
+ message(STATUS "PYTHON3 LIBS := ${PYTHON3_LIBRARIES}")
+ message(STATUS "PYTHON3 INC DIRS := ${PYTHON3_INCLUDE_DIRS}")
+
+ set(ADDITIONAL_LNK ${ADDITIONAL_LNK} ${PYTHON3_LIBRARIES})
+
+#PYTHONINCLUDES = pkg-config --cflags python3 == -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
+#PYTHONLDLIBS = pkg-config --libs python3 == -lpython3.6m
+endif (PYTHON3_FOUND)
add_executable(
proxmark3
From feafa62dede43839704cc4f70e7698f4ebeb2a9b Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 16:57:54 +0200
Subject: [PATCH 164/527] chg, cmake compiles
---
client/CMakeLists.txt | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 20cb1cbbe..285a20144 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -189,6 +189,7 @@ add_custom_command(
set(ADDITIONAL_SRC "")
set(ADDITIONAL_LNK "")
+set(ADDITIONAL_DIRS "")
set(X86_CPUS x86 x86_64 i686)
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
@@ -227,18 +228,8 @@ endif (BLUEZ_FOUND)
if (PYTHON3_FOUND)
message("Python3 library found, building with python3 support :)")
add_definitions("-DHAVE_PYTHON")
-
- #PYTHON3_LIBRARIES ... only the libraries (w/o the '-l')
- #PYTHON3_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
- #PYTHON3_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
-
- message(STATUS "PYTHON3 LIBS := ${PYTHON3_LIBRARIES}")
- message(STATUS "PYTHON3 INC DIRS := ${PYTHON3_INCLUDE_DIRS}")
-
+ set(ADDITIONAL_DIRS ${ADDITIONAL_DIRS} ${PYTHON3_INCLUDE_DIRS})
set(ADDITIONAL_LNK ${ADDITIONAL_LNK} ${PYTHON3_LIBRARIES})
-
-#PYTHONINCLUDES = pkg-config --cflags python3 == -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
-#PYTHONLDLIBS = pkg-config --libs python3 == -lpython3.6m
endif (PYTHON3_FOUND)
add_executable(
@@ -265,6 +256,7 @@ target_include_directories(proxmark3 PRIVATE
../common_fpga
../include
src
+ ${ADDITIONAL_DIRS}
)
if (APPLE)
From 9edb30f1665a97861ad6b49a5ef280dd78c75c76 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 17:01:53 +0200
Subject: [PATCH 165/527] chg, python3-embed checks (@doegox)
---
client/Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/client/Makefile b/client/Makefile
index 9ee678a4b..70f45ca81 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -136,13 +136,20 @@ LDLIBS += $(LUALIB)
INCLUDES += $(LUALIBINC)
## Python3
-#PYTHON_CONFIG := python3-config
PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
ifneq ($(PYTHONLDLIBS),)
PYTHONLIB = $(PYTHONLDLIBS)
PYTHONLIBINC = $(PYTHONINCLUDES)
PYTHON_FOUND = 1
+else
+ PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3-embed 2>/dev/null)
+ PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3-embed 2>/dev/null)
+ ifneq ($(PYTHONLDLIBS),)
+ PYTHONLIB = $(PYTHONLDLIBS)
+ PYTHONLIBINC = $(PYTHONINCLUDES)
+ PYTHON_FOUND = 1
+ endif
endif
LDLIBS += $(PYTHONLIB)
INCLUDES += $(PYTHONLIBINC)
From 6feb408071ba34c50d69cfb91dd812e63c26b3d6 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 17:15:42 +0200
Subject: [PATCH 166/527] travis needs dev...
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index ad23bf6f8..7f3d79a46 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,7 @@ addons:
- gcc-arm-none-eabi
- libnewlib-dev
- libbluetooth-dev
+ - python3-dev
homebrew:
packages:
- readline
From 646a4cc4a6a4f1ec214047bd37663825b15823b3 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 17:32:16 +0200
Subject: [PATCH 167/527] more version info
---
client/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index 70f45ca81..28ac1f87c 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -373,9 +373,9 @@ else
endif
ifeq ($(PYTHON_FOUND),1)
- $(info Python library: system library found)
+ $(info Python3 version: Python3 v${shell pkg-config --modversion python3} found, enabled)
else
- $(info Python library: system library not found, disabled)
+ $(info Python library: Python3 not found, disabled)
endif
ifeq ($(SKIPWHEREAMISYSTEM),1)
From 176f0dfe757525e1560fe44d55863b037c198b72 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 17:35:27 +0200
Subject: [PATCH 168/527] chg, function available in v3.6 Travis has v3.5...
---
client/src/cmdscript.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index cad94cafe..07764db88 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -316,10 +316,7 @@ static int CmdScriptRun(const char *Cmd) {
//PyImport_ImportModule("requests");
PyRun_SimpleFileExFlags(f, preferredName, 1, NULL);
- if (Py_FinalizeEx() < 0) {
- free(script_path);
- return PM3_ESOFT;
- }
+ Py_Finalize();
PyMem_RawFree(program);
free(script_path);
From 0464fd476ba9476288915d3cf41988bb07e26520 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 26 May 2020 17:37:03 +0200
Subject: [PATCH 169/527] Makefile python
---
client/Makefile | 60 +++++++++++++++----------------
doc/md/Development/Maintainers.md | 1 +
2 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index 28ac1f87c..bbaee39b0 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -135,25 +135,6 @@ endif
LDLIBS += $(LUALIB)
INCLUDES += $(LUALIBINC)
-## Python3
-PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
-PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
-ifneq ($(PYTHONLDLIBS),)
- PYTHONLIB = $(PYTHONLDLIBS)
- PYTHONLIBINC = $(PYTHONINCLUDES)
- PYTHON_FOUND = 1
-else
- PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3-embed 2>/dev/null)
- PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3-embed 2>/dev/null)
- ifneq ($(PYTHONLDLIBS),)
- PYTHONLIB = $(PYTHONLDLIBS)
- PYTHONLIBINC = $(PYTHONINCLUDES)
- PYTHON_FOUND = 1
- endif
-endif
-LDLIBS += $(PYTHONLIB)
-INCLUDES += $(PYTHONLIBINC)
-
## mbed TLS
# system library cannot be used because it is compiled by default without CMAC support
LDLIBS +=$(MBEDTLSLIB)
@@ -219,13 +200,6 @@ endif
LDLIBS += $(BTLIB)
INCLUDES += $(BTLIBINC)
-## Readline
-ifeq ($(platform),Darwin)
- LDLIBS += -L/usr/local/opt/readline/lib
- INCLUDES += -I/usr/local/opt/readline/include
-endif
-LDLIBS += -lreadline
-
## Math
LDLIBS += -lm
@@ -235,6 +209,28 @@ ifneq ($(SKIPPTHREAD),1)
LDLIBS += -lpthread
endif
+## Python3 (optional)
+ifneq ($(SKIPPYTHON),1)
+ PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
+ PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
+ ifneq ($(PYTHONLDLIBS),)
+ PYTHONLIB = $(PYTHONLDLIBS)
+ PYTHONLIBINC = $(PYTHONINCLUDES)
+ PYTHON_FOUND = 1
+ else
+ # since python3.8, applications willing to embed python must use -embed:
+ PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3-embed 2>/dev/null)
+ PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3-embed 2>/dev/null)
+ ifneq ($(PYTHONLDLIBS),)
+ PYTHONLIB = $(PYTHONLDLIBS)
+ PYTHONLIBINC = $(PYTHONINCLUDES)
+ PYTHON_FOUND = 1
+ endif
+ endif
+endif
+LDLIBS += $(PYTHONLIB)
+INCLUDES += $(PYTHONLIBINC)
+
## QT5 (or QT4 fallback) (optional)
ifneq ($(SKIPQT),1)
# Check for correctly configured Qt5
@@ -275,8 +271,12 @@ endif
LDLIBS += $(QTLDLIBS)
CXXINCLUDES += $(QTINCLUDES)
-## Python
-
+## Readline
+ifeq ($(platform),Darwin)
+ LDLIBS += -L/usr/local/opt/readline/lib
+ INCLUDES += -I/usr/local/opt/readline/include
+endif
+LDLIBS += -lreadline
#######################################################################################################
CFLAGS ?= $(DEFCFLAGS)
@@ -373,9 +373,9 @@ else
endif
ifeq ($(PYTHON_FOUND),1)
- $(info Python3 version: Python3 v${shell pkg-config --modversion python3} found, enabled)
+ $(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
else
- $(info Python library: Python3 not found, disabled)
+ $(info Python3 library: Python3 not found, disabled)
endif
ifeq ($(SKIPWHEREAMISYSTEM),1)
diff --git a/doc/md/Development/Maintainers.md b/doc/md/Development/Maintainers.md
index 0ea33b924..293fd3999 100644
--- a/doc/md/Development/Maintainers.md
+++ b/doc/md/Development/Maintainers.md
@@ -61,6 +61,7 @@ It's also possible to skip parts even if libraries are present in the compilatio
* `make client SKIPQT=1` to skip GUI even if Qt is present
* `make client SKIPBT=1` to skip native Bluetooth support even if libbluetooth is present
+* `make client SKIPPYTHON=1` to skip embedded Python 3 interpreter even if libpython3 is present
* `make client SKIPLUASYSTEM=1` to skip system Lua lib even if liblua5.2 is present, use embedded Lua lib instead
* `make client SKIPJANSSONSYSTEM=1` to skip system Jansson lib even if libjansson is present, use embedded Jansson lib instead
* `make client SKIPWHEREAMISYSTEM=1` to skip system Whereami lib even if libwhereami is present, use embedded whereami lib instead
From 8498c32a785882fae25072ec65c4be6de9a1b7ab Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 26 May 2020 18:41:24 +0200
Subject: [PATCH 170/527] cmake support python < 3.8 and 3.8
---
client/CMakeLists.txt | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 285a20144..644008497 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -38,6 +38,7 @@ endforeach()
find_package(PkgConfig)
pkg_search_module(BLUEZ QUIET bluez)
pkg_search_module(PYTHON3 QUIET python3)
+pkg_search_module(PYTHON3EMBED QUIET python3-embed)
SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -225,12 +226,17 @@ if (BLUEZ_FOUND)
set(ADDITIONAL_LNK bluetooth ${ADDITIONAL_LNK})
endif (BLUEZ_FOUND)
-if (PYTHON3_FOUND)
+if (PYTHON3EMBED_FOUND)
message("Python3 library found, building with python3 support :)")
add_definitions("-DHAVE_PYTHON")
- set(ADDITIONAL_DIRS ${ADDITIONAL_DIRS} ${PYTHON3_INCLUDE_DIRS})
- set(ADDITIONAL_LNK ${ADDITIONAL_LNK} ${PYTHON3_LIBRARIES})
-endif (PYTHON3_FOUND)
+ set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
+ set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
+elseif (PYTHON3_FOUND)
+ message("Python3 library found, building with python3 support :)")
+ add_definitions("-DHAVE_PYTHON")
+ set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
+ set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
+endif (PYTHON3EMBED_FOUND)
add_executable(
proxmark3
From 25c5eebfcfbba7a22cc6da726c3705d2d15e5a82 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 26 May 2020 18:54:58 +0200
Subject: [PATCH 171/527] attempt to fix cmake+osx+python
---
client/CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 644008497..baf1dad44 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -231,11 +231,13 @@ if (PYTHON3EMBED_FOUND)
add_definitions("-DHAVE_PYTHON")
set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
+ set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
elseif (PYTHON3_FOUND)
message("Python3 library found, building with python3 support :)")
add_definitions("-DHAVE_PYTHON")
set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
+ set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
endif (PYTHON3EMBED_FOUND)
add_executable(
@@ -300,6 +302,8 @@ target_link_libraries(proxmark3 PRIVATE
pm3rrg_rdv4_whereami
${ADDITIONAL_LNK})
+target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
+
install(TARGETS proxmark3 DESTINATION "bin")
install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
From 1781837bf98fb10a0f31bd0a99be19f4d6220f17 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 21:57:26 +0200
Subject: [PATCH 172/527] chg, cmake for OSX, (Thanks @doegex!)
---
client/CMakeLists.txt | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index baf1dad44..505073d7e 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -191,6 +191,7 @@ add_custom_command(
set(ADDITIONAL_SRC "")
set(ADDITIONAL_LNK "")
set(ADDITIONAL_DIRS "")
+set(ADDITIONAL_LNKDIRS "")
set(X86_CPUS x86 x86_64 i686)
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
@@ -227,7 +228,7 @@ if (BLUEZ_FOUND)
endif (BLUEZ_FOUND)
if (PYTHON3EMBED_FOUND)
- message("Python3 library found, building with python3 support :)")
+ message("Python3-embed library found, building with python3 support :)")
add_definitions("-DHAVE_PYTHON")
set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
@@ -237,7 +238,7 @@ elseif (PYTHON3_FOUND)
add_definitions("-DHAVE_PYTHON")
set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
- set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
+ set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
endif (PYTHON3EMBED_FOUND)
add_executable(
@@ -302,8 +303,15 @@ target_link_libraries(proxmark3 PRIVATE
pm3rrg_rdv4_whereami
${ADDITIONAL_LNK})
-target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
-
+# OSX have a hard time compiling python3 dependency with older cmake.
+if (PYTHON3EMBED_FOUND AND PYTHON3_FOUND)
+ if (NOT CMAKE_VERSION VERSION_LESS 3.13)
+ target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
+ elseif (APPLE)
+ message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
+ endif()
+endif()
+
install(TARGETS proxmark3 DESTINATION "bin")
install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
From 125e05ec0e6522ba116e8265faa7499a3bf5483b Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Tue, 26 May 2020 21:58:50 +0200
Subject: [PATCH 173/527] chg, clean up
---
client/src/cmdscript.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 07764db88..6d95c40ea 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -157,22 +157,22 @@ static int CmdScriptRun(const char *Cmd) {
int arg_len = 0;
static uint8_t luascriptfile_idx = 0;
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
-
+
char *extension_chk;
extension_chk = str_dup(preferredName);
str_lower(extension_chk);
pm3_scriptfile_t ext = PM3_LUA;
-
+
if (str_endswith(extension_chk, ".cmd")) {
ext = PM3_CMD;
}
-
+
#ifdef HAVE_PYTHON
if (str_endswith(extension_chk, ".py")) {
ext = PM3_PY;
}
#endif
-
+
char *script_path = NULL;
if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
int error;
@@ -241,8 +241,8 @@ static int CmdScriptRun(const char *Cmd) {
free(script_path);
return ret;
}
-
- /*
+
+ /*
For apt (Ubuntu, Debian...):
sudo apt-get install python3-dev # for python3.x installs
@@ -264,13 +264,12 @@ static int CmdScriptRun(const char *Cmd) {
For apt-cyg (Cygwin...):
apt-cyg install python3-devel # for python3.x installs
-
*/
#ifdef HAVE_PYTHON
-
+
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
-
+
PrintAndLogEx(SUCCESS, "executing python " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
@@ -288,7 +287,6 @@ static int CmdScriptRun(const char *Cmd) {
//int argc, char ** argv
char *argv[128];
int argc = split(arguments, argv);
-
wchar_t *py_args[argc];
py_args[0] = Py_DecodeLocale(preferredName, NULL);
for (int i = 0; i < argc; i++) {
@@ -296,28 +294,24 @@ static int CmdScriptRun(const char *Cmd) {
}
PySys_SetArgv(argc+1, py_args);
-
+
// clean up
for (int i = 0; i < argc; ++i) {
free(argv[i]);
}
-
+
// setup search paths.
set_python_paths();
-
+
FILE *f = fopen(script_path, "r");
if (f == NULL) {
PrintAndLogEx(ERR, "Could open file " _YELLOW_("%s"), script_path);
free(script_path);
- return PM3_ESOFT;
+ return PM3_ESOFT;
}
- // to we need to manually call all importmodules?
- //PyImport_ImportModule("requests");
PyRun_SimpleFileExFlags(f, preferredName, 1, NULL);
-
Py_Finalize();
-
PyMem_RawFree(program);
free(script_path);
PrintAndLogEx(SUCCESS, "\nfinished " _YELLOW_("%s"), preferredName);
From 02c76f39e284d36f461173a660de8d48d78df5aa Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 26 May 2020 22:20:34 +0200
Subject: [PATCH 174/527] fix cmake for osx+python
---
client/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 505073d7e..c01c199d9 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -304,7 +304,7 @@ target_link_libraries(proxmark3 PRIVATE
${ADDITIONAL_LNK})
# OSX have a hard time compiling python3 dependency with older cmake.
-if (PYTHON3EMBED_FOUND AND PYTHON3_FOUND)
+if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
if (NOT CMAKE_VERSION VERSION_LESS 3.13)
target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
elseif (APPLE)
From 24bdecac8e44e202d2709c78401cc20e62357dea Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Tue, 26 May 2020 19:06:08 +0200
Subject: [PATCH 175/527] cmake: use less hardcoded items
---
client/CMakeLists.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index c01c199d9..28735b9b7 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -30,6 +30,7 @@ set(QT_PACKAGELIST
set(Qt5_FOUND ON)
foreach(_qt_package IN LISTS QT_PACKAGELIST)
find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
+ set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
if(NOT ${_qt_package}_FOUND)
set(Qt5_FOUND OFF)
endif(NOT ${_qt_package}_FOUND)
@@ -213,7 +214,7 @@ if (Qt5_FOUND)
${TARGET_SOURCES})
add_definitions("-DHAVE_GUI")
- set(ADDITIONAL_LNK Qt5::Core Qt5::Widgets Qt5::Gui ${ADDITIONAL_LNK})
+ set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
else (Qt5_FOUND)
message("Qt5 library not found, not building gui")
set(TARGET_SOURCES
@@ -224,7 +225,7 @@ endif (Qt5_FOUND)
if (BLUEZ_FOUND)
message("Bluez library found, building native Bluetooth support :)")
add_definitions("-DHAVE_BLUEZ")
- set(ADDITIONAL_LNK bluetooth ${ADDITIONAL_LNK})
+ set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
endif (BLUEZ_FOUND)
if (PYTHON3EMBED_FOUND)
From b4c715d8fb69f81a7d0abf4d9b0195321c351648 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 27 May 2020 00:40:01 +0200
Subject: [PATCH 176/527] script run: look for all three extensions if not
specified
---
client/src/cmdscript.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index 6d95c40ea..c9b485231 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -34,11 +34,12 @@
#include "fileutils.h"
typedef enum {
+ PM3_UNSPECIFIED,
PM3_LUA,
PM3_CMD,
#ifdef HAVE_PYTHON
PM3_PY
-#endif
+#endif
} pm3_scriptfile_t;
static int CmdHelp(const char *Cmd);
@@ -161,20 +162,20 @@ static int CmdScriptRun(const char *Cmd) {
char *extension_chk;
extension_chk = str_dup(preferredName);
str_lower(extension_chk);
- pm3_scriptfile_t ext = PM3_LUA;
-
- if (str_endswith(extension_chk, ".cmd")) {
+ pm3_scriptfile_t ext = PM3_UNSPECIFIED;
+ if (str_endswith(extension_chk, ".lua")) {
+ ext = PM3_LUA;
+ } else if (str_endswith(extension_chk, ".cmd")) {
ext = PM3_CMD;
}
-
#ifdef HAVE_PYTHON
- if (str_endswith(extension_chk, ".py")) {
+ else if (str_endswith(extension_chk, ".py")) {
ext = PM3_PY;
}
#endif
char *script_path = NULL;
- if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
+ if (((ext == PM3_LUA) || (ext == PM3_UNSPECIFIED)) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
int error;
if (luascriptfile_idx == MAX_NESTED_LUASCRIPT) {
PrintAndLogEx(ERR, "too many nested scripts, skipping %s\n", script_path);
@@ -230,7 +231,7 @@ static int CmdScriptRun(const char *Cmd) {
return PM3_SUCCESS;
}
- if ((ext == PM3_CMD) && (searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", true) == PM3_SUCCESS)) {
+ if (((ext == PM3_CMD) || (ext == PM3_UNSPECIFIED)) && (searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", true) == PM3_SUCCESS)) {
PrintAndLogEx(SUCCESS, "executing Cmd " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
@@ -268,7 +269,7 @@ static int CmdScriptRun(const char *Cmd) {
#ifdef HAVE_PYTHON
- if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
+ if (((ext == PM3_PY) || (ext == PM3_UNSPECIFIED)) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
PrintAndLogEx(SUCCESS, "executing python " _YELLOW_("%s"), script_path);
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
@@ -323,13 +324,14 @@ static int CmdScriptRun(const char *Cmd) {
int ret = PM3_EUNDEF;
if (ext == PM3_LUA)
ret = searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", false);
-
- if (ext == PM3_CMD)
+ else if (ext == PM3_CMD)
ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
#ifdef HAVE_PYTHON
- if (ext == PM3_PY)
+ else if (ext == PM3_PY)
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
#endif
+ else if (ext == PM3_UNSPECIFIED)
+ PrintAndLogEx(FAILED, "Error - can't find %s.[lua|cmd|py]", preferredName);
free(script_path);
return ret;
}
From fcfdd92407f60190b577130d7ae742d740dbbdf7 Mon Sep 17 00:00:00 2001
From: Philippe Teuwen
Date: Wed, 27 May 2020 01:15:20 +0200
Subject: [PATCH 177/527] python: adjust help, hide more if no python
available, search lua/cmd/py if no extension given
---
client/Makefile | 10 +++++++---
client/src/cmdscript.c | 23 ++++++++++++++++++-----
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/client/Makefile b/client/Makefile
index bbaee39b0..52ccfc23f 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -372,10 +372,14 @@ else
endif
endif
-ifeq ($(PYTHON_FOUND),1)
- $(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
+ifeq ($(SKIPPYTHON),1)
+ $(info Python3 library: skipped)
else
- $(info Python3 library: Python3 not found, disabled)
+ ifeq ($(PYTHON_FOUND),1)
+ $(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
+ else
+ $(info Python3 library: Python3 not found, disabled)
+ endif
endif
ifeq ($(SKIPWHEREAMISYSTEM),1)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index c9b485231..bc8116849 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -139,8 +139,11 @@ static int CmdScriptList(const char *Cmd) {
ret = searchAndList(CMD_SCRIPTS_SUBDIR, ".cmd");
if (ret != PM3_SUCCESS)
return ret;
-
+#ifdef HAVE_PYTHON
return searchAndList(PYTHON_SCRIPTS_SUBDIR, ".py");
+#else
+ return ret;
+#endif
}
/**
@@ -158,7 +161,10 @@ static int CmdScriptRun(const char *Cmd) {
int arg_len = 0;
static uint8_t luascriptfile_idx = 0;
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
-
+ if (strlen(preferredName) == 0) {
+ PrintAndLogEx(FAILED, "no script name provided");
+ return PM3_EINVARG;
+ }
char *extension_chk;
extension_chk = str_dup(preferredName);
str_lower(extension_chk);
@@ -329,15 +335,18 @@ static int CmdScriptRun(const char *Cmd) {
#ifdef HAVE_PYTHON
else if (ext == PM3_PY)
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
-#endif
else if (ext == PM3_UNSPECIFIED)
PrintAndLogEx(FAILED, "Error - can't find %s.[lua|cmd|py]", preferredName);
+#else
+ else if (ext == PM3_UNSPECIFIED)
+ PrintAndLogEx(FAILED, "Error - can't find %s.[lua|cmd]", preferredName);
+#endif
free(script_path);
return ret;
}
static command_t CommandTable[] = {
- {"help", CmdHelp, AlwaysAvailable, "This help"},
+ {"help", CmdHelp, AlwaysAvailable, "Usage info"},
{"list", CmdScriptList, AlwaysAvailable, "List available scripts"},
{"run", CmdScriptRun, AlwaysAvailable, " -- execute a script"},
{NULL, NULL, NULL, NULL}
@@ -351,7 +360,11 @@ static command_t CommandTable[] = {
*/
static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
- PrintAndLogEx(NORMAL, "This is a feature to run Lua-scripts. You can place Lua-scripts within the luascripts/-folder. ");
+#ifdef HAVE_PYTHON
+ PrintAndLogEx(NORMAL, "This is a feature to run Lua/Cmd/Python scripts. You can place scripts within the luascripts/cmdscripts/pyscripts folders. ");
+#else
+ PrintAndLogEx(NORMAL, "This is a feature to run Lua/Cmd scripts. You can place scripts within the luascripts/cmdscripts folders. ");
+#endif
return PM3_SUCCESS;
}
From a8c3859ed18cc9f10a76a1d0ef04ea1e8f4dd1f6 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 10:19:22 +0200
Subject: [PATCH 178/527] chg, 'script run' - added hint
---
client/src/cmdscript.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c
index bc8116849..38c980765 100644
--- a/client/src/cmdscript.c
+++ b/client/src/cmdscript.c
@@ -37,7 +37,7 @@ typedef enum {
PM3_UNSPECIFIED,
PM3_LUA,
PM3_CMD,
-#ifdef HAVE_PYTHON
+#ifdef HAVE_PYTHON
PM3_PY
#endif
} pm3_scriptfile_t;
@@ -77,12 +77,12 @@ static void set_python_path(char *path) {
if (syspath == 0) {
PrintAndLogEx(WARNING, "Python failed to getobject");
}
-
+
PyObject *pName = PyUnicode_FromString(path);
if (PyList_Insert(syspath, 0, pName)) {
PrintAndLogEx(WARNING, "Error inserting extra path into sys.path list");
}
-
+
if (PySys_SetObject("path", syspath)) {
PrintAndLogEx(WARNING,"Error setting sys.path object");
}
@@ -135,7 +135,7 @@ static int CmdScriptList(const char *Cmd) {
int ret = searchAndList(LUA_SCRIPTS_SUBDIR, ".lua");
if (ret != PM3_SUCCESS)
return ret;
-
+
ret = searchAndList(CMD_SCRIPTS_SUBDIR, ".cmd");
if (ret != PM3_SUCCESS)
return ret;
@@ -163,6 +163,7 @@ static int CmdScriptRun(const char *Cmd) {
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
if (strlen(preferredName) == 0) {
PrintAndLogEx(FAILED, "no script name provided");
+ PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`script list`") " to see available scripts");
return PM3_EINVARG;
}
char *extension_chk;
From fa2e952dc9609c199860c35ce7f2ca8f989c73a9 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 10:19:45 +0200
Subject: [PATCH 179/527] chg, swapped prefix for HINT
---
client/src/ui.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/client/src/ui.c b/client/src/ui.c
index 798ed165a..cc256d8e3 100644
--- a/client/src/ui.c
+++ b/client/src/ui.c
@@ -207,6 +207,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
strncpy(prefix, _BLUE_("[#] "), sizeof(prefix) - 1);
break;
case HINT:
+ strncpy(prefix, _YELLOW_("[?] "), sizeof(prefix) - 1);
+ break;
case SUCCESS:
strncpy(prefix, _GREEN_("[+] "), sizeof(prefix) - 1);
break;
From e381bd51196b0eecb675f65fdb9617df8db048b1 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 11:44:34 +0200
Subject: [PATCH 180/527] textual
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fdb0b7c05..3a70189b2 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]
+ - Add Python3 as possible script engine (@iceman1001, @doegox)
- Add doc/mfu_binary_format_notes.md (@iceman1001)
- Fix `hf mfu dump` - now reads Ulev1 3counter vs NTAG 1 counters (@iceman1001)
- Fix `hf mfu info` - now print correct cfg1 - nfc protection (@iceman1001)
From f32620a04bbbac55a621b86eb024ea4d4d57687f Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 11:53:17 +0200
Subject: [PATCH 181/527] OLD->MIX
---
client/src/cmdhfmfu.c | 50 +++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c
index efd10210d..b150d3435 100644
--- a/client/src/cmdhfmfu.c
+++ b/client/src/cmdhfmfu.c
@@ -486,7 +486,7 @@ static int ul_fudan_check(void) {
uint8_t cmd[4] = {0x30, 0x00, 0x02, 0xa7}; //wrong crc on purpose should be 0xa8
clearCommandBuffer();
- SendCommandOLD(CMD_HF_ISO14443A_READER, ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 4, 0, cmd, sizeof(cmd));
+ SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 4, 0, cmd, sizeof(cmd));
PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return UL_ERROR;
if (resp.oldarg[0] != 1) return UL_ERROR;
@@ -1052,6 +1052,42 @@ uint32_t GetHF14AMfU_Type(void) {
switch (len) {
case 0x0A: {
+ /*
+ MF0UL1001DUx 0004030100000B03
+MF0UL1101DUx 0004030101000B03
+MF0ULH1101DUx 0004030201000B03
+MF0UL1141DUF 0004030301000B03
+MF0UL2101Dxy 0004030101000E03
+MF0UL2101DUx 0004030201000E03
+MF0UL3101DUx 0004030101001103
+MF0ULH3101DUx 0004030201001103
+MF0UL5101DUx 0004030101001303
+NT2L1011F0DUx 0004040101000B03
+NT2H1011G0DUD 0004040201000B03
+NT2L1211F0DUx 0004040101000E03
+NT2H1311G0DUx 0004040201000F03
+NT2H1311F0Dxy 0004040401000F03
+NT2H1411G0DUx 0004040201011103
+NT2H1511G0DUx 0004040201001103
+NT2H1511F0Dxy 0004040401001103
+NT2H1611G0DUx 0004040201001303
+NT2H1611F0Dxy 0004040401001303
+NT2H1311C1DTL 0004040201010F03
+NT2H1311TTDUx 0004040203000F03
+NT3H1101W0FHK 0004040502001303
+NT3H1201W0FHK 0004040502001503
+NT3H1101W0FHK_Variant 0004040502011303
+NT3H1201 0004040502011503
+NT3H2111 0004040502021303
+NT3H2211 0004040502021503
+nhs 0004040600001303
+MF0UN0001DUx 0004030102000B03
+MF0UNH0001DUx 0004030202000B03
+MF0UN1001DUx 0004030103000B03
+MF0UNH1001DUx 0004030203000B03
+NT2L1001G0DUx 0004040102000B03
+NT2H1001G0DUx 0004040202000B03
+ */
if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; }
else if (memcmp(version, "\x00\x04\x03\x01\x02\x00\x0B", 7) == 0) { tagtype = UL_NANO_40; break; }
@@ -1534,7 +1570,7 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
}
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, blockNo, keytype, 0, cmddata, datalen);
+ SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, blockNo, keytype, 0, cmddata, datalen);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.oldarg[0] & 0xff;
@@ -1639,7 +1675,7 @@ static int CmdHF14AMfURdBl(const char *Cmd) {
}
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFAREU_READBL, blockNo, keytype, 0, authKeyPtr, datalen);
+ SendCommandMIX(CMD_HF_MIFAREU_READBL, blockNo, keytype, 0, authKeyPtr, datalen);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.oldarg[0] & 0xff;
@@ -1907,7 +1943,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
}
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFAREU_READCARD, startPage, pages, keytype, authKeyPtr, dataLen);
+ SendCommandMIX(CMD_HF_MIFAREU_READCARD, startPage, pages, keytype, authKeyPtr, dataLen);
PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
@@ -2812,7 +2848,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
PrintAndLogEx(INFO, "Reading block BEFORE attack");
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFAREU_READBL, blockNoUint, 0, 0, NULL, 0);
+ SendCommandMIX(CMD_HF_MIFAREU_READBL, blockNoUint, 0, 0, NULL, 0);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
@@ -2828,7 +2864,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
PrintAndLogEx(INFO, ".....");
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MFU_OTP_TEAROFF, blockNoUint, actualTime, 0, teardata, 8);
+ SendCommandMIX(CMD_HF_MFU_OTP_TEAROFF, blockNoUint, actualTime, 0, teardata, 8);
if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 4000)) {
PrintAndLogEx(WARNING, "Failed");
return PM3_ESOFT;
@@ -2837,7 +2873,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
PrintAndLogEx(INFO, "Reading block AFTER attack");
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFAREU_READBL, blockNoUint, 0, 0, NULL, 0);
+ SendCommandMIX(CMD_HF_MIFAREU_READBL, blockNoUint, 0, 0, NULL, 0);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.oldarg[0] & 0xff;
if (isOK) {
From 045f2a8587afe891550c0324b04650e9f1627108 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 11:55:32 +0200
Subject: [PATCH 182/527] OLD->MIX
---
client/src/mifare/mifarehost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c
index 00e26a89e..fae64a2f6 100644
--- a/client/src/mifare/mifarehost.c
+++ b/client/src/mifare/mifarehost.c
@@ -748,7 +748,7 @@ out:
int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data) {
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFARE_READSC, sectorNo, keyType, 0, key, 6);
+ SendCommandMIX(CMD_HF_MIFARE_READSC, sectorNo, keyType, 0, key, 6);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
@@ -910,7 +910,7 @@ int mfCWipe(uint8_t *uid, uint8_t *atqa, uint8_t *sak) {
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params) {
clearCommandBuffer();
- SendCommandOLD(CMD_HF_MIFARE_CSETBL, params, blockNo, 0, data, 16);
+ SendCommandMIX(CMD_HF_MIFARE_CSETBL, params, blockNo, 0, data, 16);
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.oldarg[0] & 0xff;
From f3cc84220f221ad76b118f87e7c04bbe859eaa71 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 11:58:04 +0200
Subject: [PATCH 183/527] OLD->MIX
---
client/src/cmdsmartcard.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c
index f21ef5c4a..f60dd5513 100644
--- a/client/src/cmdsmartcard.c
+++ b/client/src/cmdsmartcard.c
@@ -366,7 +366,7 @@ static int smart_responseEx(uint8_t *data, bool silent) {
uint8_t getstatus[] = {0x00, ISO7816_GET_RESPONSE, 0x00, 0x00, len};
clearCommandBuffer();
- SendCommandOLD(CMD_SMART_RAW, SC_RAW, sizeof(getstatus), 0, getstatus, sizeof(getstatus));
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW, sizeof(getstatus), 0, getstatus, sizeof(getstatus));
datalen = smart_wait(data, silent);
@@ -893,7 +893,7 @@ static void smart_brute_prim(void) {
for (int i = 0; i < ARRAYLEN(get_card_data); i += 5) {
clearCommandBuffer();
- SendCommandOLD(CMD_SMART_RAW, SC_RAW_T0, 5, 0, get_card_data + i, 5);
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW_T0, 5, 0, get_card_data + i, 5);
int len = smart_responseEx(buf, true);
@@ -936,7 +936,7 @@ static int smart_brute_sfi(bool decodeTLV) {
READ_RECORD[3] = (sfi << 3) | 4;
clearCommandBuffer();
- SendCommandOLD(CMD_SMART_RAW, SC_RAW_T0, sizeof(READ_RECORD), 0, READ_RECORD, sizeof(READ_RECORD));
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW_T0, sizeof(READ_RECORD), 0, READ_RECORD, sizeof(READ_RECORD));
len = smart_responseEx(buf, true);
@@ -944,7 +944,7 @@ static int smart_brute_sfi(bool decodeTLV) {
READ_RECORD[4] = buf[1];
clearCommandBuffer();
- SendCommandOLD(CMD_SMART_RAW, SC_RAW_T0, sizeof(READ_RECORD), 0, READ_RECORD, sizeof(READ_RECORD));
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW_T0, sizeof(READ_RECORD), 0, READ_RECORD, sizeof(READ_RECORD));
len = smart_responseEx(buf, true);
READ_RECORD[4] = 0;
@@ -979,7 +979,7 @@ static void smart_brute_options(bool decodeTLV) {
// Get processing options command
clearCommandBuffer();
- SendCommandOLD(CMD_SMART_RAW, SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0, GET_PROCESSING_OPTIONS, sizeof(GET_PROCESSING_OPTIONS));
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0, GET_PROCESSING_OPTIONS, sizeof(GET_PROCESSING_OPTIONS));
int len = smart_responseEx(buf, true);
if (len > 4) {
@@ -1190,7 +1190,7 @@ int ExchangeAPDUSC(bool silent, uint8_t *datain, int datainlen, bool activateCar
clearCommandBuffer();
// something fishy: we have only 5 bytes but we put datainlen in arg1?
- SendCommandOLD(CMD_SMART_RAW, SC_RAW_T0, datainlen, 0, data, sizeof(data));
+ SendCommandMIX(CMD_SMART_RAW, SC_RAW_T0, datainlen, 0, data, sizeof(data));
len = smart_responseEx(dataout, silent);
}
From abff3c2ea1513dfe4be17905e5dfc6a294b0d210 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 11:59:24 +0200
Subject: [PATCH 184/527] OLD-MIX
---
client/src/cmdlft55xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c
index 9b54aef8f..173d8eb22 100644
--- a/client/src/cmdlft55xx.c
+++ b/client/src/cmdlft55xx.c
@@ -3618,7 +3618,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
}
clearCommandBuffer();
- SendCommandOLD(CMD_LF_T55XX_SET_CONFIG, shall_persist, 0, 0, &configurations, sizeof(t55xx_configurations_t));
+ SendCommandMIX(CMD_LF_T55XX_SET_CONFIG, shall_persist, 0, 0, &configurations, sizeof(t55xx_configurations_t));
return PM3_SUCCESS;
}
From 54d3ea9c8fc410ef550dc10d8b4e59afbc5dae50 Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 12:02:59 +0200
Subject: [PATCH 185/527] OLD->MIX
---
client/src/cmdhf14b.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c
index 7be829472..bfb19323b 100644
--- a/client/src/cmdhf14b.c
+++ b/client/src/cmdhf14b.c
@@ -693,7 +693,7 @@ static bool HF14B_Other_Reader(void) {
// uint32_t flags = ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_RAW | ISO14B_APPEND_CRC;
// clearCommandBuffer();
- // SendCommandOLD(CMD_HF_ISO14443B_COMMAND, flags, datalen, 0, data, datalen);
+ // SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, datalen, 0, data, datalen);
// PacketResponseNG resp;
// WaitForResponse(CMD_ACK,&resp);
@@ -707,7 +707,7 @@ static bool HF14B_Other_Reader(void) {
// data[0] = ISO14443B_AUTHENTICATE;
// clearCommandBuffer();
- // SendCommandOLD(CMD_HF_ISO14443B_COMMAND, flags, 1, 0, data, 1);
+ // SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, 1, 0, data, 1);
// PacketResponseNG resp;
// WaitForResponse(CMD_ACK, &resp);
@@ -721,7 +721,7 @@ static bool HF14B_Other_Reader(void) {
// data[0] = ISO14443B_RESET;
// clearCommandBuffer();
- // SendCommandOLD(CMD_HF_ISO14443B_COMMAND, flags, 1, 0, data, 1);
+ // SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, 1, 0, data, 1);
// PacketResponseNG resp;
// WaitForResponse(CMD_ACK, &resp);
@@ -913,7 +913,7 @@ static int CmdHF14BDump(const char *Cmd) {
req[1] = blocknum;
clearCommandBuffer();
- SendCommandOLD(CMD_HF_ISO14443B_COMMAND, ISO14B_APPEND_CRC | ISO14B_RAW, 2, 0, req, sizeof(req));
+ SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_APPEND_CRC | ISO14B_RAW, 2, 0, req, sizeof(req));
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
From b42c5f59e13ec6a118bbce2fcaa514f0b1a26d9c Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 17:44:54 +0200
Subject: [PATCH 186/527] OLD->MIX
---
client/src/cmdlfhitag.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/cmdlfhitag.c b/client/src/cmdlfhitag.c
index 5a11216fb..28cbd41d0 100644
--- a/client/src/cmdlfhitag.c
+++ b/client/src/cmdlfhitag.c
@@ -363,7 +363,7 @@ static int CmdLFHitagSim(const char *Cmd) {
clearCommandBuffer();
if (tag_mem_supplied) {
- SendCommandOLD(cmd, 1, 0, 0, data, datalen);
+ SendCommandMIX(cmd, 1, 0, 0, data, datalen);
} else {
SendCommandMIX(cmd, 0, 0, 0, NULL, 0);
}
@@ -693,7 +693,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
}
clearCommandBuffer();
- SendCommandOLD(CMD_LF_HITAGS_WRITE, htf, 0, arg2, &htd, sizeof(htd));
+ SendCommandMIX(CMD_LF_HITAGS_WRITE, htf, 0, arg2, &htd, sizeof(htd));
PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
From 46f191e13f55aeaa5fa08a3ad1d4f28265d750bf Mon Sep 17 00:00:00 2001
From: iceman1001
Date: Wed, 27 May 2020 17:46:50 +0200
Subject: [PATCH 187/527] OLD->MIX
---
client/src/cmdhf14a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c
index d65869144..5f1ec7b18 100644
--- a/client/src/cmdhf14a.c
+++ b/client/src/cmdhf14a.c
@@ -1524,7 +1524,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
if (select_status == 2) {
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
clearCommandBuffer();
- SendCommandOLD(CMD_HF_ISO14443A_READER, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0, rats, sizeof(rats));
+ SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0, rats, sizeof(rats));
WaitForResponse(CMD_ACK, &resp);
memcpy(card.ats, resp.data.asBytes, resp.oldarg[0]);
From 5860cb5e925112d1c62893edc2d010799fd382d6 Mon Sep 17 00:00:00 2001
From: iceman1001