diff --git a/armsrc/Standalone/hf_legic.c b/armsrc/Standalone/hf_legic.c index 2b826528f..8b00766d5 100644 --- a/armsrc/Standalone/hf_legic.c +++ b/armsrc/Standalone/hf_legic.c @@ -20,7 +20,7 @@ #include "legicrf.h" #include "legicrfsim.h" #include "legic.h" // legic_card_select_t struct -#include "spiffs.h" // flashmem +#include "spiffs.h" // flashmem /* @@ -47,7 +47,7 @@ void DownloadLogInstructions() { Dbprintf(""); Dbprintf("[=] List all dumps from flash:"); - Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree"); + Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree"); Dbprintf(""); Dbprintf("[=] To save a dump file from flash to client:"); Dbprintf("[=] " _YELLOW_("-") "mem spiffs dump o hf-legic-UID-dump.bin f hf-legic-UID-dump.bin"); @@ -60,15 +60,15 @@ void save_dump_to_file(legic_card_select_t *p_card) { // legic functions puts it memory in Emulator reserved memory. uint8_t *mem = BigBuf_get_EM_addr(); - char *preferredName = (char*)BigBuf_malloc(30); + char *preferredName = (char *)BigBuf_malloc(30); if (preferredName == NULL) { goto OUT; } - + sprintf(preferredName, "hf-legic-%02X%02X%02X%02X-dump", p_card->uid[0], p_card->uid[1], p_card->uid[2], p_card->uid[3]); uint16_t preferredNameLen = strlen(preferredName); - char *filename = (char*)BigBuf_malloc(preferredNameLen + 4 + 1 + 10); + char *filename = (char *)BigBuf_malloc(preferredNameLen + 4 + 1 + 10); if (filename == NULL) { goto OUT; } @@ -106,7 +106,7 @@ void RunMod() { DbpString("[=] press and HOLD button to exit standalone mode"); for (;;) { WDT_HIT(); - + //exit from hf_legic, send usbcommand if (data_available()) break; @@ -136,18 +136,18 @@ void RunMod() { //simulate if read successfully if (read_success != PM3_ESOFT) { - + legic_card_select_t *p_card; p_card = getLegicCardInfo(); - if (p_card->cardsize == 0) + if (p_card->cardsize == 0) continue; - + save_dump_to_file(p_card); LED_D_ON(); uint8_t ct; - switch(p_card->tagtype) { - case 0x0D: + switch (p_card->tagtype) { + case 0x0D: ct = 0; break; case 0x1D: @@ -156,7 +156,7 @@ void RunMod() { case 0x3D: ct = 2; break; - default: + default: continue; } diff --git a/armsrc/Standalone/lf_em4100emul.c b/armsrc/Standalone/lf_em4100emul.c index 7b38133bc..fc399c64a 100644 --- a/armsrc/Standalone/lf_em4100emul.c +++ b/armsrc/Standalone/lf_em4100emul.c @@ -83,7 +83,7 @@ void RunMod() { StandAloneMode(); FpgaDownloadAndGo(FPGA_BITSTREAM_LF); Dbprintf("[=] >> LF EM4100 simulator started <<"); - + int selected = 0; //selected slot after start slots_count = sizeof(low) / sizeof(low[0]); bba = BigBuf_get_addr(); diff --git a/armsrc/Standalone/lf_em4100rwc.c b/armsrc/Standalone/lf_em4100rwc.c index 02366d0a6..f4025d1b1 100644 --- a/armsrc/Standalone/lf_em4100rwc.c +++ b/armsrc/Standalone/lf_em4100rwc.c @@ -122,7 +122,7 @@ void RunMod() { StandAloneMode(); FpgaDownloadAndGo(FPGA_BITSTREAM_LF); Dbprintf("[=] >> LF EM4100 read/write/clone started <<"); - + int selected = 0; //state 0 - select slot // 1 - read tag to selected slot, diff --git a/armsrc/epa.c b/armsrc/epa.c index 3a44502ba..867f4a43f 100644 --- a/armsrc/epa.c +++ b/armsrc/epa.c @@ -524,7 +524,7 @@ int EPA_Setup() { } FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - + // if we're here, there is no type A card, so we look for type B // power up the field iso14443b_setup(); diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c index 4268e82e5..8e9a4bb88 100644 --- a/armsrc/hitagS.c +++ b/armsrc/hitagS.c @@ -52,8 +52,8 @@ size_t blocknr; bool end = false; //#define SENDBIT_TEST -/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3 -// UID is 0 1 2 3 // tag.uid is 3210 +/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3 +// UID is 0 1 2 3 // tag.uid is 3210 // datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0 #db# UID: 5F C2 11 84 @@ -977,7 +977,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) { // TC1: Capture mode, default timer source = MCK/2 (TIMER_CLOCK1), TIOA is external trigger, // external trigger rising edge, load RA on rising edge of TIOA. AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK - | AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING; + | AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING; // Enable and reset counter AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG; @@ -1051,7 +1051,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) { // Enable and reset external trigger in timer for capturing future frames AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG; - + // Reset the received frame and response timing info memset(rx, 0x00, sizeof(rx)); response = 0; diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c index b411efcaf..35ac379ad 100644 --- a/armsrc/legicrf.c +++ b/armsrc/legicrf.c @@ -404,7 +404,7 @@ bool write_byte(uint16_t index, uint8_t byte, uint8_t addr_sz) { // // Only this functions are public / called from appmain.c //----------------------------------------------------------------------------- -legic_card_select_t* getLegicCardInfo(void) { +legic_card_select_t *getLegicCardInfo(void) { return &card; } @@ -471,7 +471,7 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv) { goto OUT; } legic_mem[i] = byte; - + if (i < 4) { card.uid[i] = byte; } @@ -506,7 +506,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) { goto OUT; } legic_mem[i] = byte; - + if (i < 4) { card.uid[i] = byte; } diff --git a/armsrc/legicrf.h b/armsrc/legicrf.h index ae4c78cdc..687accbeb 100644 --- a/armsrc/legicrf.h +++ b/armsrc/legicrf.h @@ -21,5 +21,5 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv); void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv); void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data); -legic_card_select_t* getLegicCardInfo(void); +legic_card_select_t *getLegicCardInfo(void); #endif /* __LEGICRF_H */ diff --git a/armsrc/lfops.c b/armsrc/lfops.c index a5104d98e..aa2f68e2a 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) { WaitUS(32 * 8); } else { TurnReadLF_off(23 * 8); - TurnReadLFOn((32-23) * 8); + TurnReadLFOn((32 - 23) * 8); } } } diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c index eedbb06cc..1fb77ab0e 100644 --- a/armsrc/mifaredesfire.c +++ b/armsrc/mifaredesfire.c @@ -334,16 +334,16 @@ void MifareDES_Auth1(uint8_t *datain) { return; } - int rndlen=8; + int rndlen = 8; int expectedlen = 1 + 8 + 2 + 2; if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) { expectedlen = 1 + 16 + 2 + 2; - rndlen=16; + rndlen = 16; } if (payload->mode == MFDES_AUTH_PICC) { expectedlen = 1 + 1 + 8 + 2; - rndlen=8; + rndlen = 8; } if (len != expectedlen) { diff --git a/armsrc/util.h b/armsrc/util.h index 052ae266c..40a7c3026 100644 --- a/armsrc/util.h +++ b/armsrc/util.h @@ -15,7 +15,7 @@ // PRIx64 definition missing with gcc-arm-none-eabi v8? #ifndef PRIx64 - #define PRIx64 "llx" +#define PRIx64 "llx" #endif // Basic macros diff --git a/client/Makefile b/client/Makefile index 79c0a101b..0be82d040 100644 --- a/client/Makefile +++ b/client/Makefile @@ -17,7 +17,7 @@ include ../Makefile.defs INSTALLBIN = proxmark3 INSTALLSHARE = cmdscripts lualibs luascripts resources dictionaries -VPATH = ../common uart +VPATH = ../common src/uart src deps vpath %.dic dictionaries OBJDIR = obj @@ -32,15 +32,15 @@ ifneq ($(platform),Darwin) endif # local libraries -LUALIBPATH = ./liblua +LUALIBPATH = ./deps/liblua LUALIB = $(LUALIBPATH)/liblua.a -JANSSONLIBPATH = ./jansson +JANSSONLIBPATH = ./deps/jansson JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a -CBORLIBPATH = ./tinycbor +CBORLIBPATH = ./deps/tinycbor CBORLIB = $(CBORLIBPATH)/tinycbor.a -REVENGPATH = ./reveng +REVENGPATH = ./deps/reveng REVENGLIB = $(REVENGPATH)/libreveng.a -AMIIBOLIBPATH = ./amiitool +AMIIBOLIBPATH = ./deps/amiitool AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a # common libraries @@ -50,7 +50,7 @@ ZLIBPATH = ../common/zlib ZLIB = $(OBJDIR)/libz.a LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH) -INCLUDES_CLIENT = -I. -I../include -I../common -Iuart $(LIBS) +INCLUDES_CLIENT = -I./src -I./deps -I../include -I../common -I./deps/cliparser -I./src/uart $(LIBS) CFLAGS ?= -Wall -Werror -g -O3 # We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env: PM3CFLAGS = $(CFLAGS) -std=c99 -D_ISOC99_SOURCE $(INCLUDES_CLIENT) @@ -59,7 +59,7 @@ ifneq (,$(findstring MINGW,$(platform))) PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850 endif CXXFLAGS ?= -Wall -Werror -O3 -PM3CXXFLAGS = $(CXXFLAGS) -I../include +PM3CXXFLAGS = $(CXXFLAGS) -I../include -I/.deps/cliparser LUAPLATFORM = generic ifneq (,$(findstring MINGW,$(platform))) @@ -130,6 +130,7 @@ CORESRCS = uart_posix.c \ util_posix.c \ scandir.c \ crc16.c \ + crc32.c \ comms.c CMDSRCS = crapto1/crapto1.c \ @@ -200,7 +201,7 @@ CMDSRCS = crapto1/crapto1.c \ cmdhfmfu.c \ cmdhfmfp.c \ cmdhfmfhard.c \ - hardnested/hardnested_bruteforce.c \ + deps/hardnested/hardnested_bruteforce.c \ cmdhfmfdes.c \ cmdhftopaz.c \ cmdhffido.c \ @@ -258,13 +259,13 @@ CMDSRCS = crapto1/crapto1.c \ cpu_arch = $(shell uname -m) ifneq ($(findstring 86, $(cpu_arch)), ) - MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c + MULTIARCHSRCS = deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c endif ifneq ($(findstring amd64, $(cpu_arch)), ) - MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c + MULTIARCHSRCS = deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c endif ifeq ($(MULTIARCHSRCS), ) - CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c + CMDSRCS += deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c endif @@ -310,13 +311,13 @@ proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(info [=] LD $@) $(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@ -proxgui.cpp: ui/ui_overlays.h +src/proxgui.cpp: src/ui/ui_overlays.h -proxguiqt.moc.cpp: proxguiqt.h +src/proxguiqt.moc.cpp: src/proxguiqt.h $(info [-] MOC $@) $(Q)$(MOC) -o$@ $^ -ui/ui_overlays.h: ui/overlays.ui +src/ui/ui_overlays.h: src/ui/overlays.ui $(info [-] UIC $@) $(Q)$(UIC) $^ > $@ diff --git a/client/amiitool/LICENSE b/client/deps/amiitool/LICENSE similarity index 100% rename from client/amiitool/LICENSE rename to client/deps/amiitool/LICENSE diff --git a/client/amiitool/Makefile b/client/deps/amiitool/Makefile similarity index 51% rename from client/amiitool/Makefile rename to client/deps/amiitool/Makefile index c473f58ee..6926c12c6 100644 --- a/client/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../../../include MYCFLAGS = -std=c99 -D_ISOC99_SOURCE MYDEFS = MYSRCS = \ @@ -9,11 +9,11 @@ MYSRCS = \ LIB_A = libamiibo.a -include ../../Makefile.host +include ../../../Makefile.host # just for testing amiitool before complete migration into a lib: amiitool: gcc $(CFLAGS) \ - amiitool.c $(MYSRCS) ../../common/commonutil.c ../ui.c -lreadline -lm ../../common/mbedtls/libmbedtls.a \ + amiitool.c $(MYSRCS) ../../../common/commonutil.c ../ui.c -lreadline -lm ../../../common/mbedtls/libmbedtls.a \ -o amiitool diff --git a/client/amiitool/amiibo.c b/client/deps/amiitool/amiibo.c similarity index 100% rename from client/amiitool/amiibo.c rename to client/deps/amiitool/amiibo.c diff --git a/client/amiitool/amiibo.h b/client/deps/amiitool/amiibo.h similarity index 100% rename from client/amiitool/amiibo.h rename to client/deps/amiitool/amiibo.h diff --git a/client/amiitool/amiitool.c b/client/deps/amiitool/amiitool.c similarity index 99% rename from client/amiitool/amiitool.c rename to client/deps/amiitool/amiitool.c index ca34a5c6a..2c5c4ddc2 100644 --- a/client/amiitool/amiitool.c +++ b/client/deps/amiitool/amiitool.c @@ -7,7 +7,7 @@ #include #include -#include "fileutils.h" +#include "src/fileutils.h" #include "amiibo.h" #include "getopt.h" diff --git a/client/amiitool/drbg.c b/client/deps/amiitool/drbg.c similarity index 100% rename from client/amiitool/drbg.c rename to client/deps/amiitool/drbg.c diff --git a/client/amiitool/drbg.h b/client/deps/amiitool/drbg.h similarity index 100% rename from client/amiitool/drbg.h rename to client/deps/amiitool/drbg.h diff --git a/client/amiitool/key_retail.bin b/client/deps/amiitool/key_retail.bin similarity index 100% rename from client/amiitool/key_retail.bin rename to client/deps/amiitool/key_retail.bin diff --git a/client/amiitool/keygen.c b/client/deps/amiitool/keygen.c similarity index 100% rename from client/amiitool/keygen.c rename to client/deps/amiitool/keygen.c diff --git a/client/amiitool/keygen.h b/client/deps/amiitool/keygen.h similarity index 100% rename from client/amiitool/keygen.h rename to client/deps/amiitool/keygen.h diff --git a/client/cliparser/README.md b/client/deps/cliparser/README.md similarity index 100% rename from client/cliparser/README.md rename to client/deps/cliparser/README.md diff --git a/client/cliparser/argtable3.c b/client/deps/cliparser/argtable3.c similarity index 100% rename from client/cliparser/argtable3.c rename to client/deps/cliparser/argtable3.c diff --git a/client/cliparser/argtable3.h b/client/deps/cliparser/argtable3.h similarity index 100% rename from client/cliparser/argtable3.h rename to client/deps/cliparser/argtable3.h diff --git a/client/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c similarity index 99% rename from client/cliparser/cliparser.c rename to client/deps/cliparser/cliparser.c index 6e11d632c..1845aff29 100644 --- a/client/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -165,7 +165,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int if (ibuf == 0) { return res; } - + switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) { case 1: printf("Parameter error: Invalid HEX value.\n"); diff --git a/client/cliparser/cliparser.h b/client/deps/cliparser/cliparser.h similarity index 100% rename from client/cliparser/cliparser.h rename to client/deps/cliparser/cliparser.h diff --git a/client/cliparser/getopt.h b/client/deps/cliparser/getopt.h similarity index 100% rename from client/cliparser/getopt.h rename to client/deps/cliparser/getopt.h diff --git a/client/hardnested/hardnested_bf_core.c b/client/deps/hardnested/hardnested_bf_core.c similarity index 99% rename from client/hardnested/hardnested_bf_core.c rename to client/deps/hardnested/hardnested_bf_core.c index adc203f61..4e30dd894 100644 --- a/client/hardnested/hardnested_bf_core.c +++ b/client/deps/hardnested/hardnested_bf_core.c @@ -59,8 +59,8 @@ THE SOFTWARE. #include #include "crapto1/crapto1.h" #include "parity.h" -#include "util.h" -#include "common.h" +//#include "util.h" +//#include "common.h" // bitslice type // while AVX supports 256 bit vector floating point operations, we need integer operations for boolean logic diff --git a/client/hardnested/hardnested_bf_core.h b/client/deps/hardnested/hardnested_bf_core.h similarity index 100% rename from client/hardnested/hardnested_bf_core.h rename to client/deps/hardnested/hardnested_bf_core.h diff --git a/client/hardnested/hardnested_bitarray_core.c b/client/deps/hardnested/hardnested_bitarray_core.c similarity index 100% rename from client/hardnested/hardnested_bitarray_core.c rename to client/deps/hardnested/hardnested_bitarray_core.c diff --git a/client/hardnested/hardnested_bitarray_core.h b/client/deps/hardnested/hardnested_bitarray_core.h similarity index 100% rename from client/hardnested/hardnested_bitarray_core.h rename to client/deps/hardnested/hardnested_bitarray_core.h diff --git a/client/hardnested/hardnested_bruteforce.c b/client/deps/hardnested/hardnested_bruteforce.c similarity index 100% rename from client/hardnested/hardnested_bruteforce.c rename to client/deps/hardnested/hardnested_bruteforce.c diff --git a/client/hardnested/hardnested_bruteforce.h b/client/deps/hardnested/hardnested_bruteforce.h similarity index 71% rename from client/hardnested/hardnested_bruteforce.h rename to client/deps/hardnested/hardnested_bruteforce.h index 708d48b84..8766362d7 100644 --- a/client/hardnested/hardnested_bruteforce.h +++ b/client/deps/hardnested/hardnested_bruteforce.h @@ -19,7 +19,33 @@ #include #include -#include "cmdhfmfhard.h" + +#define NUM_SUMS 19 // number of possible sum property values + +typedef struct guess_sum_a8 { + float prob; + uint64_t num_states; + uint8_t sum_a8_idx; +} guess_sum_a8_t; + +typedef struct noncelistentry { + uint32_t nonce_enc; + uint8_t par_enc; + void *next; +} noncelistentry_t; + +typedef struct noncelist { + uint16_t num; + uint16_t Sum; + guess_sum_a8_t sum_a8_guess[NUM_SUMS]; + bool sum_a8_guess_dirty; + float expected_num_brute_force; + uint8_t BitFlips[0x400]; + uint32_t *states_bitarray[2]; + uint32_t num_states_bitarray[2]; + bool all_bitflips_dirty[2]; + noncelistentry_t *first; +} noncelist_t; typedef struct { uint32_t *states[2]; diff --git a/client/hardnested/hardnested_tables.c b/client/deps/hardnested/hardnested_tables.c similarity index 100% rename from client/hardnested/hardnested_tables.c rename to client/deps/hardnested/hardnested_tables.c diff --git a/client/jansson/Makefile b/client/deps/jansson/Makefile similarity index 90% rename from client/jansson/Makefile rename to client/deps/jansson/Makefile index dc4ae230b..1ef283bab 100644 --- a/client/jansson/Makefile +++ b/client/deps/jansson/Makefile @@ -18,4 +18,4 @@ MYSRCS = \ LIB_A = libjansson.a -include ../../Makefile.host +include ../../../Makefile.host diff --git a/client/jansson/dump.c b/client/deps/jansson/dump.c similarity index 100% rename from client/jansson/dump.c rename to client/deps/jansson/dump.c diff --git a/client/jansson/error.c b/client/deps/jansson/error.c similarity index 100% rename from client/jansson/error.c rename to client/deps/jansson/error.c diff --git a/client/jansson/hashtable.c b/client/deps/jansson/hashtable.c similarity index 99% rename from client/jansson/hashtable.c rename to client/deps/jansson/hashtable.c index 071ba585f..38c10a0c7 100644 --- a/client/jansson/hashtable.c +++ b/client/deps/jansson/hashtable.c @@ -16,7 +16,7 @@ #include #endif -#include /* for JSON_INLINE */ +#include "jansson_config.h" /* for JSON_INLINE */ #include "jansson_private.h" /* for container_of() */ #include "hashtable.h" diff --git a/client/jansson/hashtable.h b/client/deps/jansson/hashtable.h similarity index 100% rename from client/jansson/hashtable.h rename to client/deps/jansson/hashtable.h diff --git a/client/jansson/hashtable_seed.c b/client/deps/jansson/hashtable_seed.c similarity index 100% rename from client/jansson/hashtable_seed.c rename to client/deps/jansson/hashtable_seed.c diff --git a/client/jansson/jansson.def b/client/deps/jansson/jansson.def similarity index 100% rename from client/jansson/jansson.def rename to client/deps/jansson/jansson.def diff --git a/client/jansson/jansson.h b/client/deps/jansson/jansson.h similarity index 100% rename from client/jansson/jansson.h rename to client/deps/jansson/jansson.h diff --git a/client/jansson/jansson_config.h b/client/deps/jansson/jansson_config.h similarity index 100% rename from client/jansson/jansson_config.h rename to client/deps/jansson/jansson_config.h diff --git a/client/jansson/jansson_config.h.in b/client/deps/jansson/jansson_config.h.in similarity index 100% rename from client/jansson/jansson_config.h.in rename to client/deps/jansson/jansson_config.h.in diff --git a/client/jansson/jansson_private.h b/client/deps/jansson/jansson_private.h similarity index 100% rename from client/jansson/jansson_private.h rename to client/deps/jansson/jansson_private.h diff --git a/client/jansson/load.c b/client/deps/jansson/load.c similarity index 100% rename from client/jansson/load.c rename to client/deps/jansson/load.c diff --git a/client/jansson/lookup3.h b/client/deps/jansson/lookup3.h similarity index 100% rename from client/jansson/lookup3.h rename to client/deps/jansson/lookup3.h diff --git a/client/jansson/memory.c b/client/deps/jansson/memory.c similarity index 100% rename from client/jansson/memory.c rename to client/deps/jansson/memory.c diff --git a/client/jansson/pack_unpack.c b/client/deps/jansson/pack_unpack.c similarity index 100% rename from client/jansson/pack_unpack.c rename to client/deps/jansson/pack_unpack.c diff --git a/client/jansson/path.c b/client/deps/jansson/path.c similarity index 99% rename from client/jansson/path.c rename to client/deps/jansson/path.c index f9c3a9117..11964ec6e 100644 --- a/client/jansson/path.c +++ b/client/deps/jansson/path.c @@ -10,7 +10,7 @@ #include #include -#include +#include "jansson.h" #include "jansson_private.h" json_t *json_path_get(const json_t *json, const char *path) { diff --git a/client/jansson/strbuffer.c b/client/deps/jansson/strbuffer.c similarity index 100% rename from client/jansson/strbuffer.c rename to client/deps/jansson/strbuffer.c diff --git a/client/jansson/strbuffer.h b/client/deps/jansson/strbuffer.h similarity index 100% rename from client/jansson/strbuffer.h rename to client/deps/jansson/strbuffer.h diff --git a/client/jansson/strconv.c b/client/deps/jansson/strconv.c similarity index 100% rename from client/jansson/strconv.c rename to client/deps/jansson/strconv.c diff --git a/client/jansson/utf.c b/client/deps/jansson/utf.c similarity index 100% rename from client/jansson/utf.c rename to client/deps/jansson/utf.c diff --git a/client/jansson/utf.h b/client/deps/jansson/utf.h similarity index 100% rename from client/jansson/utf.h rename to client/deps/jansson/utf.h diff --git a/client/jansson/value.c b/client/deps/jansson/value.c similarity index 100% rename from client/jansson/value.c rename to client/deps/jansson/value.c diff --git a/client/liblua/Makefile b/client/deps/liblua/Makefile similarity index 97% rename from client/liblua/Makefile rename to client/deps/liblua/Makefile index 250f4b7ee..d4b31be0a 100644 --- a/client/liblua/Makefile +++ b/client/deps/liblua/Makefile @@ -21,7 +21,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris default: $(PLAT) -include ../../Makefile.host +include ../../../Makefile.host # Convenience targets for popular platforms ALL= all diff --git a/client/liblua/lapi.c b/client/deps/liblua/lapi.c similarity index 100% rename from client/liblua/lapi.c rename to client/deps/liblua/lapi.c diff --git a/client/liblua/lapi.h b/client/deps/liblua/lapi.h similarity index 100% rename from client/liblua/lapi.h rename to client/deps/liblua/lapi.h diff --git a/client/liblua/lauxlib.c b/client/deps/liblua/lauxlib.c similarity index 100% rename from client/liblua/lauxlib.c rename to client/deps/liblua/lauxlib.c diff --git a/client/liblua/lauxlib.h b/client/deps/liblua/lauxlib.h similarity index 100% rename from client/liblua/lauxlib.h rename to client/deps/liblua/lauxlib.h diff --git a/client/liblua/lbaselib.c b/client/deps/liblua/lbaselib.c similarity index 100% rename from client/liblua/lbaselib.c rename to client/deps/liblua/lbaselib.c diff --git a/client/liblua/lbitlib.c b/client/deps/liblua/lbitlib.c similarity index 100% rename from client/liblua/lbitlib.c rename to client/deps/liblua/lbitlib.c diff --git a/client/liblua/lcode.c b/client/deps/liblua/lcode.c similarity index 100% rename from client/liblua/lcode.c rename to client/deps/liblua/lcode.c diff --git a/client/liblua/lcode.h b/client/deps/liblua/lcode.h similarity index 100% rename from client/liblua/lcode.h rename to client/deps/liblua/lcode.h diff --git a/client/liblua/lcorolib.c b/client/deps/liblua/lcorolib.c similarity index 100% rename from client/liblua/lcorolib.c rename to client/deps/liblua/lcorolib.c diff --git a/client/liblua/lctype.c b/client/deps/liblua/lctype.c similarity index 100% rename from client/liblua/lctype.c rename to client/deps/liblua/lctype.c diff --git a/client/liblua/lctype.h b/client/deps/liblua/lctype.h similarity index 100% rename from client/liblua/lctype.h rename to client/deps/liblua/lctype.h diff --git a/client/liblua/ldblib.c b/client/deps/liblua/ldblib.c similarity index 100% rename from client/liblua/ldblib.c rename to client/deps/liblua/ldblib.c diff --git a/client/liblua/ldebug.c b/client/deps/liblua/ldebug.c similarity index 100% rename from client/liblua/ldebug.c rename to client/deps/liblua/ldebug.c diff --git a/client/liblua/ldebug.h b/client/deps/liblua/ldebug.h similarity index 100% rename from client/liblua/ldebug.h rename to client/deps/liblua/ldebug.h diff --git a/client/liblua/ldo.c b/client/deps/liblua/ldo.c similarity index 100% rename from client/liblua/ldo.c rename to client/deps/liblua/ldo.c diff --git a/client/liblua/ldo.h b/client/deps/liblua/ldo.h similarity index 100% rename from client/liblua/ldo.h rename to client/deps/liblua/ldo.h diff --git a/client/liblua/ldump.c b/client/deps/liblua/ldump.c similarity index 100% rename from client/liblua/ldump.c rename to client/deps/liblua/ldump.c diff --git a/client/liblua/lfunc.c b/client/deps/liblua/lfunc.c similarity index 100% rename from client/liblua/lfunc.c rename to client/deps/liblua/lfunc.c diff --git a/client/liblua/lfunc.h b/client/deps/liblua/lfunc.h similarity index 100% rename from client/liblua/lfunc.h rename to client/deps/liblua/lfunc.h diff --git a/client/liblua/lgc.c b/client/deps/liblua/lgc.c similarity index 100% rename from client/liblua/lgc.c rename to client/deps/liblua/lgc.c diff --git a/client/liblua/lgc.h b/client/deps/liblua/lgc.h similarity index 100% rename from client/liblua/lgc.h rename to client/deps/liblua/lgc.h diff --git a/client/liblua/linit.c b/client/deps/liblua/linit.c similarity index 100% rename from client/liblua/linit.c rename to client/deps/liblua/linit.c diff --git a/client/liblua/liolib.c b/client/deps/liblua/liolib.c similarity index 100% rename from client/liblua/liolib.c rename to client/deps/liblua/liolib.c diff --git a/client/liblua/llex.c b/client/deps/liblua/llex.c similarity index 100% rename from client/liblua/llex.c rename to client/deps/liblua/llex.c diff --git a/client/liblua/llex.h b/client/deps/liblua/llex.h similarity index 100% rename from client/liblua/llex.h rename to client/deps/liblua/llex.h diff --git a/client/liblua/llimits.h b/client/deps/liblua/llimits.h similarity index 100% rename from client/liblua/llimits.h rename to client/deps/liblua/llimits.h diff --git a/client/liblua/lmathlib.c b/client/deps/liblua/lmathlib.c similarity index 100% rename from client/liblua/lmathlib.c rename to client/deps/liblua/lmathlib.c diff --git a/client/liblua/lmem.c b/client/deps/liblua/lmem.c similarity index 100% rename from client/liblua/lmem.c rename to client/deps/liblua/lmem.c diff --git a/client/liblua/lmem.h b/client/deps/liblua/lmem.h similarity index 100% rename from client/liblua/lmem.h rename to client/deps/liblua/lmem.h diff --git a/client/liblua/loadlib.c b/client/deps/liblua/loadlib.c similarity index 100% rename from client/liblua/loadlib.c rename to client/deps/liblua/loadlib.c diff --git a/client/liblua/lobject.c b/client/deps/liblua/lobject.c similarity index 100% rename from client/liblua/lobject.c rename to client/deps/liblua/lobject.c diff --git a/client/liblua/lobject.h b/client/deps/liblua/lobject.h similarity index 100% rename from client/liblua/lobject.h rename to client/deps/liblua/lobject.h diff --git a/client/liblua/lopcodes.c b/client/deps/liblua/lopcodes.c similarity index 100% rename from client/liblua/lopcodes.c rename to client/deps/liblua/lopcodes.c diff --git a/client/liblua/lopcodes.h b/client/deps/liblua/lopcodes.h similarity index 100% rename from client/liblua/lopcodes.h rename to client/deps/liblua/lopcodes.h diff --git a/client/liblua/loslib.c b/client/deps/liblua/loslib.c similarity index 100% rename from client/liblua/loslib.c rename to client/deps/liblua/loslib.c diff --git a/client/liblua/lparser.c b/client/deps/liblua/lparser.c similarity index 100% rename from client/liblua/lparser.c rename to client/deps/liblua/lparser.c diff --git a/client/liblua/lparser.h b/client/deps/liblua/lparser.h similarity index 100% rename from client/liblua/lparser.h rename to client/deps/liblua/lparser.h diff --git a/client/liblua/lstate.c b/client/deps/liblua/lstate.c similarity index 100% rename from client/liblua/lstate.c rename to client/deps/liblua/lstate.c diff --git a/client/liblua/lstate.h b/client/deps/liblua/lstate.h similarity index 100% rename from client/liblua/lstate.h rename to client/deps/liblua/lstate.h diff --git a/client/liblua/lstring.c b/client/deps/liblua/lstring.c similarity index 100% rename from client/liblua/lstring.c rename to client/deps/liblua/lstring.c diff --git a/client/liblua/lstring.h b/client/deps/liblua/lstring.h similarity index 100% rename from client/liblua/lstring.h rename to client/deps/liblua/lstring.h diff --git a/client/liblua/lstrlib.c b/client/deps/liblua/lstrlib.c similarity index 100% rename from client/liblua/lstrlib.c rename to client/deps/liblua/lstrlib.c diff --git a/client/liblua/ltable.c b/client/deps/liblua/ltable.c similarity index 100% rename from client/liblua/ltable.c rename to client/deps/liblua/ltable.c diff --git a/client/liblua/ltable.h b/client/deps/liblua/ltable.h similarity index 100% rename from client/liblua/ltable.h rename to client/deps/liblua/ltable.h diff --git a/client/liblua/ltablib.c b/client/deps/liblua/ltablib.c similarity index 100% rename from client/liblua/ltablib.c rename to client/deps/liblua/ltablib.c diff --git a/client/liblua/ltm.c b/client/deps/liblua/ltm.c similarity index 100% rename from client/liblua/ltm.c rename to client/deps/liblua/ltm.c diff --git a/client/liblua/ltm.h b/client/deps/liblua/ltm.h similarity index 100% rename from client/liblua/ltm.h rename to client/deps/liblua/ltm.h diff --git a/client/liblua/lua.c b/client/deps/liblua/lua.c similarity index 100% rename from client/liblua/lua.c rename to client/deps/liblua/lua.c diff --git a/client/liblua/lua.h b/client/deps/liblua/lua.h similarity index 100% rename from client/liblua/lua.h rename to client/deps/liblua/lua.h diff --git a/client/liblua/lua.hpp b/client/deps/liblua/lua.hpp similarity index 100% rename from client/liblua/lua.hpp rename to client/deps/liblua/lua.hpp diff --git a/client/liblua/luac.c b/client/deps/liblua/luac.c similarity index 100% rename from client/liblua/luac.c rename to client/deps/liblua/luac.c diff --git a/client/liblua/luaconf.h b/client/deps/liblua/luaconf.h similarity index 100% rename from client/liblua/luaconf.h rename to client/deps/liblua/luaconf.h diff --git a/client/liblua/lualib.h b/client/deps/liblua/lualib.h similarity index 100% rename from client/liblua/lualib.h rename to client/deps/liblua/lualib.h diff --git a/client/liblua/lundump.c b/client/deps/liblua/lundump.c similarity index 100% rename from client/liblua/lundump.c rename to client/deps/liblua/lundump.c diff --git a/client/liblua/lundump.h b/client/deps/liblua/lundump.h similarity index 100% rename from client/liblua/lundump.h rename to client/deps/liblua/lundump.h diff --git a/client/liblua/lvm.c b/client/deps/liblua/lvm.c similarity index 100% rename from client/liblua/lvm.c rename to client/deps/liblua/lvm.c diff --git a/client/liblua/lvm.h b/client/deps/liblua/lvm.h similarity index 100% rename from client/liblua/lvm.h rename to client/deps/liblua/lvm.h diff --git a/client/liblua/lzio.c b/client/deps/liblua/lzio.c similarity index 100% rename from client/liblua/lzio.c rename to client/deps/liblua/lzio.c diff --git a/client/liblua/lzio.h b/client/deps/liblua/lzio.h similarity index 100% rename from client/liblua/lzio.h rename to client/deps/liblua/lzio.h diff --git a/client/reveng/Makefile b/client/deps/reveng/Makefile similarity index 95% rename from client/reveng/Makefile rename to client/deps/reveng/Makefile index c29538fa5..17d63a4f9 100644 --- a/client/reveng/Makefile +++ b/client/deps/reveng/Makefile @@ -18,7 +18,7 @@ MYSRCS = \ LIB_A = libreveng.a -include ../../Makefile.host +include ../../../Makefile.host CLEAN += bmptst diff --git a/client/reveng/bmpbit.c b/client/deps/reveng/bmpbit.c similarity index 100% rename from client/reveng/bmpbit.c rename to client/deps/reveng/bmpbit.c diff --git a/client/reveng/cli.c b/client/deps/reveng/cli.c similarity index 100% rename from client/reveng/cli.c rename to client/deps/reveng/cli.c diff --git a/client/reveng/config.h b/client/deps/reveng/config.h similarity index 100% rename from client/reveng/config.h rename to client/deps/reveng/config.h diff --git a/client/reveng/getopt.c b/client/deps/reveng/getopt.c similarity index 100% rename from client/reveng/getopt.c rename to client/deps/reveng/getopt.c diff --git a/client/reveng/getopt.h b/client/deps/reveng/getopt.h similarity index 100% rename from client/reveng/getopt.h rename to client/deps/reveng/getopt.h diff --git a/client/reveng/model.c b/client/deps/reveng/model.c similarity index 100% rename from client/reveng/model.c rename to client/deps/reveng/model.c diff --git a/client/reveng/poly.c b/client/deps/reveng/poly.c similarity index 100% rename from client/reveng/poly.c rename to client/deps/reveng/poly.c diff --git a/client/reveng/preset.c b/client/deps/reveng/preset.c similarity index 100% rename from client/reveng/preset.c rename to client/deps/reveng/preset.c diff --git a/client/reveng/reveng.c b/client/deps/reveng/reveng.c similarity index 100% rename from client/reveng/reveng.c rename to client/deps/reveng/reveng.c diff --git a/client/reveng/reveng.h b/client/deps/reveng/reveng.h similarity index 100% rename from client/reveng/reveng.h rename to client/deps/reveng/reveng.h diff --git a/client/tinycbor/Makefile b/client/deps/tinycbor/Makefile similarity index 93% rename from client/tinycbor/Makefile rename to client/deps/tinycbor/Makefile index 6470246d4..376e2b641 100644 --- a/client/tinycbor/Makefile +++ b/client/deps/tinycbor/Makefile @@ -19,4 +19,4 @@ LIB_A = tinycbor.a # Strange errors on Mingw when compiling with -O3 CFLAGS ?= -Wall -Werror -O2 -include ../../Makefile.host +include ../../../Makefile.host diff --git a/client/tinycbor/cbor.h b/client/deps/tinycbor/cbor.h similarity index 100% rename from client/tinycbor/cbor.h rename to client/deps/tinycbor/cbor.h diff --git a/client/tinycbor/cborencoder.c b/client/deps/tinycbor/cborencoder.c similarity index 100% rename from client/tinycbor/cborencoder.c rename to client/deps/tinycbor/cborencoder.c diff --git a/client/tinycbor/cborencoder_close_container_checked.c b/client/deps/tinycbor/cborencoder_close_container_checked.c similarity index 100% rename from client/tinycbor/cborencoder_close_container_checked.c rename to client/deps/tinycbor/cborencoder_close_container_checked.c diff --git a/client/tinycbor/cborerrorstrings.c b/client/deps/tinycbor/cborerrorstrings.c similarity index 100% rename from client/tinycbor/cborerrorstrings.c rename to client/deps/tinycbor/cborerrorstrings.c diff --git a/client/tinycbor/cborinternal_p.h b/client/deps/tinycbor/cborinternal_p.h similarity index 100% rename from client/tinycbor/cborinternal_p.h rename to client/deps/tinycbor/cborinternal_p.h diff --git a/client/tinycbor/cborjson.h b/client/deps/tinycbor/cborjson.h similarity index 100% rename from client/tinycbor/cborjson.h rename to client/deps/tinycbor/cborjson.h diff --git a/client/tinycbor/cborparser.c b/client/deps/tinycbor/cborparser.c similarity index 100% rename from client/tinycbor/cborparser.c rename to client/deps/tinycbor/cborparser.c diff --git a/client/tinycbor/cborparser_dup_string.c b/client/deps/tinycbor/cborparser_dup_string.c similarity index 100% rename from client/tinycbor/cborparser_dup_string.c rename to client/deps/tinycbor/cborparser_dup_string.c diff --git a/client/tinycbor/cborpretty.c b/client/deps/tinycbor/cborpretty.c similarity index 100% rename from client/tinycbor/cborpretty.c rename to client/deps/tinycbor/cborpretty.c diff --git a/client/tinycbor/cborpretty_stdio.c b/client/deps/tinycbor/cborpretty_stdio.c similarity index 100% rename from client/tinycbor/cborpretty_stdio.c rename to client/deps/tinycbor/cborpretty_stdio.c diff --git a/client/tinycbor/cbortojson.c b/client/deps/tinycbor/cbortojson.c similarity index 100% rename from client/tinycbor/cbortojson.c rename to client/deps/tinycbor/cbortojson.c diff --git a/client/tinycbor/cborvalidation.c b/client/deps/tinycbor/cborvalidation.c similarity index 100% rename from client/tinycbor/cborvalidation.c rename to client/deps/tinycbor/cborvalidation.c diff --git a/client/tinycbor/compilersupport_p.h b/client/deps/tinycbor/compilersupport_p.h similarity index 100% rename from client/tinycbor/compilersupport_p.h rename to client/deps/tinycbor/compilersupport_p.h diff --git a/client/tinycbor/open_memstream.c b/client/deps/tinycbor/open_memstream.c similarity index 100% rename from client/tinycbor/open_memstream.c rename to client/deps/tinycbor/open_memstream.c diff --git a/client/tinycbor/tinycbor-version.h b/client/deps/tinycbor/tinycbor-version.h similarity index 100% rename from client/tinycbor/tinycbor-version.h rename to client/deps/tinycbor/tinycbor-version.h diff --git a/client/tinycbor/utf8_p.h b/client/deps/tinycbor/utf8_p.h similarity index 100% rename from client/tinycbor/utf8_p.h rename to client/deps/tinycbor/utf8_p.h diff --git a/client/emojis_scrap_github.py b/client/emojis_scrap_github.py index 4c102e644..1d808e13a 100755 --- a/client/emojis_scrap_github.py +++ b/client/emojis_scrap_github.py @@ -10,7 +10,7 @@ EMOJI_JSON_URL = 'https://raw.githubusercontent.com/github/gemoji/master/db/emoj def print_emoji(emoji_json): for alias in emoji_json['aliases']: - print(' {{":{0}:", "{1}"}}, // {2}'.format(alias, + print(' {{":{0}:", "{1}"}}, // {2}'.format(alias, ''.join('\\x{:02x}'.format(b) for b in emoji_json['emoji'].encode('utf8')), diff --git a/client/luascripts/hf_bruteforce.lua b/client/luascripts/hf_bruteforce.lua index a1ba34fad..1d3b00777 100644 --- a/client/luascripts/hf_bruteforce.lua +++ b/client/luascripts/hf_bruteforce.lua @@ -12,7 +12,7 @@ This script bruteforces 4 or 7 byte UID Mifare classic card numbers. ]] example =[[ Bruteforce a 4 byte UID Mifare classic card number, starting at 11223344, ending at 11223346. - + script run hf_bruteforce -s 0x11223344 -e 0x11223346 -t 1000 -x mfc Bruteforce a 7 byte UID Mifare Ultralight card number, starting at 11223344556677, ending at 11223344556679. @@ -26,9 +26,9 @@ arguments = [[ -h this help -s 0-0xFFFFFFFF start id -e 0-0xFFFFFFFF end id - -t 0-99999, pause timeout (ms) between cards + -t 0-99999, pause timeout (ms) between cards (use the word 'pause' to wait for user input) - -x mfc, mfu mifare type: + -x mfc, mfu mifare type: mfc for Mifare Classic (default) mfu for Mifare Ultralight EV1 ]] diff --git a/client/luascripts/hf_read.lua b/client/luascripts/hf_read.lua index 22234e116..7c70e37d9 100644 --- a/client/luascripts/hf_read.lua +++ b/client/luascripts/hf_read.lua @@ -59,7 +59,7 @@ local function main(args) for o, a in getopt.getopt(args, 'h') do if o == 'h' then return help() end end - + print("WORK IN PROGRESS - not expected to be functional yet") info, err = reader.waitForTag() diff --git a/client/luascripts/hf_writer.lua b/client/luascripts/hf_writer.lua index c1812902d..ef7c3969b 100644 --- a/client/luascripts/hf_writer.lua +++ b/client/luascripts/hf_writer.lua @@ -25,7 +25,7 @@ desc = [[ Works with both 4 and 7 bytes NXP MIFARE Classic 1K cards. The script also has the possibility to change UID and permanent lock uid on magic Gen3 cards. - + It supports the following functionality. 1. Write it to the same of current card UID. @@ -33,7 +33,7 @@ desc = [[ 3. Change uid to match dump on magic Gen3 card. 4. Permanent lock UID on magic Gen3 card. 5. Erase all data at the card and set the FF FF FF FF FF FF keys, and Access Conditions to 78778800. - + Script works in a wizard styled way. ]] example = [[ @@ -88,7 +88,7 @@ local function GetUID() return read14a.read(true, true).uid end --- --- +-- local function dropfield() read14a.disconnect() core.clearCommandBuffer() @@ -121,25 +121,25 @@ local function main(args) local length = 25 local e = 16 -- Detect 7 byte card - if string.len(GetUID()) == 14 then + if string.len(GetUID()) == 14 then length = 31 e = 22 - end + end dropfield() ---List all EML files in /client local dumpEML = "find '.' -iname '*dump.eml' -type f" - local p = assert(io.popen(dumpEML)) + local p = assert(io.popen(dumpEML)) for _ in p:lines() do - + -- The length of eml file - if string.len(_) == length then + if string.len(_) == length then num_dumps = num_dumps + 1 -- cut UID from eml file files[num_dumps] = string.sub(_, 9, e) print(' '..num_dumps..' | '..files[num_dumps]) end - end + end p.close() if num_dumps == 0 then return oops("Didn't find any dump files") end @@ -153,45 +153,45 @@ local function main(args) local no = tonumber(io.read()) print(tab) - print(' You have been selected card dump ' .. no .. ', with UID : '..files[no]) + print(' You have been selected card dump ' .. no .. ', with UID : '..files[no]) --- Load eml file local dumpfile = assert(io.open('./hf-mf-' .. files[no] .. '-dump.eml', 'r')) for _ in dumpfile:lines() do table.insert(eml, _); end dumpfile.close() - --- Extract B key from EML file + --- Extract B key from EML file local b = 0 for i = 1, #eml do if (i % 4 == 0) then repeat b = b + 1 -- Cut key from block - b_keys[b] = string.sub(eml[i], (#eml[i] - 11), #eml[i]) + b_keys[b] = string.sub(eml[i], (#eml[i] - 11), #eml[i]) until b % 4 == 0 end - end + end print(tab) dbg(b_keys) dbg(eml) - --- Change UID on certain version of magic Gen3 card. + --- Change UID on certain version of magic Gen3 card. if (utils.confirm(' Change UID ?') == true) then wait() --core.console('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1])) print('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1])) print(tab) print(' The new card UID : ' .. GetUID()) - end - print(tab) - + end + print(tab) + --- Lock UID if (utils.confirm(' Permanent lock UID ? (card can never change uid again) ') == true) then wait() core.console('hf 14a raw -s -c -t 2000 90fd111100') - end + end print(tab) - + --- Writing blocks local default_key = 'FFFFFFFFFFFF' local default_key_blk = 'FFFFFFFFFFFF78778800FFFFFFFFFFFF' diff --git a/client/luascripts/legic_clone.lua b/client/luascripts/legic_clone.lua index c27da3c08..0f03157e5 100644 --- a/client/luascripts/legic_clone.lua +++ b/client/luascripts/legic_clone.lua @@ -16,7 +16,7 @@ local ansicolors = require('ansicolors') 6. calculate new crc on each segment (needs to know the new MCD & MSN0..2) simplest usage: - Dump a legic tag with 'hf legic dump' + Dump a legic tag with 'hf legic dump' place your 'empty' tag on the reader and run 'script run legic_clone -i orig.bin -w' @@ -359,7 +359,7 @@ local function displaySegments(bytes) pld = '' Seg = getSegmentData(bytes, start, index) if Seg == nil then return OOps("segment is nil") end - + KGH = CheckKgh(bytes, start, (start + tonumber(Seg[4], 10))) printSegment(Seg) diff --git a/client/resources/aid_desfire.json b/client/resources/aid_desfire.json index c483b2145..4a9798067 100644 --- a/client/resources/aid_desfire.json +++ b/client/resources/aid_desfire.json @@ -120,6 +120,141 @@ FFFFFF General Issuer Information (FIDs 00: MAD Version; 01: Card Holder; 02: Card Publisher)", "Type": "transport" }, - + { + "AID": "F518F0", + "Vendor": "TELENOT", + "Country": "DE", + "Name": "TELENOT Tag", + "Description": "", + "Type": "alarm system" + }, + { + "AID": "F38091", + "Vendor": "MICROTRONIC", + "Country": "CH", + "Name": "MICROTRONIC Tag", + "Description": "", + "Type": "payment system" + }, -] + { + "AID": "F88280", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "F5217D", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "F48EF1", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535501", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535502", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535503", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535504", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535505", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535506", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535507", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535508", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "535509", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "53550A", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "53550B", + "Vendor": "TU Delft", + "Country": "NL", + "Name": "Uni Delft", + "Description": "", + "Type": "student" + }, + { + "AID": "F001D0", + "Vendor": "Arabako Foru Aldundia", + "Country": "", + "Name": "BAT", + "Description": "", + "Type": "transport" + }, +} diff --git a/client/aidsearch.c b/client/src/aidsearch.c similarity index 100% rename from client/aidsearch.c rename to client/src/aidsearch.c diff --git a/client/aidsearch.h b/client/src/aidsearch.h similarity index 100% rename from client/aidsearch.h rename to client/src/aidsearch.h diff --git a/client/cmdanalyse.c b/client/src/cmdanalyse.c similarity index 100% rename from client/cmdanalyse.c rename to client/src/cmdanalyse.c diff --git a/client/cmdanalyse.h b/client/src/cmdanalyse.h similarity index 100% rename from client/cmdanalyse.h rename to client/src/cmdanalyse.h diff --git a/client/cmdcrc.c b/client/src/cmdcrc.c similarity index 100% rename from client/cmdcrc.c rename to client/src/cmdcrc.c diff --git a/client/cmdcrc.h b/client/src/cmdcrc.h similarity index 100% rename from client/cmdcrc.h rename to client/src/cmdcrc.h diff --git a/client/cmddata.c b/client/src/cmddata.c similarity index 99% rename from client/cmddata.c rename to client/src/cmddata.c index 74c33da55..86cc91dfd 100644 --- a/client/cmddata.c +++ b/client/src/cmddata.c @@ -21,7 +21,7 @@ #include "graph.h" // for graph data #include "comms.h" #include "lfdemod.h" // for demod code -#include "loclass/cipherutils.h" // for decimating samples in getsamples +#include "../loclass/cipherutils.h" // for decimating samples in getsamples #include "cmdlfem4x.h" // askem410xdecode #include "fileutils.h" // searchFile #include "mifare/ndef.h" diff --git a/client/cmddata.h b/client/src/cmddata.h similarity index 100% rename from client/cmddata.h rename to client/src/cmddata.h diff --git a/client/cmdflashmem.c b/client/src/cmdflashmem.c similarity index 100% rename from client/cmdflashmem.c rename to client/src/cmdflashmem.c diff --git a/client/cmdflashmem.h b/client/src/cmdflashmem.h similarity index 100% rename from client/cmdflashmem.h rename to client/src/cmdflashmem.h diff --git a/client/cmdflashmemspiffs.c b/client/src/cmdflashmemspiffs.c similarity index 99% rename from client/cmdflashmemspiffs.c rename to client/src/cmdflashmemspiffs.c index 788851f1a..8ec0fe8e1 100644 --- a/client/cmdflashmemspiffs.c +++ b/client/src/cmdflashmemspiffs.c @@ -140,7 +140,7 @@ static int CmdFlashMemSpiFFSRemove(const char *Cmd) { static int CmdFlashMemSpiFFSRename(const char *Cmd) { - int len = strlen(Cmd); + int len = strlen(Cmd); if (len < 1) { return usage_flashmemspiffs_rename(); } @@ -149,7 +149,7 @@ static int CmdFlashMemSpiFFSRename(const char *Cmd) { if (len == 1 && ctmp == 'h') { return usage_flashmemspiffs_rename(); } - + char srcfilename[32] = {0}; char destfilename[32] = {0}; bool errors = false; @@ -195,7 +195,7 @@ static int CmdFlashMemSpiFFSCopy(const char *Cmd) { return usage_flashmemspiffs_copy(); } - + char srcfilename[32] = {0}; char destfilename[32] = {0}; bool errors = false; @@ -457,7 +457,8 @@ static int CmdFlashMemSpiFFSLoad(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash, + { + "copy", CmdFlashMemSpiFFSCopy, IfPm3Flash, "Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)" }, {"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"}, diff --git a/client/cmdflashmemspiffs.h b/client/src/cmdflashmemspiffs.h similarity index 100% rename from client/cmdflashmemspiffs.h rename to client/src/cmdflashmemspiffs.h diff --git a/client/cmdhf.c b/client/src/cmdhf.c similarity index 96% rename from client/cmdhf.c rename to client/src/cmdhf.c index 773ffe431..9ea34420a 100644 --- a/client/cmdhf.c +++ b/client/src/cmdhf.c @@ -39,7 +39,7 @@ #include "ui.h" #include "cmddata.h" #include "graph.h" -#include "../common_fpga/fpga.h" +#include "../../common_fpga/fpga.h" static int CmdHelp(const char *Cmd); @@ -86,8 +86,8 @@ int CmdHFSearch(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (cmdp == 'h') return usage_hf_search(); - int res = PM3_ESOFT; - + int res = PM3_ESOFT; + PROMPT_CLEARLINE; PrintAndLogEx(INPLACE, "Searching for ThinFilm tag..."); if (IfPm3NfcBarcode()) { @@ -150,17 +150,17 @@ int CmdHFSearch(const char *Cmd) { res = PM3_SUCCESS; } } -/* - // 14b and iclass is the longest test (put last) - PROMPT_CLEARLINE; - PrintAndLogEx(INPLACE, "Searching for CryptoRF tag..."); - if (IfPm3Iso14443b()) { - if (readHFCryptoRF(false) == PM3_SUCCESS) { - PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n"); - res = PM3_SUCCESS; + /* + // 14b and iclass is the longest test (put last) + PROMPT_CLEARLINE; + PrintAndLogEx(INPLACE, "Searching for CryptoRF tag..."); + if (IfPm3Iso14443b()) { + if (readHFCryptoRF(false) == PM3_SUCCESS) { + PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n"); + res = PM3_SUCCESS; + } } - } -*/ + */ // 14b and iclass is the longest test (put last) PROMPT_CLEARLINE; diff --git a/client/cmdhf.h b/client/src/cmdhf.h similarity index 100% rename from client/cmdhf.h rename to client/src/cmdhf.h diff --git a/client/cmdhf14a.c b/client/src/cmdhf14a.c similarity index 99% rename from client/cmdhf14a.c rename to client/src/cmdhf14a.c index 2e5fcb69e..029b354d2 100644 --- a/client/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1419,12 +1419,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { // Double & triple sized UID, can be mapped to a manufacturer. if (card.uidlen <= 4) { nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0])); - + isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC); isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE); isMifarePlus = ((nxptype & MTPLUS) == MTPLUS); isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT); - + if ((nxptype & MTOTHER) == MTOTHER) isMifareClassic = true; } @@ -1433,13 +1433,13 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { switch (card.uid[0]) { case 0x04: // NXP nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0])); - + isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC); isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE); isMifarePlus = ((nxptype & MTPLUS) == MTPLUS); isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT); - - if ((nxptype & MTOTHER) == MTOTHER) + + if ((nxptype & MTOTHER) == MTOTHER) isMifareClassic = true; break; diff --git a/client/cmdhf14a.h b/client/src/cmdhf14a.h similarity index 100% rename from client/cmdhf14a.h rename to client/src/cmdhf14a.h diff --git a/client/cmdhf14b.c b/client/src/cmdhf14b.c similarity index 100% rename from client/cmdhf14b.c rename to client/src/cmdhf14b.c diff --git a/client/cmdhf14b.h b/client/src/cmdhf14b.h similarity index 100% rename from client/cmdhf14b.h rename to client/src/cmdhf14b.h diff --git a/client/cmdhf15.c b/client/src/cmdhf15.c similarity index 96% rename from client/cmdhf15.c rename to client/src/cmdhf15.c index b6a601391..9762ba498 100644 --- a/client/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -29,7 +29,7 @@ #include "comms.h" // clearCommandBuffer #include "cmdtrace.h" #include "iso15693tools.h" -#include "crypto/libpcrypto.h" +#include "../crypto/libpcrypto.h" #include "graph.h" #include "crc16.h" // iso15 crc #include "cmddata.h" // getsamples @@ -212,8 +212,8 @@ static int CmdHF15Help(const char *Cmd); static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) { - #define PUBLIC_ECDA_KEYLEN 33 - const ecdsa_publickey_t nxp_15693_public_keys[] = { +#define PUBLIC_ECDA_KEYLEN 33 + const ecdsa_publickey_t nxp_15693_public_keys[] = { {"NXP Mifare Classic MFC1C14_x", "044F6D3F294DEA5737F0F46FFEE88A356EED95695DD7E0C27A591E6F6F65962BAF"}, {"Manufacturer Mifare Classic MFC1C14_x", "046F70AC557F5461CE5052C8E4A7838C11C7A236797E8A0730A101837C004039C2"}, {"NXP ICODE DNA, ICODE SLIX2", "048878A2A2D3EEC336B4F261A082BD71F9BE11C4E2E896648B32EFA59CEA6E59F0"}, @@ -222,55 +222,55 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) { {"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"}, {"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"}, }; -/* - uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = { - // ICODE SLIX2 / DNA - { - 0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3, - 0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71, - 0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64, - 0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0 - }, - // unknown. Needs identification - { - 0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57, - 0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35, - 0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2, - 0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF - }, - // unknown. Needs identification - { - 0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE, - 0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1, - 0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA, - 0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC - }, - // manufacturer public key - { - 0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61, - 0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C, - 0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07, - 0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2 - }, - // MIKRON public key. - { - 0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8, - 0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07, - 0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7, - 0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2 - } - }; -*/ + /* + uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = { + // ICODE SLIX2 / DNA + { + 0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3, + 0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71, + 0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64, + 0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0 + }, + // unknown. Needs identification + { + 0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57, + 0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35, + 0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2, + 0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF + }, + // unknown. Needs identification + { + 0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE, + 0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1, + 0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA, + 0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC + }, + // manufacturer public key + { + 0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61, + 0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C, + 0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07, + 0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2 + }, + // MIKRON public key. + { + 0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8, + 0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07, + 0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7, + 0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2 + } + }; + */ uint8_t i; int res; bool is_valid = false; - for (i = 0; i< ARRAYLEN(nxp_15693_public_keys); i++) { + for (i = 0; i < ARRAYLEN(nxp_15693_public_keys); i++) { int dl = 0; uint8_t key[PUBLIC_ECDA_KEYLEN]; - param_gethex_to_eol(nxp_15693_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl); - + param_gethex_to_eol(nxp_15693_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl); + res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 8, signature, 32, false); is_valid = (res == 0); if (is_valid) @@ -589,7 +589,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t return false; } memcpy(&req[tmpreqlen], uid, sizeof(uid)); - PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid)); tmpreqlen += sizeof(uid); break; default: @@ -602,7 +602,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t uid[7 - i] = temp & 0xff; } - PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid)); memcpy(&req[tmpreqlen], uid, sizeof(uid)); tmpreqlen += sizeof(uid); break; @@ -931,7 +931,7 @@ static int CmdHF15Info(const char *Cmd) { PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") "---------"); PrintAndLogEx(INFO, "-------------------------------------------------------------"); PrintAndLogEx(SUCCESS, " TYPE: " _YELLOW_("%s"), getTagInfo_15(recv + 2)); - PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL, uid)); PrintAndLogEx(SUCCESS, " SYSINFO: %s", sprint_hex(recv, status - 2)); // DSFID @@ -1003,7 +1003,7 @@ static int CmdHF15Sim(const char *Cmd) { return PM3_EINVARG; } - PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid)); clearCommandBuffer(); SendCommandOLD(CMD_HF_ISO15693_SIMULATE, 0, 0, 0, uid, 8); @@ -1201,7 +1201,7 @@ static int CmdHF15Dump(const char *Cmd) { } // detect blocksize from card :) - PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid)); int blocknum = 0; uint8_t *recv = NULL; @@ -1271,7 +1271,7 @@ static int CmdHF15Dump(const char *Cmd) { PrintAndLogEx(NORMAL, "\n"); size_t datalen = blocknum * 4; - saveFile(filename, ".bin", data, datalen); + saveFile(filename, ".bin", data, datalen); saveFileEML(filename, data, datalen, 4); saveFileJSON(filename, jsf15, data, datalen); return PM3_SUCCESS; @@ -1446,7 +1446,7 @@ static int CmdHF15Readmulti(const char *Cmd) { } // skip status byte - int start = 1; + int start = 1; int stop = (pagecount + 1) * 5; int currblock = pagenum; // print response @@ -1680,7 +1680,7 @@ static int CmdHF15Restore(const char *Cmd) { } if ((f = fopen(filename, "rb")) == NULL) { - + PrintAndLogEx(WARNING, "Could not find file %s", filename); return PM3_EFILE; } @@ -1762,7 +1762,7 @@ static int CmdHF15CSetUID(const char *Cmd) { return PM3_EINVARG; } - PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid)); + PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid)); if (!getUID(oldUid)) { PrintAndLogEx(FAILED, "Can't get old/current UID."); diff --git a/client/cmdhf15.h b/client/src/cmdhf15.h similarity index 100% rename from client/cmdhf15.h rename to client/src/cmdhf15.h diff --git a/client/cmdhfcryptorf.c b/client/src/cmdhfcryptorf.c similarity index 83% rename from client/cmdhfcryptorf.c rename to client/src/cmdhfcryptorf.c index c6d43ff46..559dc0e35 100644 --- a/client/cmdhfcryptorf.c +++ b/client/src/cmdhfcryptorf.c @@ -25,86 +25,86 @@ static int CmdHelp(const char *Cmd); static int usage_hf_cryptorf_info(void) { PrintAndLogEx(NORMAL, "Usage: hf cryptorf info [h] [v]\n" - "Options:\n" - " h this help\n" - " v verbose\n" - "\n" - "Example:\n" - _YELLOW_(" hf cryptorf info") - ); + "Options:\n" + " h this help\n" + " v verbose\n" + "\n" + "Example:\n" + _YELLOW_(" hf cryptorf info") + ); return PM3_SUCCESS; } static int usage_hf_cryptorf_reader(void) { PrintAndLogEx(NORMAL, "Usage: hf cryptorf reader [h] [v]\n" - "Options:\n" - " h this help\n" - " v verbose\n" - "\n" - "Example:\n" - _YELLOW_(" hf cryptorf reader") - ); + "Options:\n" + " h this help\n" + " v verbose\n" + "\n" + "Example:\n" + _YELLOW_(" hf cryptorf reader") + ); return PM3_SUCCESS; } static int usage_hf_cryptorf_sniff(void) { PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer\n" - "Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n" - "Usage: hf cryptorf sniff [h]\n" - "Options:\n" - " h this help\n" - "\n" - "Example:\n" - _YELLOW_(" hf cryptorf sniff") - ); + "Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n" + "Usage: hf cryptorf sniff [h]\n" + "Options:\n" + " h this help\n" + "\n" + "Example:\n" + _YELLOW_(" hf cryptorf sniff") + ); return PM3_SUCCESS; } static int usage_hf_cryptorf_sim(void) { PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with 4 UID / PUPI\n" - "Usage: hf cryptorf sim [h] [u ]\n" - "Options:\n" - " h this help\n" - " u 4byte UID/PUPI\n" - "\n" - "Example:\n" - _YELLOW_(" hf cryptorf sim") - ); + "Usage: hf cryptorf sim [h] [u ]\n" + "Options:\n" + " h this help\n" + " u 4byte UID/PUPI\n" + "\n" + "Example:\n" + _YELLOW_(" hf cryptorf sim") + ); return PM3_SUCCESS; } static int usage_hf_cryptorf_dump(void) { PrintAndLogEx(NORMAL, "This command dumps the contents of a ISO-14443-B tag and save it to file\n" - "\n" - "Usage: hf cryptorf dump [h] [card memory] \n" - "Options:\n" - " h this help\n" - " f filename, if no UID will be used as filename\n" - "\n" - "Examples:\n" - "\thf cryptorf dump\n" - "\thf cryptorf dump f mydump"); + "\n" + "Usage: hf cryptorf dump [h] [card memory] \n" + "Options:\n" + " h this help\n" + " f filename, if no UID will be used as filename\n" + "\n" + "Examples:\n" + "\thf cryptorf dump\n" + "\thf cryptorf dump f mydump"); return PM3_SUCCESS; } static int usage_hf_cryptorf_eload(void) { PrintAndLogEx(NORMAL, "It loads a binary dump into emulator memory\n" - "Usage: hf cryptorf eload [f ]\n" - "Options:\n" - " h this help\n" - " f filename, if no UID will be used as filename\n" - "\n" - "Examples:\n" - _YELLOW_(" hf cryptorf eload f filename") - ); + "Usage: hf cryptorf eload [f ]\n" + "Options:\n" + " h this help\n" + " f filename, if no UID will be used as filename\n" + "\n" + "Examples:\n" + _YELLOW_(" hf cryptorf eload f filename") + ); return PM3_SUCCESS; } static int usage_hf_cryptorf_esave(void) { PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n" - " Usage: hf cryptorf esave [f ]\n" - "Options:\n" - " h this help\n" - " f filename, if no UID will be used as filename\n" - "\n" - "Examples:\n" - _YELLOW_(" hf cryptorf esave ") - _YELLOW_(" hf cryptorf esave f filename") - ); + " Usage: hf cryptorf esave [f ]\n" + "Options:\n" + " h this help\n" + " f filename, if no UID will be used as filename\n" + "\n" + "Examples:\n" + _YELLOW_(" hf cryptorf esave ") + _YELLOW_(" hf cryptorf esave f filename") + ); return PM3_SUCCESS; } @@ -379,7 +379,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) { case 'h' : return usage_hf_cryptorf_eload(); case 'f' : - if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) { + if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) { PrintAndLogEx(FAILED, "Filename too long"); errors = true; break; @@ -414,26 +414,26 @@ static int CmdHFCryptoRFELoad(const char *Cmd) { PrintAndLogEx(SUCCESS, "Uploading to emulator memory"); -/* - // fast push mode - conn.block_after_ACK = true; + /* + // fast push mode + conn.block_after_ACK = true; - //Send to device - uint32_t bytes_sent = 0; - uint32_t bytes_remaining = bytes_read; + //Send to device + uint32_t bytes_sent = 0; + uint32_t bytes_remaining = bytes_read; - while (bytes_remaining > 0) { - uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining); - if (bytes_in_packet == bytes_remaining) { - // Disable fast mode on last packet - conn.block_after_ACK = false; + while (bytes_remaining > 0) { + uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining); + if (bytes_in_packet == bytes_remaining) { + // Disable fast mode on last packet + conn.block_after_ACK = false; + } + clearCommandBuffer(); + SendCommandOLD(CMD_HF_CRYPTORF_EML_MEMSET, bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet); + bytes_remaining -= bytes_in_packet; + bytes_sent += bytes_in_packet; } - clearCommandBuffer(); - SendCommandOLD(CMD_HF_CRYPTORF_EML_MEMSET, bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet); - bytes_remaining -= bytes_in_packet; - bytes_sent += bytes_in_packet; - } -*/ + */ free(data); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, "Done"); @@ -524,10 +524,10 @@ int CmdHFCryptoRF(const char *Cmd) { return CmdsParse(CommandTable, Cmd); } -// Print extented information about tag. +// Print extented information about tag. int infoHFCryptoRF(bool verbose) { - - int res = PM3_ESOFT; + + int res = PM3_ESOFT; // 14b get and print UID only (general info) clearCommandBuffer(); diff --git a/client/cmdhfcryptorf.h b/client/src/cmdhfcryptorf.h similarity index 100% rename from client/cmdhfcryptorf.h rename to client/src/cmdhfcryptorf.h diff --git a/client/cmdhfepa.c b/client/src/cmdhfepa.c similarity index 100% rename from client/cmdhfepa.c rename to client/src/cmdhfepa.c diff --git a/client/cmdhfepa.h b/client/src/cmdhfepa.h similarity index 100% rename from client/cmdhfepa.h rename to client/src/cmdhfepa.h diff --git a/client/cmdhffelica.c b/client/src/cmdhffelica.c similarity index 100% rename from client/cmdhffelica.c rename to client/src/cmdhffelica.c diff --git a/client/cmdhffelica.h b/client/src/cmdhffelica.h similarity index 100% rename from client/cmdhffelica.h rename to client/src/cmdhffelica.h diff --git a/client/cmdhffido.c b/client/src/cmdhffido.c similarity index 99% rename from client/cmdhffido.c rename to client/src/cmdhffido.c index a0a8793c0..e6f89790a 100644 --- a/client/cmdhffido.c +++ b/client/src/cmdhffido.c @@ -31,8 +31,8 @@ #include "emv/emvcore.h" #include "emv/emvjson.h" #include "cliparser/cliparser.h" -#include "crypto/asn1utils.h" -#include "crypto/libpcrypto.h" +#include "../crypto/asn1utils.h" +#include "../crypto/libpcrypto.h" #include "fido/cbortools.h" #include "fido/fidocore.h" #include "emv/dump.h" diff --git a/client/cmdhffido.h b/client/src/cmdhffido.h similarity index 100% rename from client/cmdhffido.h rename to client/src/cmdhffido.h diff --git a/client/cmdhficlass.c b/client/src/cmdhficlass.c similarity index 99% rename from client/cmdhficlass.c rename to client/src/cmdhficlass.c index 8d82ed32c..73163e1ea 100644 --- a/client/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -19,10 +19,10 @@ #include "util_posix.h" #include "comms.h" #include "mbedtls/des.h" -#include "loclass/cipherutils.h" -#include "loclass/cipher.h" -#include "loclass/ikeys.h" -#include "loclass/elite_crack.h" +#include "../loclass/cipherutils.h" +#include "../loclass/cipher.h" +#include "../loclass/ikeys.h" +#include "../loclass/elite_crack.h" #include "fileutils.h" #include "protocols.h" #include "cardhelper.h" @@ -580,7 +580,7 @@ static int CmdHFiClassSim(const char *Cmd) { } uint8_t num_mac = resp.oldarg[1]; bool success = (NUM_CSNS == num_mac); - PrintAndLogEx( (success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL"); + PrintAndLogEx((success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL"); if (num_mac == 0) break; @@ -939,7 +939,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) { if (aa1_encryption == RFU || aa1_encryption == None) continue; - + // Decrypted block 7,8,9 if configured. if (blocknum > 6 && blocknum <= 6 + numblocks4userid && memcmp(enc_data, empty, 8) != 0) { if (use_sc) { @@ -1329,7 +1329,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) { break; } // dump cmd switch off at device when finised. - + uint32_t blocksRead = resp.oldarg[1]; uint8_t isOK = resp.oldarg[0] & 0xff; if (!isOK && !blocksRead) { @@ -2009,11 +2009,11 @@ static int CmdHFiClassReadTagFile(const char *Cmd) { case 'e': endblock = param_get8ex(Cmd, cmdp + 1, 0, 10); cmdp += 2; - break; + break; case 'v': verbose = true; cmdp++; - break; + break; default: PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, cmdp)); errors = true; @@ -2047,7 +2047,7 @@ static int CmdHFiClassReadTagFile(const char *Cmd) { } size_t bytes_read = fread(dump, 1, fsize, f); fclose(f); - + if (verbose) { PrintAndLogEx(INFO, "File: " _YELLOW_("%s"), filename); PrintAndLogEx(INFO, "File size %zu bytes, file blocks %d (0x%x)", bytes_read, (uint16_t)(bytes_read >> 3), (uint16_t)(bytes_read >> 3)); diff --git a/client/cmdhficlass.h b/client/src/cmdhficlass.h similarity index 100% rename from client/cmdhficlass.h rename to client/src/cmdhficlass.h diff --git a/client/cmdhflegic.c b/client/src/cmdhflegic.c similarity index 99% rename from client/cmdhflegic.c rename to client/src/cmdhflegic.c index 5c007f9f9..04bd692aa 100644 --- a/client/cmdhflegic.c +++ b/client/src/cmdhflegic.c @@ -185,7 +185,7 @@ static bool legic_xor(uint8_t *data, uint16_t cardsize) { } - for(uint16_t i = 22; i < cardsize; i++) { + for (uint16_t i = 22; i < cardsize; i++) { data[i] ^= crc; } PrintAndLogEx(SUCCESS, "(De)Obsfuscation done"); @@ -241,7 +241,7 @@ static int CmdLegicInfo(const char *Cmd) { PrintAndLogEx(NORMAL, "------------------------------------------------------"); PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)", data[0], - sprint_hex(data +1, 3), + sprint_hex(data + 1, 3), data[4], (calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail") ); @@ -667,7 +667,7 @@ static int CmdLegicWrbl(const char *Cmd) { PrintAndLogEx(WARNING, "Out-of-bounds, bytes 0-1-2-3-4 can't be written to. Offset = %d", offset); return PM3_EOUTOFBOUND; } - + //Validations if (errors || cmdp == 0) { if (data) @@ -1088,7 +1088,7 @@ static int CmdLegicRestore(const char *Cmd) { return PM3_EFILE; } - if (shall_obsfuscate){ + if (shall_obsfuscate) { legic_xor(data, card.cardsize); } diff --git a/client/cmdhflegic.h b/client/src/cmdhflegic.h similarity index 100% rename from client/cmdhflegic.h rename to client/src/cmdhflegic.h diff --git a/client/cmdhflist.c b/client/src/cmdhflist.c similarity index 100% rename from client/cmdhflist.c rename to client/src/cmdhflist.c diff --git a/client/cmdhflist.h b/client/src/cmdhflist.h similarity index 100% rename from client/cmdhflist.h rename to client/src/cmdhflist.h diff --git a/client/cmdhflto.c b/client/src/cmdhflto.c similarity index 100% rename from client/cmdhflto.c rename to client/src/cmdhflto.c diff --git a/client/cmdhflto.h b/client/src/cmdhflto.h similarity index 100% rename from client/cmdhflto.h rename to client/src/cmdhflto.h diff --git a/client/cmdhfmf.c b/client/src/cmdhfmf.c similarity index 99% rename from client/cmdhfmf.c rename to client/src/cmdhfmf.c index 8d2614ea7..44e56351b 100644 --- a/client/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -25,6 +25,7 @@ #include "mifare/ndef.h" #include "protocols.h" #include "util_posix.h" // msclock +#include "cmdhfmfhard.h" #define MFBLOCK_SIZE 16 diff --git a/client/cmdhfmf.h b/client/src/cmdhfmf.h similarity index 100% rename from client/cmdhfmf.h rename to client/src/cmdhfmf.h diff --git a/client/cmdhfmfdes.c b/client/src/cmdhfmfdes.c similarity index 99% rename from client/cmdhfmfdes.c rename to client/src/cmdhfmfdes.c index 944dfe438..d02c1ddfa 100644 --- a/client/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -20,7 +20,7 @@ #include "cmdhf14a.h" #include "mbedtls/des.h" #include "mbedtls/aes.h" -#include "crypto/libpcrypto.h" +#include "../crypto/libpcrypto.h" #include "protocols.h" #include "mifare.h" // desfire raw command options #include "cmdtrace.h" diff --git a/client/cmdhfmfdes.h b/client/src/cmdhfmfdes.h similarity index 100% rename from client/cmdhfmfdes.h rename to client/src/cmdhfmfdes.h diff --git a/client/cmdhfmfdesfire_disabled.c b/client/src/cmdhfmfdesfire_disabled.c similarity index 100% rename from client/cmdhfmfdesfire_disabled.c rename to client/src/cmdhfmfdesfire_disabled.c diff --git a/client/cmdhfmfdesfire_disabled.h b/client/src/cmdhfmfdesfire_disabled.h similarity index 100% rename from client/cmdhfmfdesfire_disabled.h rename to client/src/cmdhfmfdesfire_disabled.h diff --git a/client/cmdhfmfhard.c b/client/src/cmdhfmfhard.c similarity index 99% rename from client/cmdhfmfhard.c rename to client/src/cmdhfmfhard.c index 9f6c458ae..85e91ac64 100644 --- a/client/cmdhfmfhard.c +++ b/client/src/cmdhfmfhard.c @@ -16,7 +16,6 @@ //----------------------------------------------------------------------------- #include "cmdhfmfhard.h" - #include #include #include @@ -33,6 +32,7 @@ #include "util_posix.h" #include "crapto1/crapto1.h" #include "parity.h" +#include "hardnested/hardnested_bruteforce.h" #include "hardnested/hardnested_bf_core.h" #include "hardnested/hardnested_bitarray_core.h" #include "zlib.h" diff --git a/client/cmdhfmfhard.h b/client/src/cmdhfmfhard.h similarity index 58% rename from client/cmdhfmfhard.h rename to client/src/cmdhfmfhard.h index d86a2005a..6761626b2 100644 --- a/client/cmdhfmfhard.h +++ b/client/src/cmdhfmfhard.h @@ -13,33 +13,6 @@ #include "common.h" -#define NUM_SUMS 19 // number of possible sum property values - -typedef struct guess_sum_a8 { - float prob; - uint64_t num_states; - uint8_t sum_a8_idx; -} guess_sum_a8_t; - -typedef struct noncelistentry { - uint32_t nonce_enc; - uint8_t par_enc; - void *next; -} noncelistentry_t; - -typedef struct noncelist { - uint16_t num; - uint16_t Sum; - guess_sum_a8_t sum_a8_guess[NUM_SUMS]; - bool sum_a8_guess_dirty; - float expected_num_brute_force; - uint8_t BitFlips[0x400]; - uint32_t *states_bitarray[2]; - uint32_t num_states_bitarray[2]; - bool all_bitflips_dirty[2]; - noncelistentry_t *first; -} noncelist_t; - int mfnestedhard(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *trgkey, bool nonce_file_read, bool nonce_file_write, bool slow, int tests, uint64_t *foundkey, char *filename); void hardnested_print_progress(uint32_t nonces, const char *activity, float brute_force, uint64_t min_diff_print_time); diff --git a/client/cmdhfmfp.c b/client/src/cmdhfmfp.c similarity index 99% rename from client/cmdhfmfp.c rename to client/src/cmdhfmfp.c index e85f0861a..91418b191 100644 --- a/client/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -25,7 +25,7 @@ #include "util_posix.h" #include "fileutils.h" #include "protocols.h" -#include "crypto/libpcrypto.h" +#include "../crypto/libpcrypto.h" static const uint8_t DefaultKey[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; uint16_t CardAddresses[] = {0x9000, 0x9001, 0x9002, 0x9003, 0x9004, 0xA000, 0xA001, 0xA080, 0xA081, 0xC000, 0xC001}; @@ -72,7 +72,7 @@ static char *getProtocolStr(uint8_t id, bool hw) { if (id == 0x04) { sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3 MIFARE, 14443-4") ")", id); } else if (id == 0x05) { - if (hw) + if (hw) sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-2, 14443-3") ")", id); else sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3, 14443-4") ")", id); @@ -109,9 +109,9 @@ static char *getTypeStr(uint8_t type) { static char buf[40] = {0x00}; char *retStr = buf; - + switch (type) { - case 1: + case 1: sprintf(retStr, "0x%02X ( " _YELLOW_("DESFire") ")", type); break; case 2: @@ -130,17 +130,17 @@ static char *getTypeStr(uint8_t type) { } static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) { - + // DESFire MF3ICD40 - if (major == 0x00 && minor == 0x00 ) + if (major == 0x00 && minor == 0x00) return DESFIRE_MF3ICD40; - + // DESFire EV1 - if (major == 0x01 && minor == 0x00 ) + if (major == 0x01 && minor == 0x00) return DESFIRE_EV1; // DESFire EV2 - if (major == 0x12 && minor == 0x00 ) + if (major == 0x12 && minor == 0x00) return DESFIRE_EV2; // DESFire EV3 @@ -148,11 +148,11 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) { // return DESFIRE_EV3; // DESFire Light - if (major == 0x30 && minor == 0x00 ) + if (major == 0x30 && minor == 0x00) return DESFIRE_LIGHT; // Plus EV1 - if (major == 0x11 && minor == 0x00 ) + if (major == 0x11 && minor == 0x00) return PLUS_EV1; return MFP_UNKNOWN; @@ -162,7 +162,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) { static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) { // ref: MIFARE Plus EV1 Originality Signature Validation - #define PUBLIC_PLUS_ECDA_KEYLEN 57 +#define PUBLIC_PLUS_ECDA_KEYLEN 57 const ecdsa_publickey_t nxp_plus_public_keys[] = { {"Mifare Plus EV1", "044409ADC42F91A8394066BA83D872FB1D16803734E911170412DDF8BAD1A4DADFD0416291AFE1C748253925DA39A5F39A1C557FFACD34C62E"} }; @@ -185,7 +185,7 @@ static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("Tag Signature")); - + if (is_valid == false) { PrintAndLogEx(SUCCESS, "Signature verification " _RED_("failed")); return PM3_ESOFT; @@ -212,7 +212,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) { uint8_t data[59] = {0}; int resplen = 0, retval = PM3_SUCCESS; MFPGetSignature(true, false, data, sizeof(data), &resplen); - + if (resplen == 59) { memcpy(signature, data + 1, 56); *signature_len = 56; @@ -227,7 +227,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) { static int plus_print_version(uint8_t *version) { PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(version + 14, 7)); PrintAndLogEx(SUCCESS, " Batch number: " _GREEN_("%s"), sprint_hex(version + 21, 5)); - PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7+7+7+5], version[7+7+7+5+1]); + PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7 + 7 + 7 + 5], version[7 + 7 + 7 + 5 + 1]); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information")); PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(version[0])); @@ -247,7 +247,7 @@ static int plus_print_version(uint8_t *version) { return PM3_SUCCESS; } static int get_plus_version(uint8_t *version, int *version_len) { - + int resplen = 0, retval = PM3_SUCCESS; mfpSetVerboseMode(false); MFPGetVersion(true, false, version, *version_len, &resplen); @@ -282,7 +282,7 @@ static int CmdHFMFPInfo(const char *Cmd) { // info about 14a part infoHF14A(false, false, false); } - + // Mifare Plus info SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; @@ -310,7 +310,7 @@ static int CmdHFMFPInfo(const char *Cmd) { if (supportVersion) { int cardtype = getCardType(version[3], version[4]); - + if (cardtype == 6) { if (supportSignature) { PrintAndLogEx(INFO, " Tech: " _GREEN_("MIFARE Plus EV1")); @@ -319,7 +319,7 @@ static int CmdHFMFPInfo(const char *Cmd) { } isPlus = true; } else { - + } } @@ -374,7 +374,7 @@ static int CmdHFMFPInfo(const char *Cmd) { PrintAndLogEx(INFO, "ICEE: %s", sprint_hex(data, datalen)); if (memcmp(data, "\x67\x00", 2) == 0) { - PrintAndLogEx(INFO, "\tMost likely a MIFARE DESFire tag"); + PrintAndLogEx(INFO, "\tMost likely a MIFARE DESFire tag"); PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`hf mfdes info`")); DropField(); return PM3_SUCCESS; @@ -390,11 +390,11 @@ static int CmdHFMFPInfo(const char *Cmd) { // How do we detect SL0 / SL1 / SL2 / SL3 modes?!? PrintAndLogEx(INFO, "--- " _CYAN_("Security Level (SL)")); - if (SLmode != 0xFF ) + if (SLmode != 0xFF) PrintAndLogEx(SUCCESS, " SL mode: " _YELLOW_("SL%d"), SLmode); else PrintAndLogEx(WARNING, " SL mode: " _YELLOW_("unknown")); - switch(SLmode) { + switch (SLmode) { case 0: PrintAndLogEx(INFO, " SL 0: initial delivery configuration, used for card personalization"); break; diff --git a/client/cmdhfmfp.h b/client/src/cmdhfmfp.h similarity index 100% rename from client/cmdhfmfp.h rename to client/src/cmdhfmfp.h diff --git a/client/cmdhfmfu.c b/client/src/cmdhfmfu.c similarity index 97% rename from client/cmdhfmfu.c rename to client/src/cmdhfmfu.c index 2513f7122..fcac8d137 100644 --- a/client/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -11,7 +11,7 @@ #include #include "cmdparser.h" #include "commonutil.h" -#include "crypto/libpcrypto.h" +#include "../crypto/libpcrypto.h" #include "mbedtls/des.h" #include "cmdhfmf.h" #include "cmdhf14a.h" @@ -64,7 +64,7 @@ static int usage_hf_mfu_info(void) { static int usage_hf_mfu_dump(void) { PrintAndLogEx(NORMAL, "Reads all pages from Ultralight, Ultralight-C, Ultralight EV1"); PrintAndLogEx(NORMAL, "NTAG 203, NTAG 210, NTAG 212, NTAG 213, NTAG 215, NTAG 216"); - PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`") ); + PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`")); PrintAndLogEx(NORMAL, "It autodetects card type.\n"); PrintAndLogEx(NORMAL, "Usage: hf mfu dump k l f p q <#pages>"); PrintAndLogEx(NORMAL, " Options :"); @@ -89,8 +89,8 @@ static int usage_hf_mfu_restore(void) { PrintAndLogEx(NORMAL, " Options :"); PrintAndLogEx(NORMAL, " k : (optional) key for authentication [UL-C 16bytes, EV1/NTAG 4bytes]"); PrintAndLogEx(NORMAL, " l : (optional) swap entered key's endianness"); - PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-") ); - PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-") ); + PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-")); + PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-")); PrintAndLogEx(NORMAL, " r : (optional) use the password found in dumpfile to configure tag. requires " _YELLOW_("'e'") "parameter to work"); PrintAndLogEx(NORMAL, " f : " _YELLOW_("filename w .bin") "to restore"); PrintAndLogEx(NORMAL, ""); @@ -135,7 +135,7 @@ static int usage_hf_mfu_wrbl(void) { } static int usage_hf_mfu_eload(void) { - PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`") ); + PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`")); PrintAndLogEx(NORMAL, "Hint: See " _YELLOW_("`script run dumptoemul-mfu`") "to convert the .bin to the eml"); PrintAndLogEx(NORMAL, "Usage: hf mfu eload u [numblocks]"); PrintAndLogEx(NORMAL, " Options:"); @@ -526,7 +526,7 @@ static int ul_print_default(uint8_t *data) { else PrintAndLogEx(NORMAL, " BCC1: %02X, crc should be %02X", data[8], crc1); - PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default") ); + PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default")); PrintAndLogEx(SUCCESS, " Lock: %s - %s", sprint_hex(data + 10, 2), @@ -545,7 +545,7 @@ static int ndef_get_maxsize(uint8_t *data) { // no NDEF message if (data[0] != 0xE1) return 0; - + if (data[2] == 0x06) return 48; else if (data[2] == 0x12) @@ -865,7 +865,7 @@ static int ulev1_print_counters() { static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *signature, size_t signature_len) { - #define PUBLIC_ECDA_KEYLEN 33 +#define PUBLIC_ECDA_KEYLEN 33 // known public keys for the originality check (source: https://github.com/alexbatalov/node-nxp-originality-verifier) // ref: AN11350 NTAG 21x Originality Signature Validation // ref: AN11341 MIFARE Ultralight EV1 Originality Signature Validation @@ -878,64 +878,64 @@ static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *sig {"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"}, {"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"}, }; - -/* - uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = { - // UL, NTAG21x and NDEF - { - 0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c, - 0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49, - 0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39, - 0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61 - }, - // UL EV1 - { - 0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b, - 0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8, - 0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72, - 0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8 - }, - // unknown. Needs identification - { - 0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57, - 0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35, - 0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2, - 0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF - }, - // unknown. Needs identification - { - 0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE, - 0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1, - 0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA, - 0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC - }, - // manufacturer public key - { - 0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61, - 0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C, - 0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07, - 0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2 - }, - // MIKRON public key. - { - 0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8, - 0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07, - 0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7, - 0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2 - } - }; -*/ + + /* + uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = { + // UL, NTAG21x and NDEF + { + 0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c, + 0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49, + 0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39, + 0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61 + }, + // UL EV1 + { + 0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b, + 0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8, + 0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72, + 0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8 + }, + // unknown. Needs identification + { + 0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57, + 0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35, + 0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2, + 0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF + }, + // unknown. Needs identification + { + 0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE, + 0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1, + 0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA, + 0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC + }, + // manufacturer public key + { + 0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61, + 0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C, + 0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07, + 0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2 + }, + // MIKRON public key. + { + 0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8, + 0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07, + 0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7, + 0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2 + } + }; + */ uint8_t i; int res; bool is_valid = false; - for (i = 0; i< ARRAYLEN(nxp_mfu_public_keys); i++) { + for (i = 0; i < ARRAYLEN(nxp_mfu_public_keys); i++) { int dl = 0; uint8_t key[PUBLIC_ECDA_KEYLEN]; param_gethex_to_eol(nxp_mfu_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl); - + res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 7, signature, signature_len, false); - + is_valid = (res == 0); if (is_valid) break; @@ -2721,7 +2721,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) { uint8_t key[16] = {0x00}; uint8_t *p_key = key; uint8_t pack[4] = {0, 0, 0, 0}; - + CLIParserInit("hf mfu ndef", "Prints NFC Data Exchange Format (NDEF)", "Usage:\n\thf mfu ndef -> shows NDEF data\n" @@ -2737,8 +2737,8 @@ static int CmdHF14MfuNDEF(const char *Cmd) { CLIGetHexWithReturn(1, key, &keylen); swapEndian = arg_get_lit(2); CLIParserFree(); - - switch(keylen) { + + switch (keylen) { case 0: break; case 4: @@ -2758,13 +2758,13 @@ static int CmdHF14MfuNDEF(const char *Cmd) { } // Is tag UL/NTAG? - + // Swap endianness if (swapEndian && hasAuthKey) p_key = SwapEndian64(key, keylen, (keylen == 16) ? 8 : 4); // Select and Auth if (ul_auth_select(&card, tagtype, hasAuthKey, p_key, pack, sizeof(pack)) == PM3_ESOFT) return PM3_ESOFT; - + // read pages 0,1,2,3 (should read 4pages) status = ul_read(0, data, sizeof(data)); if (status == -1) { @@ -2783,20 +2783,20 @@ static int CmdHF14MfuNDEF(const char *Cmd) { // max datasize; maxsize = ndef_get_maxsize(data + 12); } - + // iceman: maybe always take MIN of tag identified size vs NDEF reported size? // fix: UL_EV1 48bytes != NDEF reported size for (uint8_t i = 0; i < ARRAYLEN(UL_TYPES_ARRAY); i++) { if (tagtype & UL_TYPES_ARRAY[i]) { - - if (maxsize != (UL_MEMORY_ARRAY[i] * 4) ) { + + if (maxsize != (UL_MEMORY_ARRAY[i] * 4)) { PrintAndLogEx(INFO, "Tag reported size vs NDEF reported size mismatch. Using smallest value"); } maxsize = MIN(maxsize, (UL_MEMORY_ARRAY[i] * 4)); break; } } - + // allocate mem uint8_t *records = calloc(maxsize, sizeof(uint8_t)); if (records == NULL) { @@ -2805,7 +2805,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) { } // read NDEF records. - for(uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) { + for (uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) { status = ul_read(4 + j, records + i, 16); if (status == -1) { DropField(); diff --git a/client/cmdhfmfu.h b/client/src/cmdhfmfu.h similarity index 100% rename from client/cmdhfmfu.h rename to client/src/cmdhfmfu.h diff --git a/client/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c similarity index 100% rename from client/cmdhfthinfilm.c rename to client/src/cmdhfthinfilm.c diff --git a/client/cmdhfthinfilm.h b/client/src/cmdhfthinfilm.h similarity index 100% rename from client/cmdhfthinfilm.h rename to client/src/cmdhfthinfilm.h diff --git a/client/cmdhftopaz.c b/client/src/cmdhftopaz.c similarity index 99% rename from client/cmdhftopaz.c rename to client/src/cmdhftopaz.c index 48a46cc2c..ea6b7da1d 100644 --- a/client/cmdhftopaz.c +++ b/client/src/cmdhftopaz.c @@ -514,7 +514,7 @@ int readTopazUid(bool verbose) { uint8_t rid_response[8]; uint8_t *uid_echo = &rid_response[2]; uint8_t rall_response[124]; - + int status = topaz_select(atqa, sizeof(atqa), rid_response, sizeof(rid_response), verbose); if (status == PM3_ESOFT) { if (verbose) PrintAndLogEx(ERR, "Error: couldn't receive ATQA"); @@ -543,7 +543,7 @@ int readTopazUid(bool verbose) { memcpy(topaz_tag.uid, rall_response + 2, 7); memcpy(topaz_tag.data_blocks, rall_response + 2, 0x0f * 8); - // printing + // printing PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, "UID : %02x %02x %02x %02x %02x %02x %02x", topaz_tag.uid[6], @@ -557,7 +557,7 @@ int readTopazUid(bool verbose) { PrintAndLogEx(SUCCESS, " UID[6] (Manufacturer Byte) = " _YELLOW_("%02x")", Manufacturer: " _YELLOW_("%s"), topaz_tag.uid[6], getTagInfo(topaz_tag.uid[6]) - ); + ); PrintAndLogEx(SUCCESS, "ATQA : %02x %02x", atqa[1], atqa[0]); diff --git a/client/cmdhftopaz.h b/client/src/cmdhftopaz.h similarity index 100% rename from client/cmdhftopaz.h rename to client/src/cmdhftopaz.h diff --git a/client/cmdhw.c b/client/src/cmdhw.c similarity index 100% rename from client/cmdhw.c rename to client/src/cmdhw.c diff --git a/client/cmdhw.h b/client/src/cmdhw.h similarity index 100% rename from client/cmdhw.h rename to client/src/cmdhw.h diff --git a/client/cmdlf.c b/client/src/cmdlf.c similarity index 100% rename from client/cmdlf.c rename to client/src/cmdlf.c diff --git a/client/cmdlf.h b/client/src/cmdlf.h similarity index 100% rename from client/cmdlf.h rename to client/src/cmdlf.h diff --git a/client/cmdlfawid.c b/client/src/cmdlfawid.c similarity index 100% rename from client/cmdlfawid.c rename to client/src/cmdlfawid.c diff --git a/client/cmdlfawid.h b/client/src/cmdlfawid.h similarity index 100% rename from client/cmdlfawid.h rename to client/src/cmdlfawid.h diff --git a/client/cmdlfcotag.c b/client/src/cmdlfcotag.c similarity index 100% rename from client/cmdlfcotag.c rename to client/src/cmdlfcotag.c diff --git a/client/cmdlfcotag.h b/client/src/cmdlfcotag.h similarity index 100% rename from client/cmdlfcotag.h rename to client/src/cmdlfcotag.h diff --git a/client/cmdlfem4x.c b/client/src/cmdlfem4x.c similarity index 100% rename from client/cmdlfem4x.c rename to client/src/cmdlfem4x.c diff --git a/client/cmdlfem4x.h b/client/src/cmdlfem4x.h similarity index 100% rename from client/cmdlfem4x.h rename to client/src/cmdlfem4x.h diff --git a/client/cmdlffdx.c b/client/src/cmdlffdx.c similarity index 100% rename from client/cmdlffdx.c rename to client/src/cmdlffdx.c diff --git a/client/cmdlffdx.h b/client/src/cmdlffdx.h similarity index 100% rename from client/cmdlffdx.h rename to client/src/cmdlffdx.h diff --git a/client/cmdlfgallagher.c b/client/src/cmdlfgallagher.c similarity index 100% rename from client/cmdlfgallagher.c rename to client/src/cmdlfgallagher.c diff --git a/client/cmdlfgallagher.h b/client/src/cmdlfgallagher.h similarity index 100% rename from client/cmdlfgallagher.h rename to client/src/cmdlfgallagher.h diff --git a/client/cmdlfguard.c b/client/src/cmdlfguard.c similarity index 100% rename from client/cmdlfguard.c rename to client/src/cmdlfguard.c diff --git a/client/cmdlfguard.h b/client/src/cmdlfguard.h similarity index 100% rename from client/cmdlfguard.h rename to client/src/cmdlfguard.h diff --git a/client/cmdlfhid.c b/client/src/cmdlfhid.c similarity index 100% rename from client/cmdlfhid.c rename to client/src/cmdlfhid.c diff --git a/client/cmdlfhid.h b/client/src/cmdlfhid.h similarity index 100% rename from client/cmdlfhid.h rename to client/src/cmdlfhid.h diff --git a/client/cmdlfhitag.c b/client/src/cmdlfhitag.c similarity index 99% rename from client/cmdlfhitag.c rename to client/src/cmdlfhitag.c index 4d699541e..c13395898 100644 --- a/client/cmdlfhitag.c +++ b/client/src/cmdlfhitag.c @@ -567,7 +567,7 @@ static int CmdLFHitagReader(const char *Cmd) { PrintAndLogEx(SUCCESS, " UID: " _YELLOW_("%08x"), id); if (htf != RHT2F_UID_ONLY) { - + // block3, 1 byte printHitagConfiguration(data[4 * 3]); } @@ -681,7 +681,7 @@ static int CmdLFHitag2Dump(const char *Cmd) { if (ctmp == 'h') return 0; // usage_hitag_dump(); PacketResponseNG resp; - + PrintAndLogEx(SUCCESS, "Dumping tag memory..."); uint8_t *data = resp.data.asBytes; @@ -699,7 +699,7 @@ static int CmdLFHitag2Dump(const char *Cmd) { // Annotate HITAG protocol -void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { +void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { } void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { diff --git a/client/cmdlfhitag.h b/client/src/cmdlfhitag.h similarity index 100% rename from client/cmdlfhitag.h rename to client/src/cmdlfhitag.h diff --git a/client/cmdlfindala.c b/client/src/cmdlfindala.c similarity index 100% rename from client/cmdlfindala.c rename to client/src/cmdlfindala.c diff --git a/client/cmdlfindala.h b/client/src/cmdlfindala.h similarity index 100% rename from client/cmdlfindala.h rename to client/src/cmdlfindala.h diff --git a/client/cmdlfio.c b/client/src/cmdlfio.c similarity index 100% rename from client/cmdlfio.c rename to client/src/cmdlfio.c diff --git a/client/cmdlfio.h b/client/src/cmdlfio.h similarity index 100% rename from client/cmdlfio.h rename to client/src/cmdlfio.h diff --git a/client/cmdlfjablotron.c b/client/src/cmdlfjablotron.c similarity index 100% rename from client/cmdlfjablotron.c rename to client/src/cmdlfjablotron.c diff --git a/client/cmdlfjablotron.h b/client/src/cmdlfjablotron.h similarity index 100% rename from client/cmdlfjablotron.h rename to client/src/cmdlfjablotron.h diff --git a/client/cmdlfkeri.c b/client/src/cmdlfkeri.c similarity index 87% rename from client/cmdlfkeri.c rename to client/src/cmdlfkeri.c index a77f3c477..020a8331e 100644 --- a/client/cmdlfkeri.c +++ b/client/src/cmdlfkeri.c @@ -44,7 +44,7 @@ static int usage_lf_keri_clone(void) { PrintAndLogEx(NORMAL, " lf keri clone 112233"); PrintAndLogEx(NORMAL, " lf keri clone type ms fc 6 cn 12345"); PrintAndLogEx(NORMAL, " lf keri clone t m f 6 c 12345"); - + return PM3_SUCCESS; } @@ -62,16 +62,17 @@ static int usage_lf_keri_sim(void) { return PM3_SUCCESS; } -typedef enum {Scramble = 0,Descramble = 1} KeriMSScramble_t; +typedef enum {Scramble = 0, Descramble = 1} KeriMSScramble_t; -static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) -{ +static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) { // 255 = Not used/Unknown other values are the bit offset in the ID/FC values - uint8_t CardToID [] = { 255,255,255,255, 13, 12, 20, 5, 16, 6, 21, 17, 8,255, 0, 7, - 10, 15,255, 11, 4, 1,255, 18,255, 19, 2, 14, 3, 9,255,255 }; + uint8_t CardToID [] = { 255, 255, 255, 255, 13, 12, 20, 5, 16, 6, 21, 17, 8, 255, 0, 7, + 10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255 + }; - uint8_t CardToFC [] = { 255,255,255,255,255,255,255,255,255,255,255,255,255, 0,255,255, - 255,255, 2,255,255,255, 3,255, 4,255,255,255,255,255, 1,255 }; + uint8_t CardToFC [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, + 255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255 + }; uint8_t CardIdx; // 0 - 31 bool BitState; @@ -93,13 +94,11 @@ static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *I } } - if (Action == Scramble) - { + if (Action == Scramble) { *CardID = 0; // set to 0 - for (CardIdx = 0; CardIdx < 32; CardIdx++) - { - // Card ID + for (CardIdx = 0; CardIdx < 32; CardIdx++) { + // Card ID if (CardToID[CardIdx] < 32) { if ((*ID & (1 << CardToID[CardIdx])) > 0) *CardID |= (1 << CardIdx); @@ -130,7 +129,7 @@ static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *I // Bit 31 was fixed but not in check/parity bits *CardID |= 1UL << 31; - PrintAndLogEx(SUCCESS, "Scrambled MS : FC %d - CN %d to RAW : E0000000%08X",*FC,*ID,*CardID); + PrintAndLogEx(SUCCESS, "Scrambled MS : FC %d - CN %d to RAW : E0000000%08X", *FC, *ID, *CardID); } return PM3_SUCCESS; } @@ -187,16 +186,16 @@ static int CmdKeriDemod(const char *Cmd) { PrintAndLogEx(SUCCESS, "KERI Tag Found -- Internal ID: %u", ID); PrintAndLogEx(SUCCESS, "Raw: %08X%08X", raw1, raw2); -/* - Descramble Data. -*/ + /* + Descramble Data. + */ uint32_t fc = 0; uint32_t cardid = 0; // Just need to the low 32 bits without the 111 trailer - CmdKeriMSScramble (Descramble,&fc,&cardid,&raw2); + CmdKeriMSScramble(Descramble, &fc, &cardid, &raw2); - PrintAndLogEx (SUCCESS,"Descrambled MS : FC %d - CN %d\n",fc,cardid); + PrintAndLogEx(SUCCESS, "Descrambled MS : FC %d - CN %d\n", fc, cardid); if (invert) { PrintAndLogEx(INFO, "Had to Invert - probably KERI"); @@ -245,26 +244,26 @@ static int CmdKeriClone(const char *Cmd) { case 'h': // help return usage_lf_keri_clone(); case 't': // format type - keritype = tolower(param_getchar(Cmd,cmdidx+1)); + keritype = tolower(param_getchar(Cmd, cmdidx + 1)); cmdidx += 2; break; case 'f': // fc - fc = param_get32ex(Cmd,cmdidx+1,0,10); + fc = param_get32ex(Cmd, cmdidx + 1, 0, 10); cmdidx += 2; break; case 'c': // cardid - cid = param_get32ex(Cmd,cmdidx+1,0,10); + cid = param_get32ex(Cmd, cmdidx + 1, 0, 10); cmdidx += 2; break; case 'q': // q5 - blocks[0] = + blocks[0] = T5555_MODULATION_PSK1 | T5555_SET_BITRATE(128) | T5555_PSK_RF_2 | 2 << T5555_MAXBLOCK_SHIFT; - cmdidx++; + cmdidx++; break; - default: + default: // Skip unknown cmdidx++; } @@ -272,28 +271,28 @@ static int CmdKeriClone(const char *Cmd) { // this is managed in above code // internalid = param_get32ex(Cmd, 0, 0, 10); -/* - // Q5 is caught in the while loop - //Q5 - if (tolower(param_getchar(Cmd, 1)) == 'q') { - blocks[0] = - T5555_MODULATION_PSK1 | - T5555_SET_BITRATE(128) | - T5555_PSK_RF_2 | - 2 << T5555_MAXBLOCK_SHIFT; - } -*/ + /* + // Q5 is caught in the while loop + //Q5 + if (tolower(param_getchar(Cmd, 1)) == 'q') { + blocks[0] = + T5555_MODULATION_PSK1 | + T5555_SET_BITRATE(128) | + T5555_PSK_RF_2 | + 2 << T5555_MAXBLOCK_SHIFT; + } + */ // Setup card data/build internal id - switch (keritype) { + switch (keritype) { case 'i' : // Internal ID // MSB is ONE internalid = cid | 0x80000000; break; case 'm' : // MS - CmdKeriMSScramble (Scramble,&fc,&cid,&internalid); + CmdKeriMSScramble(Scramble, &fc, &cid, &internalid); break; } - + // Prepare and write to card // 3 LSB is ONE uint64_t data = ((uint64_t)internalid << 3) + 7; diff --git a/client/cmdlfkeri.h b/client/src/cmdlfkeri.h similarity index 100% rename from client/cmdlfkeri.h rename to client/src/cmdlfkeri.h diff --git a/client/cmdlfmotorola.c b/client/src/cmdlfmotorola.c similarity index 100% rename from client/cmdlfmotorola.c rename to client/src/cmdlfmotorola.c diff --git a/client/cmdlfmotorola.h b/client/src/cmdlfmotorola.h similarity index 100% rename from client/cmdlfmotorola.h rename to client/src/cmdlfmotorola.h diff --git a/client/cmdlfnedap.c b/client/src/cmdlfnedap.c similarity index 100% rename from client/cmdlfnedap.c rename to client/src/cmdlfnedap.c diff --git a/client/cmdlfnedap.h b/client/src/cmdlfnedap.h similarity index 100% rename from client/cmdlfnedap.h rename to client/src/cmdlfnedap.h diff --git a/client/cmdlfnexwatch.c b/client/src/cmdlfnexwatch.c similarity index 100% rename from client/cmdlfnexwatch.c rename to client/src/cmdlfnexwatch.c diff --git a/client/cmdlfnexwatch.h b/client/src/cmdlfnexwatch.h similarity index 100% rename from client/cmdlfnexwatch.h rename to client/src/cmdlfnexwatch.h diff --git a/client/cmdlfnoralsy.c b/client/src/cmdlfnoralsy.c similarity index 100% rename from client/cmdlfnoralsy.c rename to client/src/cmdlfnoralsy.c diff --git a/client/cmdlfnoralsy.h b/client/src/cmdlfnoralsy.h similarity index 100% rename from client/cmdlfnoralsy.h rename to client/src/cmdlfnoralsy.h diff --git a/client/cmdlfpac.c b/client/src/cmdlfpac.c similarity index 100% rename from client/cmdlfpac.c rename to client/src/cmdlfpac.c diff --git a/client/cmdlfpac.h b/client/src/cmdlfpac.h similarity index 100% rename from client/cmdlfpac.h rename to client/src/cmdlfpac.h diff --git a/client/cmdlfparadox.c b/client/src/cmdlfparadox.c similarity index 100% rename from client/cmdlfparadox.c rename to client/src/cmdlfparadox.c diff --git a/client/cmdlfparadox.h b/client/src/cmdlfparadox.h similarity index 100% rename from client/cmdlfparadox.h rename to client/src/cmdlfparadox.h diff --git a/client/cmdlfpcf7931.c b/client/src/cmdlfpcf7931.c similarity index 100% rename from client/cmdlfpcf7931.c rename to client/src/cmdlfpcf7931.c diff --git a/client/cmdlfpcf7931.h b/client/src/cmdlfpcf7931.h similarity index 100% rename from client/cmdlfpcf7931.h rename to client/src/cmdlfpcf7931.h diff --git a/client/cmdlfpresco.c b/client/src/cmdlfpresco.c similarity index 100% rename from client/cmdlfpresco.c rename to client/src/cmdlfpresco.c diff --git a/client/cmdlfpresco.h b/client/src/cmdlfpresco.h similarity index 100% rename from client/cmdlfpresco.h rename to client/src/cmdlfpresco.h diff --git a/client/cmdlfpyramid.c b/client/src/cmdlfpyramid.c similarity index 100% rename from client/cmdlfpyramid.c rename to client/src/cmdlfpyramid.c diff --git a/client/cmdlfpyramid.h b/client/src/cmdlfpyramid.h similarity index 100% rename from client/cmdlfpyramid.h rename to client/src/cmdlfpyramid.h diff --git a/client/cmdlfsecurakey.c b/client/src/cmdlfsecurakey.c similarity index 100% rename from client/cmdlfsecurakey.c rename to client/src/cmdlfsecurakey.c diff --git a/client/cmdlfsecurakey.h b/client/src/cmdlfsecurakey.h similarity index 100% rename from client/cmdlfsecurakey.h rename to client/src/cmdlfsecurakey.h diff --git a/client/cmdlft55xx.c b/client/src/cmdlft55xx.c similarity index 100% rename from client/cmdlft55xx.c rename to client/src/cmdlft55xx.c diff --git a/client/cmdlft55xx.h b/client/src/cmdlft55xx.h similarity index 100% rename from client/cmdlft55xx.h rename to client/src/cmdlft55xx.h diff --git a/client/cmdlfti.c b/client/src/cmdlfti.c similarity index 100% rename from client/cmdlfti.c rename to client/src/cmdlfti.c diff --git a/client/cmdlfti.h b/client/src/cmdlfti.h similarity index 100% rename from client/cmdlfti.h rename to client/src/cmdlfti.h diff --git a/client/cmdlfverichip.c b/client/src/cmdlfverichip.c similarity index 100% rename from client/cmdlfverichip.c rename to client/src/cmdlfverichip.c diff --git a/client/cmdlfverichip.h b/client/src/cmdlfverichip.h similarity index 100% rename from client/cmdlfverichip.h rename to client/src/cmdlfverichip.h diff --git a/client/cmdlfviking.c b/client/src/cmdlfviking.c similarity index 100% rename from client/cmdlfviking.c rename to client/src/cmdlfviking.c diff --git a/client/cmdlfviking.h b/client/src/cmdlfviking.h similarity index 100% rename from client/cmdlfviking.h rename to client/src/cmdlfviking.h diff --git a/client/cmdlfvisa2000.c b/client/src/cmdlfvisa2000.c similarity index 100% rename from client/cmdlfvisa2000.c rename to client/src/cmdlfvisa2000.c diff --git a/client/cmdlfvisa2000.h b/client/src/cmdlfvisa2000.h similarity index 100% rename from client/cmdlfvisa2000.h rename to client/src/cmdlfvisa2000.h diff --git a/client/cmdmain.c b/client/src/cmdmain.c similarity index 98% rename from client/cmdmain.c rename to client/src/cmdmain.c index 906a354f6..932b66bd3 100644 --- a/client/cmdmain.c +++ b/client/src/cmdmain.c @@ -197,13 +197,13 @@ static int CmdHints(const char *Cmd) { char ctmp = tolower(param_getchar(Cmd, 0)); if (ctmp == 'h') return usage_hints(); - if (strlen(Cmd) > 1){ - str_lower((char *)Cmd); - if (str_startswith(Cmd, "of")) { + if (strlen(Cmd) > 1) { + str_lower((char *)Cmd); + if (str_startswith(Cmd, "of")) { session.show_hints = false; - } else { + } else { session.show_hints = true; - } + } } else if (strlen(Cmd) == 1) { if (param_getchar(Cmd, 0) != 0x00) { ms = param_get32ex(Cmd, 0, 0, 10); @@ -214,7 +214,7 @@ static int CmdHints(const char *Cmd) { } } } - + PrintAndLogEx(INFO, "Hints are %s", (session.show_hints) ? "ON" : "OFF"); return PM3_SUCCESS; } diff --git a/client/cmdmain.h b/client/src/cmdmain.h similarity index 100% rename from client/cmdmain.h rename to client/src/cmdmain.h diff --git a/client/cmdparser.c b/client/src/cmdparser.c similarity index 100% rename from client/cmdparser.c rename to client/src/cmdparser.c diff --git a/client/cmdparser.h b/client/src/cmdparser.h similarity index 100% rename from client/cmdparser.h rename to client/src/cmdparser.h diff --git a/client/cmdscript.c b/client/src/cmdscript.c similarity index 100% rename from client/cmdscript.c rename to client/src/cmdscript.c diff --git a/client/cmdscript.h b/client/src/cmdscript.h similarity index 100% rename from client/cmdscript.h rename to client/src/cmdscript.h diff --git a/client/cmdsmartcard.c b/client/src/cmdsmartcard.c similarity index 99% rename from client/cmdsmartcard.c rename to client/src/cmdsmartcard.c index ba48fae96..36b7155e7 100644 --- a/client/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -19,7 +19,7 @@ #include "proxmark3.h" #include "comms.h" // getfromdevice #include "emv/emvcore.h" // decodeTVL -#include "crypto/libpcrypto.h" // sha512hash +#include "../crypto/libpcrypto.h" // sha512hash #include "emv/dump.h" #include "ui.h" #include "fileutils.h" diff --git a/client/cmdsmartcard.h b/client/src/cmdsmartcard.h similarity index 100% rename from client/cmdsmartcard.h rename to client/src/cmdsmartcard.h diff --git a/client/cmdtrace.c b/client/src/cmdtrace.c similarity index 99% rename from client/cmdtrace.c rename to client/src/cmdtrace.c index 88f55ed3f..305f2839c 100644 --- a/client/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -394,13 +394,13 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr break; case PROTO_HITAG1: annotateHitag1(explanation, sizeof(explanation), frame, data_len); - break; + break; case PROTO_HITAG2: annotateHitag2(explanation, sizeof(explanation), frame, data_len); - break; - case PROTO_HITAGS: + break; + case PROTO_HITAGS: annotateHitagS(explanation, sizeof(explanation), frame, data_len); - break; + break; default: break; } @@ -611,7 +611,7 @@ int CmdTraceList(const char *Cmd) { else if (strcmp(type, "mf") == 0) protocol = PROTO_MIFARE; else if (strcmp(type, "hitag1") == 0) protocol = PROTO_HITAG1; else if (strcmp(type, "hitag2") == 0) protocol = PROTO_HITAG2; - else if (strcmp(type, "hitags") == 0) protocol = PROTO_HITAGS; + else if (strcmp(type, "hitags") == 0) protocol = PROTO_HITAGS; else if (strcmp(type, "thinfilm") == 0) protocol = THINFILM; else if (strcmp(type, "lto") == 0) protocol = LTO; else if (strcmp(type, "raw") == 0) protocol = -1; //No crc, no annotations @@ -694,7 +694,7 @@ int CmdTraceList(const char *Cmd) { PrintAndLogEx(INFO, "Hitag1 / Hitag2 / HitagS - Timings in ETU (8us)"); if (protocol == FELICA) PrintAndLogEx(INFO, "ISO18092 / FeliCa - Timings are not as accurate"); - + PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation"); PrintAndLogEx(NORMAL, "------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------"); diff --git a/client/cmdtrace.h b/client/src/cmdtrace.h similarity index 100% rename from client/cmdtrace.h rename to client/src/cmdtrace.h diff --git a/client/cmdusart.c b/client/src/cmdusart.c similarity index 100% rename from client/cmdusart.c rename to client/src/cmdusart.c diff --git a/client/cmdusart.h b/client/src/cmdusart.h similarity index 100% rename from client/cmdusart.h rename to client/src/cmdusart.h diff --git a/client/cmdwiegand.c b/client/src/cmdwiegand.c similarity index 100% rename from client/cmdwiegand.c rename to client/src/cmdwiegand.c diff --git a/client/cmdwiegand.h b/client/src/cmdwiegand.h similarity index 100% rename from client/cmdwiegand.h rename to client/src/cmdwiegand.h diff --git a/client/comms.c b/client/src/comms.c similarity index 100% rename from client/comms.c rename to client/src/comms.c diff --git a/client/comms.h b/client/src/comms.h similarity index 100% rename from client/comms.h rename to client/src/comms.h diff --git a/client/crypto/asn1dump.c b/client/src/crypto/asn1dump.c similarity index 100% rename from client/crypto/asn1dump.c rename to client/src/crypto/asn1dump.c diff --git a/client/crypto/asn1dump.h b/client/src/crypto/asn1dump.h similarity index 100% rename from client/crypto/asn1dump.h rename to client/src/crypto/asn1dump.h diff --git a/client/crypto/asn1utils.c b/client/src/crypto/asn1utils.c similarity index 100% rename from client/crypto/asn1utils.c rename to client/src/crypto/asn1utils.c diff --git a/client/crypto/asn1utils.h b/client/src/crypto/asn1utils.h similarity index 100% rename from client/crypto/asn1utils.h rename to client/src/crypto/asn1utils.h diff --git a/client/crypto/libpcrypto.c b/client/src/crypto/libpcrypto.c similarity index 100% rename from client/crypto/libpcrypto.c rename to client/src/crypto/libpcrypto.c diff --git a/client/crypto/libpcrypto.h b/client/src/crypto/libpcrypto.h similarity index 100% rename from client/crypto/libpcrypto.h rename to client/src/crypto/libpcrypto.h diff --git a/client/elf.h b/client/src/elf.h similarity index 100% rename from client/elf.h rename to client/src/elf.h diff --git a/client/emojis.h b/client/src/emojis.h similarity index 100% rename from client/emojis.h rename to client/src/emojis.h diff --git a/client/emojis_alt.h b/client/src/emojis_alt.h similarity index 100% rename from client/emojis_alt.h rename to client/src/emojis_alt.h diff --git a/client/emv/apduinfo.c b/client/src/emv/apduinfo.c similarity index 98% rename from client/emv/apduinfo.c rename to client/src/emv/apduinfo.c index b64696628..bc8d3f8ae 100644 --- a/client/emv/apduinfo.c +++ b/client/src/emv/apduinfo.c @@ -503,17 +503,17 @@ void APDUPrint(APDUStruct apdu) { void APDUPrintEx(APDUStruct apdu, size_t maxdatalen) { PrintAndLogEx(INFO, "APDU: %scase=0x%02x cla=0x%02x ins=0x%02x p1=0x%02x p2=0x%02x Lc=0x%02x(%d) Le=0x%02x(%d)", - apdu.extended_apdu ? "[e]" : "", - apdu.case_type, - apdu.cla, - apdu.ins, - apdu.p1, - apdu.p2, - apdu.lc, - apdu.lc, - apdu.le, - apdu.le - ); + apdu.extended_apdu ? "[e]" : "", + apdu.case_type, + apdu.cla, + apdu.ins, + apdu.p1, + apdu.p2, + apdu.lc, + apdu.lc, + apdu.le, + apdu.le + ); if (maxdatalen > 0) PrintAndLogEx(INFO, "data: %s%s", sprint_hex(apdu.data, MIN(apdu.lc, maxdatalen)), apdu.lc > maxdatalen ? "..." : ""); } diff --git a/client/emv/apduinfo.h b/client/src/emv/apduinfo.h similarity index 100% rename from client/emv/apduinfo.h rename to client/src/emv/apduinfo.h diff --git a/client/emv/cmdemv.c b/client/src/emv/cmdemv.c similarity index 100% rename from client/emv/cmdemv.c rename to client/src/emv/cmdemv.c diff --git a/client/emv/cmdemv.h b/client/src/emv/cmdemv.h similarity index 100% rename from client/emv/cmdemv.h rename to client/src/emv/cmdemv.h diff --git a/client/emv/crypto.c b/client/src/emv/crypto.c similarity index 100% rename from client/emv/crypto.c rename to client/src/emv/crypto.c diff --git a/client/emv/crypto.h b/client/src/emv/crypto.h similarity index 100% rename from client/emv/crypto.h rename to client/src/emv/crypto.h diff --git a/client/emv/crypto_backend.h b/client/src/emv/crypto_backend.h similarity index 100% rename from client/emv/crypto_backend.h rename to client/src/emv/crypto_backend.h diff --git a/client/emv/crypto_polarssl.c b/client/src/emv/crypto_polarssl.c similarity index 100% rename from client/emv/crypto_polarssl.c rename to client/src/emv/crypto_polarssl.c diff --git a/client/emv/dol.c b/client/src/emv/dol.c similarity index 100% rename from client/emv/dol.c rename to client/src/emv/dol.c diff --git a/client/emv/dol.h b/client/src/emv/dol.h similarity index 100% rename from client/emv/dol.h rename to client/src/emv/dol.h diff --git a/client/emv/dump.c b/client/src/emv/dump.c similarity index 100% rename from client/emv/dump.c rename to client/src/emv/dump.c diff --git a/client/emv/dump.h b/client/src/emv/dump.h similarity index 100% rename from client/emv/dump.h rename to client/src/emv/dump.h diff --git a/client/emv/emv_pk.c b/client/src/emv/emv_pk.c similarity index 100% rename from client/emv/emv_pk.c rename to client/src/emv/emv_pk.c diff --git a/client/emv/emv_pk.h b/client/src/emv/emv_pk.h similarity index 100% rename from client/emv/emv_pk.h rename to client/src/emv/emv_pk.h diff --git a/client/emv/emv_pki.c b/client/src/emv/emv_pki.c similarity index 100% rename from client/emv/emv_pki.c rename to client/src/emv/emv_pki.c diff --git a/client/emv/emv_pki.h b/client/src/emv/emv_pki.h similarity index 100% rename from client/emv/emv_pki.h rename to client/src/emv/emv_pki.h diff --git a/client/emv/emv_pki_priv.c b/client/src/emv/emv_pki_priv.c similarity index 100% rename from client/emv/emv_pki_priv.c rename to client/src/emv/emv_pki_priv.c diff --git a/client/emv/emv_pki_priv.h b/client/src/emv/emv_pki_priv.h similarity index 100% rename from client/emv/emv_pki_priv.h rename to client/src/emv/emv_pki_priv.h diff --git a/client/emv/emv_roca.c b/client/src/emv/emv_roca.c similarity index 100% rename from client/emv/emv_roca.c rename to client/src/emv/emv_roca.c diff --git a/client/emv/emv_roca.h b/client/src/emv/emv_roca.h similarity index 100% rename from client/emv/emv_roca.h rename to client/src/emv/emv_roca.h diff --git a/client/emv/emv_tags.c b/client/src/emv/emv_tags.c similarity index 100% rename from client/emv/emv_tags.c rename to client/src/emv/emv_tags.c diff --git a/client/emv/emv_tags.h b/client/src/emv/emv_tags.h similarity index 100% rename from client/emv/emv_tags.h rename to client/src/emv/emv_tags.h diff --git a/client/emv/emvcore.c b/client/src/emv/emvcore.c similarity index 100% rename from client/emv/emvcore.c rename to client/src/emv/emvcore.c diff --git a/client/emv/emvcore.h b/client/src/emv/emvcore.h similarity index 100% rename from client/emv/emvcore.h rename to client/src/emv/emvcore.h diff --git a/client/emv/emvjson.c b/client/src/emv/emvjson.c similarity index 100% rename from client/emv/emvjson.c rename to client/src/emv/emvjson.c diff --git a/client/emv/emvjson.h b/client/src/emv/emvjson.h similarity index 100% rename from client/emv/emvjson.h rename to client/src/emv/emvjson.h diff --git a/client/emv/test/cda_test.c b/client/src/emv/test/cda_test.c similarity index 100% rename from client/emv/test/cda_test.c rename to client/src/emv/test/cda_test.c diff --git a/client/emv/test/cda_test.h b/client/src/emv/test/cda_test.h similarity index 100% rename from client/emv/test/cda_test.h rename to client/src/emv/test/cda_test.h diff --git a/client/emv/test/crypto_test.c b/client/src/emv/test/crypto_test.c similarity index 100% rename from client/emv/test/crypto_test.c rename to client/src/emv/test/crypto_test.c diff --git a/client/emv/test/crypto_test.h b/client/src/emv/test/crypto_test.h similarity index 100% rename from client/emv/test/crypto_test.h rename to client/src/emv/test/crypto_test.h diff --git a/client/emv/test/cryptotest.c b/client/src/emv/test/cryptotest.c similarity index 100% rename from client/emv/test/cryptotest.c rename to client/src/emv/test/cryptotest.c diff --git a/client/emv/test/cryptotest.h b/client/src/emv/test/cryptotest.h similarity index 100% rename from client/emv/test/cryptotest.h rename to client/src/emv/test/cryptotest.h diff --git a/client/emv/test/dda_test.c b/client/src/emv/test/dda_test.c similarity index 100% rename from client/emv/test/dda_test.c rename to client/src/emv/test/dda_test.c diff --git a/client/emv/test/dda_test.h b/client/src/emv/test/dda_test.h similarity index 100% rename from client/emv/test/dda_test.h rename to client/src/emv/test/dda_test.h diff --git a/client/emv/test/sda_test.c b/client/src/emv/test/sda_test.c similarity index 100% rename from client/emv/test/sda_test.c rename to client/src/emv/test/sda_test.c diff --git a/client/emv/test/sda_test.h b/client/src/emv/test/sda_test.h similarity index 100% rename from client/emv/test/sda_test.h rename to client/src/emv/test/sda_test.h diff --git a/client/emv/tlv.c b/client/src/emv/tlv.c similarity index 100% rename from client/emv/tlv.c rename to client/src/emv/tlv.c diff --git a/client/emv/tlv.h b/client/src/emv/tlv.h similarity index 100% rename from client/emv/tlv.h rename to client/src/emv/tlv.h diff --git a/client/fido/additional_ca.c b/client/src/fido/additional_ca.c similarity index 100% rename from client/fido/additional_ca.c rename to client/src/fido/additional_ca.c diff --git a/client/fido/additional_ca.h b/client/src/fido/additional_ca.h similarity index 100% rename from client/fido/additional_ca.h rename to client/src/fido/additional_ca.h diff --git a/client/fido/cbortools.c b/client/src/fido/cbortools.c similarity index 100% rename from client/fido/cbortools.c rename to client/src/fido/cbortools.c diff --git a/client/fido/cbortools.h b/client/src/fido/cbortools.h similarity index 100% rename from client/fido/cbortools.h rename to client/src/fido/cbortools.h diff --git a/client/fido/cose.c b/client/src/fido/cose.c similarity index 100% rename from client/fido/cose.c rename to client/src/fido/cose.c diff --git a/client/fido/cose.h b/client/src/fido/cose.h similarity index 100% rename from client/fido/cose.h rename to client/src/fido/cose.h diff --git a/client/fido/fido2.json b/client/src/fido/fido2.json similarity index 100% rename from client/fido/fido2.json rename to client/src/fido/fido2.json diff --git a/client/fido/fidocore.c b/client/src/fido/fidocore.c similarity index 100% rename from client/fido/fidocore.c rename to client/src/fido/fidocore.c diff --git a/client/fido/fidocore.h b/client/src/fido/fidocore.h similarity index 100% rename from client/fido/fidocore.h rename to client/src/fido/fidocore.h diff --git a/client/fileutils.c b/client/src/fileutils.c similarity index 99% rename from client/fileutils.c rename to client/src/fileutils.c index 1eb82e57c..066a796b5 100644 --- a/client/fileutils.c +++ b/client/src/fileutils.c @@ -374,7 +374,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s JsonSaveStr(root, "FileType", "14b"); JsonSaveBufAsHexCompact(root, "raw", data, datalen); break; - } + } case jsf15: { JsonSaveStr(root, "FileType", "15693"); JsonSaveBufAsHexCompact(root, "raw", data, datalen); @@ -426,8 +426,8 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s } } break; - case jsfSettings: - preferences_save_callback (root); + case jsfSettings: + preferences_save_callback(root); break; default: break; @@ -867,8 +867,8 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_ } *datalen = sptr; } - if (!strcmp(ctype,"settings")) { - preferences_load_callback (root); + if (!strcmp(ctype, "settings")) { + preferences_load_callback(root); } PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName); out: diff --git a/client/fileutils.h b/client/src/fileutils.h similarity index 100% rename from client/fileutils.h rename to client/src/fileutils.h diff --git a/client/flash.c b/client/src/flash.c similarity index 100% rename from client/flash.c rename to client/src/flash.c diff --git a/client/flash.h b/client/src/flash.h similarity index 100% rename from client/flash.h rename to client/src/flash.h diff --git a/client/graph.c b/client/src/graph.c similarity index 100% rename from client/graph.c rename to client/src/graph.c diff --git a/client/graph.h b/client/src/graph.h similarity index 100% rename from client/graph.h rename to client/src/graph.h diff --git a/client/guidummy.cpp b/client/src/guidummy.cpp similarity index 100% rename from client/guidummy.cpp rename to client/src/guidummy.cpp diff --git a/client/loclass/cipher.c b/client/src/loclass/cipher.c similarity index 100% rename from client/loclass/cipher.c rename to client/src/loclass/cipher.c diff --git a/client/loclass/cipher.h b/client/src/loclass/cipher.h similarity index 100% rename from client/loclass/cipher.h rename to client/src/loclass/cipher.h diff --git a/client/loclass/cipherutils.c b/client/src/loclass/cipherutils.c similarity index 100% rename from client/loclass/cipherutils.c rename to client/src/loclass/cipherutils.c diff --git a/client/loclass/cipherutils.h b/client/src/loclass/cipherutils.h similarity index 100% rename from client/loclass/cipherutils.h rename to client/src/loclass/cipherutils.h diff --git a/client/loclass/elite_crack.c b/client/src/loclass/elite_crack.c similarity index 100% rename from client/loclass/elite_crack.c rename to client/src/loclass/elite_crack.c diff --git a/client/loclass/elite_crack.h b/client/src/loclass/elite_crack.h similarity index 100% rename from client/loclass/elite_crack.h rename to client/src/loclass/elite_crack.h diff --git a/client/loclass/hash1_brute.c b/client/src/loclass/hash1_brute.c similarity index 100% rename from client/loclass/hash1_brute.c rename to client/src/loclass/hash1_brute.c diff --git a/client/loclass/hash1_brute.h b/client/src/loclass/hash1_brute.h similarity index 100% rename from client/loclass/hash1_brute.h rename to client/src/loclass/hash1_brute.h diff --git a/client/loclass/ikeys.c b/client/src/loclass/ikeys.c similarity index 100% rename from client/loclass/ikeys.c rename to client/src/loclass/ikeys.c diff --git a/client/loclass/ikeys.h b/client/src/loclass/ikeys.h similarity index 100% rename from client/loclass/ikeys.h rename to client/src/loclass/ikeys.h diff --git a/client/mifare/desfire_crypto.c b/client/src/mifare/desfire_crypto.c similarity index 97% rename from client/mifare/desfire_crypto.c rename to client/src/mifare/desfire_crypto.c index 42542c948..e4caaae26 100644 --- a/client/mifare/desfire_crypto.c +++ b/client/src/mifare/desfire_crypto.c @@ -27,15 +27,14 @@ */ #include "desfire_crypto.h" #include -#include #include #include "commonutil.h" -#include "crc32.h" #include "mbedtls/aes.h" #include "mbedtls/des.h" #include "ui.h" #include "crc.h" #include "crc16.h" // crc16 ccitt +#include "crc32.h" mbedtls_des_context ctx; mbedtls_des3_context ctx3; @@ -45,37 +44,6 @@ mbedtls_aes_context actx; # define AddCrc14A(data, len) compute_crc(CRC_14443_A, (data), (len), (data)+(len), (data)+(len)+1) #endif -#define htole32(x) (x) -#define CRC32_PRESET 0xFFFFFFFF - -static void crc32_byte(uint32_t *crc, const uint8_t value); - -static void crc32_byte(uint32_t *crc, const uint8_t value) { - /* x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 */ - const uint32_t poly = 0xEDB88320; - - *crc ^= value; - for (int current_bit = 7; current_bit >= 0; current_bit--) { - int bit_out = (*crc) & 0x00000001; - *crc >>= 1; - if (bit_out) - *crc ^= poly; - } -} - -void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc) { - uint32_t desfire_crc = CRC32_PRESET; - for (size_t i = 0; i < len; i++) { - crc32_byte(&desfire_crc, data[i]); - } - - *((uint32_t *)(crc)) = htole32(desfire_crc); -} - -void crc32_append(uint8_t *data, const size_t len) { - crc32_ex(data, len, data + len); -} - static inline void update_key_schedules(desfirekey_t key); static inline void update_key_schedules(desfirekey_t key) { diff --git a/client/mifare/desfire_crypto.h b/client/src/mifare/desfire_crypto.h similarity index 97% rename from client/mifare/desfire_crypto.h rename to client/src/mifare/desfire_crypto.h index ff2334b5d..40c57de27 100644 --- a/client/mifare/desfire_crypto.h +++ b/client/src/mifare/desfire_crypto.h @@ -3,6 +3,7 @@ #include "common.h" #include "mifare.h" // structs +#include "crc32.h" //#include "../../armsrc/printf.h" //#include "../../armsrc/desfire.h" //#include "../../armsrc/iso14443a.h" @@ -103,9 +104,6 @@ typedef unsigned long DES3_KS[48][2]; /* Triple-DES key schedule */ extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */ -void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc); -void crc32_append(uint8_t *data, const size_t len); - void des_encrypt(void *out, const void *in, const void *key); void des_decrypt(void *out, const void *in, const void *key); void tdes_nxp_receive(const void *in, void *out, size_t length, const void *key, unsigned char iv[8], int keymode); diff --git a/client/mifare/mad.c b/client/src/mifare/mad.c similarity index 100% rename from client/mifare/mad.c rename to client/src/mifare/mad.c diff --git a/client/mifare/mad.h b/client/src/mifare/mad.h similarity index 100% rename from client/mifare/mad.h rename to client/src/mifare/mad.h diff --git a/client/mifare/mfkey.c b/client/src/mifare/mfkey.c similarity index 100% rename from client/mifare/mfkey.c rename to client/src/mifare/mfkey.c diff --git a/client/mifare/mfkey.h b/client/src/mifare/mfkey.h similarity index 100% rename from client/mifare/mfkey.h rename to client/src/mifare/mfkey.h diff --git a/client/mifare/mifare4.c b/client/src/mifare/mifare4.c similarity index 99% rename from client/mifare/mifare4.c rename to client/src/mifare/mifare4.c index 848528611..67c6f3932 100644 --- a/client/mifare/mifare4.c +++ b/client/src/mifare/mifare4.c @@ -449,12 +449,12 @@ int MFPGetVersion(bool activateField, bool leaveSignalON, uint8_t *dataout, int *dataoutlen = 0; // MFDES_ADDITIONAL_FRAME if (tmp[0] == 0xAF) { - c[0] = 0xAF; + c[0] = 0xAF; res = intExchangeRAW14aPlus(c, sizeof(c), false, true, tmp, maxdataoutlen, dataoutlen); if (res == 0) { - + memcpy(dataout + 7, tmp + 1, (*dataoutlen - 3)); - + // MFDES_ADDITIONAL_FRAME res = intExchangeRAW14aPlus(c, sizeof(c), false, false, tmp, maxdataoutlen, dataoutlen); if (res == 0) { diff --git a/client/mifare/mifare4.h b/client/src/mifare/mifare4.h similarity index 100% rename from client/mifare/mifare4.h rename to client/src/mifare/mifare4.h diff --git a/client/mifare/mifaredefault.c b/client/src/mifare/mifaredefault.c similarity index 100% rename from client/mifare/mifaredefault.c rename to client/src/mifare/mifaredefault.c diff --git a/client/mifare/mifaredefault.h b/client/src/mifare/mifaredefault.h similarity index 100% rename from client/mifare/mifaredefault.h rename to client/src/mifare/mifaredefault.h diff --git a/client/mifare/mifarehost.c b/client/src/mifare/mifarehost.c similarity index 100% rename from client/mifare/mifarehost.c rename to client/src/mifare/mifarehost.c diff --git a/client/mifare/mifarehost.h b/client/src/mifare/mifarehost.h similarity index 100% rename from client/mifare/mifarehost.h rename to client/src/mifare/mifarehost.h diff --git a/client/mifare/ndef.c b/client/src/mifare/ndef.c similarity index 98% rename from client/mifare/ndef.c rename to client/src/mifare/ndef.c index 996d8d767..990221c5c 100644 --- a/client/mifare/ndef.c +++ b/client/src/mifare/ndef.c @@ -312,13 +312,13 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) { uint8_t utf8 = (ndef->Payload[0] >> 7); uint8_t lc_len = ndef->Payload[0] & 0x3F; PrintAndLogEx(INFO, - "\tUTF %d\t: " _GREEN_("%.*s") ", " _GREEN_("%.*s"), - (utf8 == 0) ? 8 : 16, - lc_len, - ndef->Payload + 1, - (int)ndef->PayloadLen - 1 - lc_len, - ndef->Payload + 1 + lc_len - ); + "\tUTF %d\t: " _GREEN_("%.*s") ", " _GREEN_("%.*s"), + (utf8 == 0) ? 8 : 16, + lc_len, + ndef->Payload + 1, + (int)ndef->PayloadLen - 1 - lc_len, + ndef->Payload + 1 + lc_len + ); } if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) { diff --git a/client/mifare/ndef.h b/client/src/mifare/ndef.h similarity index 100% rename from client/mifare/ndef.h rename to client/src/mifare/ndef.h diff --git a/client/pm3_binlib.c b/client/src/pm3_binlib.c similarity index 100% rename from client/pm3_binlib.c rename to client/src/pm3_binlib.c diff --git a/client/pm3_binlib.h b/client/src/pm3_binlib.h similarity index 100% rename from client/pm3_binlib.h rename to client/src/pm3_binlib.h diff --git a/client/pm3_bit_limits.h b/client/src/pm3_bit_limits.h similarity index 100% rename from client/pm3_bit_limits.h rename to client/src/pm3_bit_limits.h diff --git a/client/pm3_bitlib.c b/client/src/pm3_bitlib.c similarity index 100% rename from client/pm3_bitlib.c rename to client/src/pm3_bitlib.c diff --git a/client/pm3_bitlib.h b/client/src/pm3_bitlib.h similarity index 100% rename from client/pm3_bitlib.h rename to client/src/pm3_bitlib.h diff --git a/client/polarssl_config.h b/client/src/polarssl_config.h similarity index 100% rename from client/polarssl_config.h rename to client/src/polarssl_config.h diff --git a/client/preferences.c b/client/src/preferences.c similarity index 53% rename from client/preferences.c rename to client/src/preferences.c index 7c5ad9d14..a1de6e4e2 100644 --- a/client/preferences.c +++ b/client/src/preferences.c @@ -14,7 +14,7 @@ // Update the preferences_load_callback to load your setting into the stucture // Update the preferences_save_callback to enusre your setting gets saved when needed. // use the preference as needed : session. -// Can use (session.preferences_loaded) to check if json settings file was used +// Can use (session.preferences_loaded) to check if json settings file was used //----------------------------------------------------------------------------- #include "preferences.h" @@ -40,18 +40,18 @@ static int setCmdHelp(const char *Cmd); #define GetCurrentDir getcwd #endif -static char* prefGetFilename (void) { +static char *prefGetFilename(void) { char *Path; - if (searchHomeFilePath(&Path,preferencesFilename,false) == PM3_SUCCESS) + if (searchHomeFilePath(&Path, preferencesFilename, false) == PM3_SUCCESS) return Path; else return preferencesFilename; } -int preferences_load (void) { +int preferences_load(void) { - PrintAndLogEx(INFO,"Looking for preferences..."); + PrintAndLogEx(INFO, "Looking for preferences..."); // Set all defaults session.client_debug_level = OFF; @@ -61,48 +61,48 @@ int preferences_load (void) { session.window_plot_hsize = 400; session.window_plot_wsize = 800; session.window_overlay_xpos = session.window_plot_xpos; - session.window_overlay_ypos = 60+session.window_plot_ypos + session.window_plot_hsize; + session.window_overlay_ypos = 60 + session.window_plot_ypos + session.window_plot_hsize; session.window_overlay_hsize = 200; session.window_overlay_wsize = session.window_plot_wsize; session.emoji_mode = ALIAS; session.show_hints = false; session.supports_colors = false; - - + + // loadFileJson wants these, so pass in place holder values, though not used // in settings load; uint8_t dummyData = 0x00; size_t dummyDL = 0x00; - + if (loadFileJSON(prefGetFilename(), &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) { session.preferences_loaded = true; } - // Note, if session.settings_loaded == false then the settings_save + // Note, if session.settings_loaded == false then the settings_save // will be called in main () to save settings as set in defaults and main() checks. - return PM3_SUCCESS; + return PM3_SUCCESS; } // Save all settings from memory (struct) to file -int preferences_save (void) { +int preferences_save(void) { // Note sure if backup has value ? - char backupFilename[FILENAME_MAX+sizeof(preferencesFilename)+10] = {0}; + char backupFilename[FILENAME_MAX + sizeof(preferencesFilename) + 10] = {0}; - PrintAndLogEx(INFO,"Saving preferences ..."); - snprintf (backupFilename,sizeof(backupFilename)-1,"%s.bak",prefGetFilename()); + PrintAndLogEx(INFO, "Saving preferences ..."); + snprintf(backupFilename, sizeof(backupFilename) - 1, "%s.bak", prefGetFilename()); - if (fileExists (backupFilename)) { - if (remove (backupFilename) != 0) { - PrintAndLogEx (FAILED, "Error - could not delete old settings backup file \"%s\"",backupFilename); + if (fileExists(backupFilename)) { + if (remove(backupFilename) != 0) { + PrintAndLogEx(FAILED, "Error - could not delete old settings backup file \"%s\"", backupFilename); return PM3_ESOFT; } } - if (fileExists (prefGetFilename())) { - if (rename (prefGetFilename(),backupFilename) != 0) { - PrintAndLogEx (FAILED, "Error - could not backup settings file \"%s\" to \"%s\"",prefGetFilename(),backupFilename); - return PM3_ESOFT; + if (fileExists(prefGetFilename())) { + if (rename(prefGetFilename(), backupFilename) != 0) { + PrintAndLogEx(FAILED, "Error - could not backup settings file \"%s\" to \"%s\"", prefGetFilename(), backupFilename); + return PM3_ESOFT; } } @@ -110,52 +110,66 @@ int preferences_save (void) { size_t dummyDL = 0x00; if (saveFileJSON(prefGetFilename(), jsfSettings, &dummyData, dummyDL) != PM3_SUCCESS) - PrintAndLogEx (ERR, "Error saving preferences to \"%s\"",prefGetFilename()); + PrintAndLogEx(ERR, "Error saving preferences to \"%s\"", prefGetFilename()); return PM3_SUCCESS; } -void preferences_save_callback (json_t *root) { +void preferences_save_callback(json_t *root) { - JsonSaveStr (root,"FileType","settings"); + JsonSaveStr(root, "FileType", "settings"); // Log level, convert to text switch (session.client_debug_level) { - case OFF: JsonSaveStr (root,"client.debug.level","off"); break; - case SIMPLE: JsonSaveStr (root,"client.debug.level","simple"); break; - case FULL: JsonSaveStr (root,"client.debug.level","full"); break; + case OFF: + JsonSaveStr(root, "client.debug.level", "off"); + break; + case SIMPLE: + JsonSaveStr(root, "client.debug.level", "simple"); + break; + case FULL: + JsonSaveStr(root, "client.debug.level", "full"); + break; default: - JsonSaveStr (root,"logging.level","NORMAL"); + JsonSaveStr(root, "logging.level", "NORMAL"); } // Plot window - JsonSaveInt (root,"window.plot.xpos",session.window_plot_xpos); - JsonSaveInt (root,"window.plot.ypos",session.window_plot_ypos); - JsonSaveInt (root,"window.plot.hsize",session.window_plot_hsize); - JsonSaveInt (root,"window.plot.wsize",session.window_plot_wsize); + JsonSaveInt(root, "window.plot.xpos", session.window_plot_xpos); + JsonSaveInt(root, "window.plot.ypos", session.window_plot_ypos); + JsonSaveInt(root, "window.plot.hsize", session.window_plot_hsize); + JsonSaveInt(root, "window.plot.wsize", session.window_plot_wsize); // Overlay/Slider window - JsonSaveInt (root,"window.overlay.xpos",session.window_overlay_xpos); - JsonSaveInt (root,"window.overlay.ypos",session.window_overlay_ypos); - JsonSaveInt (root,"window.overlay.hsize",session.window_overlay_hsize); - JsonSaveInt (root,"window.overlay.wsize",session.window_overlay_wsize); + JsonSaveInt(root, "window.overlay.xpos", session.window_overlay_xpos); + JsonSaveInt(root, "window.overlay.ypos", session.window_overlay_ypos); + JsonSaveInt(root, "window.overlay.hsize", session.window_overlay_hsize); + JsonSaveInt(root, "window.overlay.wsize", session.window_overlay_wsize); // Emoji switch (session.emoji_mode) { - case ALIAS: JsonSaveStr (root,"show.emoji","alias"); break; - case EMOJI: JsonSaveStr (root,"show.emoji","emoji"); break; - case ALTTEXT: JsonSaveStr (root,"show.emoji","alttext"); break; - case ERASE: JsonSaveStr (root,"show.emoji","erase"); break; + case ALIAS: + JsonSaveStr(root, "show.emoji", "alias"); + break; + case EMOJI: + JsonSaveStr(root, "show.emoji", "emoji"); + break; + case ALTTEXT: + JsonSaveStr(root, "show.emoji", "alttext"); + break; + case ERASE: + JsonSaveStr(root, "show.emoji", "erase"); + break; default: - JsonSaveStr (root,"show.emoji","ALIAS"); + JsonSaveStr(root, "show.emoji", "ALIAS"); } - JsonSaveBoolean (root,"show.hints",session.show_hints); + JsonSaveBoolean(root, "show.hints", session.show_hints); - JsonSaveBoolean (root,"os.supports.colors",session.supports_colors); + JsonSaveBoolean(root, "os.supports.colors", session.supports_colors); } -void preferences_load_callback (json_t *root) { +void preferences_load_callback(json_t *root) { json_error_t up_error = {0}; bool b1; int i1; @@ -163,48 +177,48 @@ void preferences_load_callback (json_t *root) { char tempStr [500]; // to use str_lower() since json unpack uses const char * // Logging Level - if (json_unpack_ex(root,&up_error, 0, "{s:s}","client.debug.level",&s1) == 0) { - strncpy (tempStr,s1,sizeof(tempStr)-1); - str_lower (tempStr); - if (strncmp (tempStr,"off",3) == 0) session.client_debug_level = OFF; - if (strncmp (tempStr,"simple",6) == 0) session.client_debug_level = SIMPLE; - if (strncmp (tempStr,"full",4) == 0) session.client_debug_level = FULL; + if (json_unpack_ex(root, &up_error, 0, "{s:s}", "client.debug.level", &s1) == 0) { + strncpy(tempStr, s1, sizeof(tempStr) - 1); + str_lower(tempStr); + if (strncmp(tempStr, "off", 3) == 0) session.client_debug_level = OFF; + if (strncmp(tempStr, "simple", 6) == 0) session.client_debug_level = SIMPLE; + if (strncmp(tempStr, "full", 4) == 0) session.client_debug_level = FULL; } // window plot - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.xpos",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0) session.window_plot_xpos = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.ypos",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.ypos", &i1) == 0) session.window_plot_ypos = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.hsize",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.hsize", &i1) == 0) session.window_plot_hsize = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.wsize",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.wsize", &i1) == 0) session.window_plot_wsize = i1; // overlay/slider plot - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.xpos",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.xpos", &i1) == 0) session.window_overlay_xpos = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.ypos",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.ypos", &i1) == 0) session.window_overlay_ypos = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.hsize",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.hsize", &i1) == 0) session.window_overlay_hsize = i1; - if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.wsize",&i1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.wsize", &i1) == 0) session.window_overlay_wsize = i1; // show options - if (json_unpack_ex(root,&up_error, 0, "{s:s}","show.emoji",&s1) == 0) { - strncpy (tempStr,s1,sizeof(tempStr)-1); - str_lower (tempStr); - if (strncmp (tempStr,"alias",5) == 0) session.emoji_mode = ALIAS; - if (strncmp (tempStr,"emoji",5) == 0) session.emoji_mode = EMOJI; - if (strncmp (tempStr,"alttext",7) == 0) session.emoji_mode = ALTTEXT; - if (strncmp (tempStr,"erase",5) == 0) session.emoji_mode = ERASE; + if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.emoji", &s1) == 0) { + strncpy(tempStr, s1, sizeof(tempStr) - 1); + str_lower(tempStr); + if (strncmp(tempStr, "alias", 5) == 0) session.emoji_mode = ALIAS; + if (strncmp(tempStr, "emoji", 5) == 0) session.emoji_mode = EMOJI; + if (strncmp(tempStr, "alttext", 7) == 0) session.emoji_mode = ALTTEXT; + if (strncmp(tempStr, "erase", 5) == 0) session.emoji_mode = ERASE; } - if (json_unpack_ex(root,&up_error, 0, "{s:b}","show.hints",&b1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:b}", "show.hints", &b1) == 0) session.show_hints = b1; - if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.supports.colors",&b1) == 0) + if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0) session.supports_colors = b1; } @@ -254,83 +268,92 @@ static int usage_set_hints() { } // Preference Processing Functions -typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t; -typedef enum prefShowOpt {prefShowNone,prefShowOLD,prefShowNEW} prefShowOpt_t; +typedef enum preferenceId {prefNONE, prefHELP, prefEMOJI, prefCOLOR, prefPLOT, prefOVERLAY, prefHINTS, prefCLIENTDEBUG} preferenceId_t; +typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t; -const char *prefShowMsg (prefShowOpt_t Opt) -{ +const char *prefShowMsg(prefShowOpt_t Opt) { switch (Opt) { - case prefShowOLD: return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break; - case prefShowNEW: return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break; - case prefShowNone: return ""; + case prefShowOLD: + return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break; + case prefShowNEW: + return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break; + case prefShowNone: + return ""; } - + return ""; } -void showEmojiState (prefShowOpt_t Opt) { +void showEmojiState(prefShowOpt_t Opt) { switch (session.emoji_mode) { - case ALIAS: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alias"),prefShowMsg (Opt)); + case ALIAS: + PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alias"), prefShowMsg(Opt)); break; - case EMOJI: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"),prefShowMsg (Opt)); + case EMOJI: + PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"), prefShowMsg(Opt)); break; - case ALTTEXT: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"),prefShowMsg (Opt)); + case ALTTEXT: + PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"), prefShowMsg(Opt)); break; - case ERASE: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"),prefShowMsg (Opt)); + case ERASE: + PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"), prefShowMsg(Opt)); break; default: - PrintAndLogEx(NORMAL, " %s emoji.................. "_RED_("unknown"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s emoji.................. "_RED_("unknown"), prefShowMsg(Opt)); } } -void showColorState (prefShowOpt_t Opt) { +void showColorState(prefShowOpt_t Opt) { if (session.supports_colors) - PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"), prefShowMsg(Opt)); else - PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("off"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("off"), prefShowMsg(Opt)); } -void showClientDebugState (prefShowOpt_t Opt) { - +void showClientDebugState(prefShowOpt_t Opt) { + switch (session.client_debug_level) { - case OFF: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("off"),prefShowMsg(Opt)); - break; - case SIMPLE: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("simple"),prefShowMsg(Opt)); - break; - case FULL: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("full"),prefShowMsg(Opt)); - break; + case OFF: + PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("off"), prefShowMsg(Opt)); + break; + case SIMPLE: + PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("simple"), prefShowMsg(Opt)); + break; + case FULL: + PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("full"), prefShowMsg(Opt)); + break; default: - PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"), prefShowMsg(Opt)); } } -void showPlotPosState (void){ - PrintAndLogEx (NORMAL," Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"), - session.window_plot_xpos,session.window_plot_ypos,session.window_plot_hsize,session.window_plot_wsize); +void showPlotPosState(void) { + PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"), + session.window_plot_xpos, session.window_plot_ypos, session.window_plot_hsize, session.window_plot_wsize); } -void showOverlayPosState (void){ - PrintAndLogEx (NORMAL," Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"), - session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_hsize,session.window_overlay_wsize); +void showOverlayPosState(void) { + PrintAndLogEx(NORMAL, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"), + session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_hsize, session.window_overlay_wsize); } -void showHintsState (prefShowOpt_t Opt){ +void showHintsState(prefShowOpt_t Opt) { if (session.show_hints) - PrintAndLogEx (NORMAL," %s Hints.................. "_GREEN_("on"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s Hints.................. "_GREEN_("on"), prefShowMsg(Opt)); else - PrintAndLogEx (NORMAL," %s Hints.................. "_GREEN_("off"),prefShowMsg(Opt)); + PrintAndLogEx(NORMAL, " %s Hints.................. "_GREEN_("off"), prefShowMsg(Opt)); } -static int setCmdEmoji (const char *Cmd) { +static int setCmdEmoji(const char *Cmd) { uint8_t cmdp = 0; bool errors = false; bool validValue = false; char strOpt[50]; emojiMode_t newValue = session.emoji_mode; - if (param_getchar(Cmd, cmdp) == 0x00) + if (param_getchar(Cmd, cmdp) == 0x00) return usage_set_emoji(); while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) { @@ -338,37 +361,37 @@ static int setCmdEmoji (const char *Cmd) { if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) { str_lower(strOpt); // convert to lowercase - if (strncmp (strOpt,"help",4) == 0) + if (strncmp(strOpt, "help", 4) == 0) return usage_set_emoji(); - if (strncmp (strOpt,"alias",5) == 0) { + if (strncmp(strOpt, "alias", 5) == 0) { validValue = true; newValue = ALIAS; } - if (strncmp (strOpt,"emoji",5) == 0) { + if (strncmp(strOpt, "emoji", 5) == 0) { validValue = true; newValue = EMOJI; } - if (strncmp (strOpt,"alttext",7) == 0) { + if (strncmp(strOpt, "alttext", 7) == 0) { validValue = true; newValue = ALTTEXT; } - if (strncmp (strOpt,"erase",5) == 0) { + if (strncmp(strOpt, "erase", 5) == 0) { validValue = true; newValue = ERASE; } if (validValue) { - if (session.emoji_mode != newValue) {// changed - showEmojiState (prefShowOLD); + if (session.emoji_mode != newValue) {// changed + showEmojiState(prefShowOLD); session.emoji_mode = newValue; - showEmojiState (prefShowNEW); - preferences_save (); + showEmojiState(prefShowNEW); + preferences_save(); } else { - PrintAndLogEx(INFO,"nothing changed"); - showEmojiState (prefShowNone); + PrintAndLogEx(INFO, "nothing changed"); + showEmojiState(prefShowNone); } } else { - PrintAndLogEx(ERR,"invalid option"); + PrintAndLogEx(ERR, "invalid option"); return usage_set_emoji(); } } @@ -377,15 +400,14 @@ static int setCmdEmoji (const char *Cmd) { return PM3_SUCCESS; } -static int setCmdColor (const char *Cmd) -{ +static int setCmdColor(const char *Cmd) { uint8_t cmdp = 0; bool errors = false; bool validValue = false; char strOpt[50]; bool newValue = session.supports_colors; - if (param_getchar(Cmd, cmdp) == 0x00) + if (param_getchar(Cmd, cmdp) == 0x00) return usage_set_color(); while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) { @@ -393,29 +415,29 @@ static int setCmdColor (const char *Cmd) if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) { str_lower(strOpt); // convert to lowercase - if (strncmp (strOpt,"help",4) == 0) + if (strncmp(strOpt, "help", 4) == 0) return usage_set_color(); - if (strncmp (strOpt,"off",3) == 0) { + if (strncmp(strOpt, "off", 3) == 0) { validValue = true; - newValue = false; + newValue = false; } - if (strncmp (strOpt,"ansi",4) == 0) { + if (strncmp(strOpt, "ansi", 4) == 0) { validValue = true; newValue = true; } if (validValue) { - if (session.supports_colors != newValue) {// changed - showColorState (prefShowOLD); + if (session.supports_colors != newValue) {// changed + showColorState(prefShowOLD); session.supports_colors = newValue; - showColorState (prefShowNEW); - preferences_save (); + showColorState(prefShowNEW); + preferences_save(); } else { - PrintAndLogEx(INFO,"nothing changed"); - showColorState (prefShowNone); + PrintAndLogEx(INFO, "nothing changed"); + showColorState(prefShowNone); } } else { - PrintAndLogEx(ERR,"invalid option"); + PrintAndLogEx(ERR, "invalid option"); return usage_set_color(); } } @@ -424,15 +446,14 @@ static int setCmdColor (const char *Cmd) return PM3_SUCCESS; } -static int setCmdDebug (const char *Cmd) -{ +static int setCmdDebug(const char *Cmd) { uint8_t cmdp = 0; bool errors = false; bool validValue = false; char strOpt[50]; clientdebugLevel_t newValue = session.client_debug_level; - if (param_getchar(Cmd, cmdp) == 0x00) + if (param_getchar(Cmd, cmdp) == 0x00) return usage_set_debug(); while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) { @@ -440,34 +461,34 @@ static int setCmdDebug (const char *Cmd) if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) { str_lower(strOpt); // convert to lowercase - if (strncmp (strOpt,"help",4) == 0) + if (strncmp(strOpt, "help", 4) == 0) return usage_set_debug(); - if (strncmp (strOpt,"off",3) == 0) { + if (strncmp(strOpt, "off", 3) == 0) { validValue = true; newValue = OFF; - } - if (strncmp (strOpt,"simple",6) == 0) { + } + if (strncmp(strOpt, "simple", 6) == 0) { validValue = true; newValue = SIMPLE; } - if (strncmp (strOpt,"full",4) == 0) { + if (strncmp(strOpt, "full", 4) == 0) { validValue = true; newValue = FULL; } if (validValue) { - if (session.client_debug_level != newValue) {// changed - showClientDebugState (prefShowOLD); + if (session.client_debug_level != newValue) {// changed + showClientDebugState(prefShowOLD); session.client_debug_level = newValue; g_debugMode = newValue; - showClientDebugState (prefShowNEW); - preferences_save (); + showClientDebugState(prefShowNEW); + preferences_save(); } else { - PrintAndLogEx(INFO,"nothing changed"); - showClientDebugState (prefShowNone); + PrintAndLogEx(INFO, "nothing changed"); + showClientDebugState(prefShowNone); } } else { - PrintAndLogEx(ERR,"invalid option"); + PrintAndLogEx(ERR, "invalid option"); return usage_set_debug(); } } @@ -476,15 +497,14 @@ static int setCmdDebug (const char *Cmd) return PM3_SUCCESS; } -static int setCmdHint (const char *Cmd) -{ +static int setCmdHint(const char *Cmd) { uint8_t cmdp = 0; bool errors = false; bool validValue = false; char strOpt[50]; bool newValue = session.show_hints; - if (param_getchar(Cmd, cmdp) == 0x00) + if (param_getchar(Cmd, cmdp) == 0x00) return usage_set_hints(); while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) { @@ -492,29 +512,29 @@ static int setCmdHint (const char *Cmd) if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) { str_lower(strOpt); // convert to lowercase - if (strncmp (strOpt,"help",4) == 0) + if (strncmp(strOpt, "help", 4) == 0) return usage_set_hints(); - if (strncmp (strOpt,"off",3) == 0) { + if (strncmp(strOpt, "off", 3) == 0) { validValue = true; - newValue = false; + newValue = false; } - if (strncmp (strOpt,"on",2) == 0) { + if (strncmp(strOpt, "on", 2) == 0) { validValue = true; newValue = true; } if (validValue) { - if (session.show_hints != newValue) {// changed - showHintsState (prefShowOLD); + if (session.show_hints != newValue) {// changed + showHintsState(prefShowOLD); session.show_hints = newValue; - showHintsState (prefShowNEW); - preferences_save (); + showHintsState(prefShowNEW); + preferences_save(); } else { - PrintAndLogEx(INFO,"nothing changed"); - showHintsState (prefShowNone); + PrintAndLogEx(INFO, "nothing changed"); + showHintsState(prefShowNone); } } else { - PrintAndLogEx(ERR,"invalid option"); + PrintAndLogEx(ERR, "invalid option"); return usage_set_hints(); } } @@ -540,32 +560,31 @@ static int setCmdHelp(const char *Cmd) { return PM3_SUCCESS; } -int CmdPrefSet (const char *Cmd) -{ +int CmdPrefSet(const char *Cmd) { clearCommandBuffer(); - return CmdsParse(setCommandTable, Cmd); + return CmdsParse(setCommandTable, Cmd); } -static int CmdPrefShow (const char *Cmd) { +static int CmdPrefShow(const char *Cmd) { + + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, _BLUE_("Preferences")); - PrintAndLogEx(NORMAL,""); - PrintAndLogEx(NORMAL,_BLUE_("Preferences")); - if (!session. preferences_loaded) { - PrintAndLogEx (ERR,"Preferneces not loaded"); + PrintAndLogEx(ERR, "Preferneces not loaded"); return PM3_ESOFT; } - PrintAndLogEx(NORMAL," preference file........ "_GREEN_("%s"),prefGetFilename()); - showEmojiState (prefShowNone); - showColorState (prefShowNone); - // showPlotPosState (); - // showOverlayPosState (); + PrintAndLogEx(NORMAL, " preference file........ "_GREEN_("%s"), prefGetFilename()); + showEmojiState(prefShowNone); + showColorState(prefShowNone); + // showPlotPosState (); + // showOverlayPosState (); showClientDebugState(prefShowNone); - showHintsState (prefShowNone); + showHintsState(prefShowNone); - PrintAndLogEx(NORMAL,""); + PrintAndLogEx(NORMAL, ""); return PM3_SUCCESS; } @@ -591,9 +610,8 @@ static int CmdHelp(const char *Cmd) { return PM3_SUCCESS; } -int CmdPreferences (const char *Cmd) -{ +int CmdPreferences(const char *Cmd) { clearCommandBuffer(); - return CmdsParse(CommandTable, Cmd); -} \ No newline at end of file + return CmdsParse(CommandTable, Cmd); +} diff --git a/client/preferences.h b/client/src/preferences.h similarity index 76% rename from client/preferences.h rename to client/src/preferences.h index 527ca5ffb..38e2272cb 100644 --- a/client/preferences.h +++ b/client/src/preferences.h @@ -13,11 +13,11 @@ // Current working directory will be prepended. #define preferencesFilename "preferences.json" -int CmdPreferences (const char *Cmd); -int preferences_load (void); -int preferences_save (void); +int CmdPreferences(const char *Cmd); +int preferences_load(void); +int preferences_save(void); -void preferences_save_callback (json_t *root); -void preferences_load_callback (json_t *root); +void preferences_save_callback(json_t *root); +void preferences_load_callback(json_t *root); #endif diff --git a/client/prng.c b/client/src/prng.c similarity index 100% rename from client/prng.c rename to client/src/prng.c diff --git a/client/prng.h b/client/src/prng.h similarity index 100% rename from client/prng.h rename to client/src/prng.h diff --git a/client/proxendian.h b/client/src/proxendian.h similarity index 100% rename from client/proxendian.h rename to client/src/proxendian.h diff --git a/client/proxgui.cpp b/client/src/proxgui.cpp similarity index 100% rename from client/proxgui.cpp rename to client/src/proxgui.cpp diff --git a/client/proxgui.h b/client/src/proxgui.h similarity index 100% rename from client/proxgui.h rename to client/src/proxgui.h diff --git a/client/proxguiqt.cpp b/client/src/proxguiqt.cpp similarity index 97% rename from client/proxguiqt.cpp rename to client/src/proxguiqt.cpp index 7caf695ce..945a1922f 100644 --- a/client/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -28,7 +28,7 @@ #include #include "ui.h" -extern "C" int preferences_save (void); +extern "C" int preferences_save(void); extern "C" { #include "util_darwin.h" @@ -132,26 +132,26 @@ ProxGuiQT::~ProxGuiQT(void) { } // ------------------------------------------------- -// Slider Widget form based on a class to enable +// Slider Widget form based on a class to enable // Event override functions // ------------------------------------------------- -SliderWidget::SliderWidget() { +SliderWidget::SliderWidget() { // Set the initail postion and size from settings if (session.preferences_loaded) - setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize); + setGeometry(session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_wsize, session.window_overlay_hsize); else resize(800, 400); } -void SliderWidget::resizeEvent (QResizeEvent *event) { +void SliderWidget::resizeEvent(QResizeEvent *event) { session.window_overlay_hsize = event->size().height(); session.window_overlay_wsize = event->size().width(); session.window_changed = true; } -void SliderWidget::moveEvent (QMoveEvent *event) { +void SliderWidget::moveEvent(QMoveEvent *event) { session.window_overlay_xpos = event->pos().x(); session.window_overlay_ypos = event->pos().y(); session.window_changed = true; @@ -199,12 +199,12 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) { this->master = master; // Set the initail postion and size from settings if (session.preferences_loaded) - setGeometry (session.window_plot_xpos,session.window_plot_ypos,session.window_plot_wsize,session.window_plot_hsize); + setGeometry(session.window_plot_xpos, session.window_plot_ypos, session.window_plot_wsize, session.window_plot_hsize); else resize(800, 400); // Setup the controller widget - controlWidget = new SliderWidget ();//new QWidget(); + controlWidget = new SliderWidget(); //new QWidget(); opsController = new Ui::Form(); opsController->setupUi(controlWidget); //Due to quirks in QT Designer, we need to fiddle a bit @@ -224,7 +224,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) { QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int))); QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int))); - controlWidget->setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize); + controlWidget->setGeometry(session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_wsize, session.window_overlay_hsize); // Set up the plot widget, which does the actual plotting plot = new Plot(this); @@ -240,7 +240,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) { show(); // Set Slider/Overlay position if no settings. - if (!session.preferences_loaded){ + if (!session.preferences_loaded) { // Move controller widget below plot controlWidget->move(x(), y() + frameSize().height()); controlWidget->resize(size().width(), 200); @@ -251,7 +251,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) { controlWidget->setWindowTitle(ct); controlWidget->show(); - + // now that is up, reset pos/size change flags session.window_changed = false; diff --git a/client/proxguiqt.h b/client/src/proxguiqt.h similarity index 97% rename from client/proxguiqt.h rename to client/src/proxguiqt.h index bbc0fcefd..70a9cc6c1 100644 --- a/client/proxguiqt.h +++ b/client/src/proxguiqt.h @@ -58,10 +58,10 @@ class ProxGuiQT; // Added class for SliderWidget to allow move/resize event override class SliderWidget : public QWidget { -protected: - void resizeEvent (QResizeEvent *event); - void moveEvent (QMoveEvent *event); -public: + protected: + void resizeEvent(QResizeEvent *event); + void moveEvent(QMoveEvent *event); + public: SliderWidget(); }; diff --git a/client/proxmark3.c b/client/src/proxmark3.c similarity index 95% rename from client/proxmark3.c rename to client/src/proxmark3.c index 461b00b84..492fdd8c5 100644 --- a/client/proxmark3.c +++ b/client/src/proxmark3.c @@ -42,33 +42,33 @@ #ifdef _WIN32 -static void utf8_showBanner (void) { - - char sq[] = { 0xE2,0x96,0x88,0x00 }; // square block - char tr[] = { 0xE2,0x95,0x97,0x00 }; // top rigth corner - char tl[] = { 0xE2,0x95,0x94,0x00 }; // top left corner - char br[] = { 0xE2,0x95,0x9D,0x00 }; // bottom right corner - char bl[] = { 0xE2,0x95,0x9A,0x00 }; // bottom left corner - char hl[] = { 0xE2,0x95,0x90,0x00 }; // horiz line - char vl[] = { 0xE2,0x95,0x91,0x00 }; // vert line +static void utf8_showBanner(void) { + + char sq[] = { 0xE2, 0x96, 0x88, 0x00 }; // square block + char tr[] = { 0xE2, 0x95, 0x97, 0x00 }; // top rigth corner + char tl[] = { 0xE2, 0x95, 0x94, 0x00 }; // top left corner + char br[] = { 0xE2, 0x95, 0x9D, 0x00 }; // bottom right corner + char bl[] = { 0xE2, 0x95, 0x9A, 0x00 }; // bottom left corner + char hl[] = { 0xE2, 0x95, 0x90, 0x00 }; // horiz line + char vl[] = { 0xE2, 0x95, 0x91, 0x00 }; // vert line char msg1 [60]; char msg2 [60]; char msg3 [60]; - strcpy (msg1," :snowflake: iceman@icesql.net :coffee:"); - strcpy (msg2," https://github.com/rfidresearchgroup/proxmark3/"); - strcpy (msg3,"pre-release v4.0"); + strcpy(msg1, " :snowflake: iceman@icesql.net :coffee:"); + strcpy(msg2, " https://github.com/rfidresearchgroup/proxmark3/"); + strcpy(msg3, "pre-release v4.0"); g_printAndLog = PRINTANDLOG_PRINT; PrintAndLogEx(NORMAL, "\n"); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s%s "),sq,sq,sq,sq,sq,sq,tr,sq,sq,sq,tr,sq,sq,sq,tr,sq,sq,sq,sq,tr); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s %s%s%s%s"),sq,sq,tl,hl,hl,sq,sq,tr,sq,sq,sq,sq,tr,sq,sq,sq,sq,vl,hl,hl,sq,vl); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s%s"),sq,sq,sq,sq,sq,sq,tl,br,sq,sq,tl,sq,sq,sq,sq,tl,sq,sq,vl,sq,sq,sq,sq,tl,br); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s%s%s%s %s%s%s%s")"%s",sq,sq,tr,hl,hl,hl,br,sq,sq,vl,bl,sq,sq,tl,br,sq,sq,vl,hl,hl,sq,vl,msg1); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s %s%s%s%s%s%s")"%s",sq,sq,vl,sq,sq,vl,bl,hl,br,sq,sq,vl,sq,sq,sq,sq,tl,br,msg2); - PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s%s%s ")"%s",bl,hl,br,bl,hl,br,bl,hl,br,bl,hl,hl,hl,br,msg3); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s%s "), sq, sq, sq, sq, sq, sq, tr, sq, sq, sq, tr, sq, sq, sq, tr, sq, sq, sq, sq, tr); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s %s%s%s%s"), sq, sq, tl, hl, hl, sq, sq, tr, sq, sq, sq, sq, tr, sq, sq, sq, sq, vl, hl, hl, sq, vl); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s%s"), sq, sq, sq, sq, sq, sq, tl, br, sq, sq, tl, sq, sq, sq, sq, tl, sq, sq, vl, sq, sq, sq, sq, tl, br); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s%s%s%s %s%s%s%s")"%s", sq, sq, tr, hl, hl, hl, br, sq, sq, vl, bl, sq, sq, tl, br, sq, sq, vl, hl, hl, sq, vl, msg1); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s %s%s%s%s%s%s")"%s", sq, sq, vl, sq, sq, vl, bl, hl, br, sq, sq, vl, sq, sq, sq, sq, tl, br, msg2); + PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s%s%s ")"%s", bl, hl, br, bl, hl, br, bl, hl, br, bl, hl, hl, hl, br, msg3); PrintAndLogEx(NORMAL, ""); fflush(stdout); @@ -82,7 +82,7 @@ static void showBanner(void) { #ifdef _WIN32 // If on windows and using UTF-8 then we need utf-8 ascii art for banner. if (GetConsoleCP() == 65001) { - utf8_showBanner (); + utf8_showBanner(); return; } #endif @@ -409,11 +409,11 @@ static void set_my_user_directory(void) { // if not found, default to current directory if (my_user_directory == NULL) { - my_user_directory = GetCurrentDir ( _cwd_Buffer,sizeof( _cwd_Buffer)); + my_user_directory = GetCurrentDir(_cwd_Buffer, sizeof(_cwd_Buffer)); // change all slashs to / (windows should not care... for (int i = 0; i < strlen(_cwd_Buffer); i++) if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/'; - // my_user_directory = "."; + // my_user_directory = "."; } } @@ -654,7 +654,7 @@ int main(int argc, char *argv[]) { #ifdef USE_PREFERENCE_FILE // Load Settings and assign // This will allow the command line to override the settings.json values - preferences_load (); + preferences_load(); // Change height/width (Rows,Cols) - Testing // printf ("\e[8;50;100t"); // printf ("\e[3;50;50t"); // x,y @@ -844,7 +844,7 @@ int main(int argc, char *argv[]) { } #ifndef USE_PREFERENCE_FILE - // comment next 2 lines to use session values set from settings_load + // comment next 2 lines to use session values set from settings_load session.supports_colors = DetectWindowsAnsiSupport(); session.emoji_mode = ALTTEXT; #endif @@ -859,12 +859,12 @@ int main(int argc, char *argv[]) { // struct stat tmp_stat; // if ((fstat (STDOUT_FILENO, &tmp_stat) == 0) && (S_ISCHR (tmp_stat.st_mode)) && isatty(STDIN_FILENO)) #ifdef USE_PREFERENCE_FILE - if (!session.preferences_loaded) { - if (session.stdinOnTTY && session.stdoutOnTTY) { - session.supports_colors = true; - session.emoji_mode = EMOJI; - } + if (!session.preferences_loaded) { + if (session.stdinOnTTY && session.stdoutOnTTY) { + session.supports_colors = true; + session.emoji_mode = EMOJI; } + } #else if (session.stdinOnTTY && session.stdoutOnTTY) { session.supports_colors = true; @@ -932,7 +932,7 @@ int main(int argc, char *argv[]) { // Doing this here will ensure other checks and updates are saved to over rule default // e.g. Linux color use check if (!session.preferences_loaded) { - preferences_save (); // Save defaults + preferences_save(); // Save defaults session.preferences_loaded = true; } #endif @@ -964,7 +964,7 @@ int main(int argc, char *argv[]) { #ifdef USE_PREFERENCE_FILE if (session.window_changed) // Plot/Overlay moved or resized - preferences_save (); + preferences_save(); #endif exit(EXIT_SUCCESS); } diff --git a/client/proxmark3.h b/client/src/proxmark3.h similarity index 100% rename from client/proxmark3.h rename to client/src/proxmark3.h diff --git a/client/scandir.c b/client/src/scandir.c similarity index 100% rename from client/scandir.c rename to client/src/scandir.c diff --git a/client/scandir.h b/client/src/scandir.h similarity index 100% rename from client/scandir.h rename to client/src/scandir.h diff --git a/client/scripting.c b/client/src/scripting.c similarity index 100% rename from client/scripting.c rename to client/src/scripting.c diff --git a/client/scripting.h b/client/src/scripting.h similarity index 100% rename from client/scripting.h rename to client/src/scripting.h diff --git a/client/tea.c b/client/src/tea.c similarity index 100% rename from client/tea.c rename to client/src/tea.c diff --git a/client/tea.h b/client/src/tea.h similarity index 100% rename from client/tea.h rename to client/src/tea.h diff --git a/client/uart/README.md b/client/src/uart/README.md similarity index 100% rename from client/uart/README.md rename to client/src/uart/README.md diff --git a/client/uart/uart.h b/client/src/uart/uart.h similarity index 100% rename from client/uart/uart.h rename to client/src/uart/uart.h diff --git a/client/uart/uart_posix.c b/client/src/uart/uart_posix.c similarity index 100% rename from client/uart/uart_posix.c rename to client/src/uart/uart_posix.c diff --git a/client/uart/uart_win32.c b/client/src/uart/uart_win32.c similarity index 100% rename from client/uart/uart_win32.c rename to client/src/uart/uart_win32.c diff --git a/client/ui.c b/client/src/ui.c similarity index 99% rename from client/ui.c rename to client/src/ui.c index 5097b28f1..bb3039b05 100644 --- a/client/ui.c +++ b/client/src/ui.c @@ -130,7 +130,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) { // skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0' if (g_debugMode == 0 && level == DEBUG) return; - + // skip HINT messages if client has hints turned off i.e. 'HINT 0' if (session.show_hints == false && level == HINT) return; @@ -143,7 +143,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) { FILE *stream = stdout; const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")}; const char *spinner_emoji[] = {" :clock1: ", " :clock2: ", " :clock3: ", " :clock4: ", " :clock5: ", " :clock6: ", - " :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "}; + " :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: " + }; switch (level) { case ERR: if (session.emoji_mode == EMOJI) @@ -433,7 +434,7 @@ void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode const char *emojified_token = NULL; uint8_t emojified_token_length = 0; char *current_token = NULL; - uint8_t current_token_length=0; + uint8_t current_token_length = 0; char current_char; char *rdest = (char *)dest; char *rsrc = (char *)src; diff --git a/client/ui.h b/client/src/ui.h similarity index 97% rename from client/ui.h rename to client/src/ui.h index e28eca530..24c4b7201 100644 --- a/client/ui.h +++ b/client/src/ui.h @@ -19,7 +19,7 @@ typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t; typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t; -typedef enum clientdebugLevel {OFF,SIMPLE,FULL} clientdebugLevel_t; +typedef enum clientdebugLevel {OFF, SIMPLE, FULL} clientdebugLevel_t; typedef struct { bool preferences_loaded; diff --git a/client/ui/overlays.ui b/client/src/ui/overlays.ui similarity index 100% rename from client/ui/overlays.ui rename to client/src/ui/overlays.ui diff --git a/client/util.c b/client/src/util.c similarity index 100% rename from client/util.c rename to client/src/util.c diff --git a/client/util.h b/client/src/util.h similarity index 100% rename from client/util.h rename to client/src/util.h diff --git a/client/util_darwin.h b/client/src/util_darwin.h similarity index 100% rename from client/util_darwin.h rename to client/src/util_darwin.h diff --git a/client/util_darwin.m b/client/src/util_darwin.m similarity index 100% rename from client/util_darwin.m rename to client/src/util_darwin.m diff --git a/client/whereami.c b/client/src/whereami.c similarity index 99% rename from client/whereami.c rename to client/src/whereami.c index 923115318..30d70c4d9 100644 --- a/client/whereami.c +++ b/client/src/whereami.c @@ -7,7 +7,7 @@ extern "C" { #endif -#include +#include "whereami.h" #if defined(__linux__) // make realpath() available: @@ -272,7 +272,7 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) { char *begin; char *p; - begin = (char*)mmap(0, offset + sizeof(p), PROT_READ, MAP_SHARED, fd, 0); + begin = (char *)mmap(0, offset + sizeof(p), PROT_READ, MAP_SHARED, fd, 0); p = begin + offset; while (p >= begin) { // scan backwards diff --git a/client/whereami.h b/client/src/whereami.h similarity index 100% rename from client/whereami.h rename to client/src/whereami.h diff --git a/client/wiegand_formats.c b/client/src/wiegand_formats.c similarity index 100% rename from client/wiegand_formats.c rename to client/src/wiegand_formats.c diff --git a/client/wiegand_formats.h b/client/src/wiegand_formats.h similarity index 100% rename from client/wiegand_formats.h rename to client/src/wiegand_formats.h diff --git a/client/wiegand_formatutils.c b/client/src/wiegand_formatutils.c similarity index 100% rename from client/wiegand_formatutils.c rename to client/src/wiegand_formatutils.c diff --git a/client/wiegand_formatutils.h b/client/src/wiegand_formatutils.h similarity index 100% rename from client/wiegand_formatutils.h rename to client/src/wiegand_formatutils.h diff --git a/common/cardhelper.c b/common/cardhelper.c index df3aff5be..03af2d799 100644 --- a/common/cardhelper.c +++ b/common/cardhelper.c @@ -91,4 +91,4 @@ uint8_t GetNumberBlocksForUserId(uint8_t *src) { memcpy(c + 5, src, 8); ExchangeAPDUSC(true, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len); return resp[8]; -} \ No newline at end of file +} diff --git a/common/generator.c b/common/generator.c index fa1fd7cd3..a456c6b78 100644 --- a/common/generator.c +++ b/common/generator.c @@ -34,7 +34,7 @@ // XYZ 3D printing // Vinglock //------------------------------------ -void transform_D(uint8_t* ru) { +void transform_D(uint8_t *ru) { const uint32_t c_D[] = { 0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8, @@ -44,32 +44,31 @@ void transform_D(uint8_t* ru) { 0x5728B869, 0x30726D5A }; - //Transform - uint8_t i; - uint8_t p = 0; - uint32_t v1 = ((ru[3] << 24) | (ru[2] << 16) | (ru[1] << 8) | ru[0]) + c_D[p++]; - uint32_t v2 = ((ru[7] << 24) | (ru[6] << 16) | (ru[5] << 8) | ru[4]) + c_D[p++]; - for (i = 0; i < 12; i += 2) - { - uint32_t tempA = v1 ^ v2; - uint32_t t1 = PM3_ROTL(tempA, v2 & 0x1F) + c_D[p++]; - uint32_t tempB = v2 ^ t1; - uint32_t t2 = PM3_ROTL(tempB, t1 & 0x1F) + c_D[p++]; - tempA = t1 ^ t2; - v1 = PM3_ROTL(tempA, t2 & 0x1F) + c_D[p++]; - tempB = t2 ^ v1; - v2 = PM3_ROTL(tempB, v1 & 0x1F) + c_D[p++]; - } + //Transform + uint8_t i; + uint8_t p = 0; + uint32_t v1 = ((ru[3] << 24) | (ru[2] << 16) | (ru[1] << 8) | ru[0]) + c_D[p++]; + uint32_t v2 = ((ru[7] << 24) | (ru[6] << 16) | (ru[5] << 8) | ru[4]) + c_D[p++]; + for (i = 0; i < 12; i += 2) { + uint32_t tempA = v1 ^ v2; + uint32_t t1 = PM3_ROTL(tempA, v2 & 0x1F) + c_D[p++]; + uint32_t tempB = v2 ^ t1; + uint32_t t2 = PM3_ROTL(tempB, t1 & 0x1F) + c_D[p++]; + tempA = t1 ^ t2; + v1 = PM3_ROTL(tempA, t2 & 0x1F) + c_D[p++]; + tempB = t2 ^ v1; + v2 = PM3_ROTL(tempB, v1 & 0x1F) + c_D[p++]; + } - //Re-use ru - ru[0] = v1 & 0xFF; - ru[1] = (v1 >> 8) & 0xFF; - ru[2] = (v1 >> 16) & 0xFF; - ru[3] = (v1 >> 24) & 0xFF; - ru[4] = v2 & 0xFF; - ru[5] = (v2 >> 8) & 0xFF; - ru[6] = (v2 >> 16) & 0xFF; - ru[7] = (v2 >> 24) & 0xFF; + //Re-use ru + ru[0] = v1 & 0xFF; + ru[1] = (v1 >> 8) & 0xFF; + ru[2] = (v1 >> 16) & 0xFF; + ru[3] = (v1 >> 24) & 0xFF; + ru[4] = v2 & 0xFF; + ru[5] = (v2 >> 8) & 0xFF; + ru[6] = (v2 >> 16) & 0xFF; + ru[7] = (v2 >> 24) & 0xFF; } // Transport system (IT) pwd generation algo nickname A. @@ -136,16 +135,16 @@ uint32_t ul_ev1_pwdgenD(uint8_t *uid) { uint8_t r = (uid[1] + uid[3] + uid[5]) & 7; // rotated UID - uint8_t ru[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + uint8_t ru[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; for (i = 0; i < 7; i++) ru[(i + r) & 7] = uid[i]; transform_D(ru); - // offset + // offset r = (ru[0] + ru[2] + ru[4] + ru[6]) & 3; - // calc key + // calc key uint32_t pwd = 0; for (i = 0; i < 4; i++) pwd = ru[i + r] + (pwd << 8); @@ -429,28 +428,28 @@ int generator_selftest() { uint8_t uid1[] = {0x04, 0x11, 0x12, 0x11, 0x12, 0x11, 0x10}; uint32_t pwd1 = ul_ev1_pwdgenA(uid1); success = (pwd1 == 0x8432EB17); - if (success) + if (success) testresult++; PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid1, 7), pwd1, success ? "OK" : "->8432EB17<-"); uint8_t uid2[] = {0x04, 0x1f, 0x98, 0xea, 0x1e, 0x3e, 0x81}; uint32_t pwd2 = ul_ev1_pwdgenB(uid2); success = (pwd2 == 0x5fd37eca); - if (success) + if (success) testresult++; PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid2, 7), pwd2, success ? "OK" : "->5fd37eca<--"); uint8_t uid3[] = {0x04, 0x62, 0xB6, 0x8A, 0xB4, 0x42, 0x80}; uint32_t pwd3 = ul_ev1_pwdgenC(uid3); success = (pwd3 == 0x5a349515); - if (success) + if (success) testresult++; PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid3, 7), pwd3, success ? "OK" : "->5a349515<--"); uint8_t uid4[] = {0x04, 0xC5, 0xDF, 0x4A, 0x6D, 0x51, 0x80}; uint32_t pwd4 = ul_ev1_pwdgenD(uid4); success = (pwd4 == 0x72B1EC61); - if (success) + if (success) testresult++; PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid4, 7), pwd4, success ? "OK" : "->72B1EC61<--"); @@ -463,7 +462,7 @@ int generator_selftest() { uint64_t key6 = 0; mfc_algo_sky_one(uid6, 15, 0, &key6); success = (key6 == 0x82c7e64bc565); - if (success) + if (success) testresult++; PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %"PRIx64" - %s", sprint_hex(uid6, 4), key6, success ? "OK" : "->82C7E64BC565<--");