diff --git a/README.md b/README.md index 350763c34..b306ad542 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # RRG / Iceman repo - Proxmark3 -This repo is based on iceman fork for Proxmark3. It supports other Proxmark3 platforms as well. +This repo is based on iceman fork for Proxmark3. -It is dedicated to bringing the most out of the new features for Proxmark3 RDV4.0 new hardware and design. +It supports RDV4.0 and other Proxmark3 platforms as well. | Releases | Linux & OSX CI | Windows CI | Coverity | diff --git a/armsrc/spiffs.c b/armsrc/spiffs.c index 629dff422..f242062be 100644 --- a/armsrc/spiffs.c +++ b/armsrc/spiffs.c @@ -536,21 +536,28 @@ int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, R //////////////////////////////////////////////////////////////////////////////// ///////// MISC HIGH LEVEL FUNCTIONS //////////////////////////////////////////// +#define SPIFFS_BANNER DbpString(_BLUE_("Flash Memory FileSystem tree (SPIFFS)")); void rdv40_spiffs_safe_print_fsinfo() { rdv40_spiffs_fsinfo fsinfo; rdv40_spiffs_getfsinfo(&fsinfo, RDV40_SPIFFS_SAFETY_SAFE); + DbpString(_BLUE_("Flash Memory FileSystem Info (SPIFFS)")); - Dbprintf("-------------------------------------"); - Dbprintf("* Filesystem Logical Block Size.........%d bytes", fsinfo.blockSize); - Dbprintf("* Filesystem Logical Page Size..........%d bytes", fsinfo.pageSize); - Dbprintf("--"); - Dbprintf("* Filesystem Max Open Files.............%d file descriptors", fsinfo.maxOpenFiles); - Dbprintf("* Filesystem Max Path Length............%d chars", fsinfo.maxPathLength); - Dbprintf("--"); - Dbprintf("Filesystem\tSize\tUsed\tAvailable\tUse%\tMounted on"); - Dbprintf("spiffs\t%dB\t%dB\t%dB\t\t%d%\t/", fsinfo.totalBytes, fsinfo.usedBytes, fsinfo.freeBytes, - fsinfo.usedPercent); + + + Dbprintf(" Logical Block Size........." _YELLOW_("%d")"bytes", fsinfo.blockSize); + Dbprintf(" Logical Page Size.........." _YELLOW_("%d")"bytes", fsinfo.pageSize); + Dbprintf(""); + Dbprintf(" Max Open Files............." _YELLOW_("%d")"file descriptors", fsinfo.maxOpenFiles); + Dbprintf(" Max Path Length............" _YELLOW_("%d")"chars", fsinfo.maxPathLength); + DbpString(""); + Dbprintf(" filesystem size used available use% mounted"); + Dbprintf(" spiffs %6d B %6d B %6d B"_YELLOW_("%2d%")" /" + , fsinfo.totalBytes + , fsinfo.usedBytes + , fsinfo.freeBytes + , fsinfo.usedPercent + ); } // this function is safe and WILL rollback since it is only a PRINTING function, @@ -562,14 +569,16 @@ void rdv40_spiffs_safe_print_fsinfo() { // dont want, as prefix are way easier and lighter in every aspect. void rdv40_spiffs_safe_print_tree(uint8_t banner) { - int changed = rdv40_spiffs_lazy_mount(); - spiffs_DIR d; - struct spiffs_dirent e; - struct spiffs_dirent *pe = &e; if (banner) { DbpString(_BLUE_("Flash Memory FileSystem tree (SPIFFS)")); Dbprintf("-------------------------------------"); } + + int changed = rdv40_spiffs_lazy_mount(); + spiffs_DIR d; + struct spiffs_dirent e; + struct spiffs_dirent *pe = &e; + SPIFFS_opendir(&fs, "/", &d); Dbprintf(" \t \t/"); while ((pe = SPIFFS_readdir(&d, pe))) { @@ -592,29 +601,40 @@ void rdv40_spiffs_safe_print_tree(uint8_t banner) { rdv40_spiffs_lazy_mount_rollback(changed); } + +// Selftest function void test_spiffs() { - Dbprintf("---------------------------"); + Dbprintf("----------------------------------------------"); Dbprintf("Testing SPIFFS operations"); - Dbprintf("---------------------------"); - Dbprintf("(all test are made using lazy safetylevel)"); - Dbprintf("* Mounting filesystem (lazy)......."); + Dbprintf("----------------------------------------------"); + Dbprintf("-- all test are made using lazy safetylevel"); + + Dbprintf(" Mounting filesystem (lazy)......."); int changed = rdv40_spiffs_lazy_mount(); - Dbprintf("* Printing tree.............."); + + Dbprintf(" Printing tree.............."); rdv40_spiffs_safe_print_tree(false); - Dbprintf("* Writing 'I love Proxmark' in a testspiffs.txt"); + + Dbprintf(" Writing 'I love Proxmark3 RDV4' in a testspiffs.txt"); + // Since We lazy_mounted manually before hand, the wrte safety level will // just imply noops - rdv40_spiffs_write((char *)"testspiffs.txt", (uint8_t *)"I love Proxmark", 15, RDV40_SPIFFS_SAFETY_SAFE); - Dbprintf("* Printing tree again......."); + rdv40_spiffs_write((char *)"testspiffs.txt", (uint8_t *)"I love Proxmark3 RDV4", 21, RDV40_SPIFFS_SAFETY_SAFE); + + Dbprintf(" Printing tree again......."); rdv40_spiffs_safe_print_tree(false); - Dbprintf("* Making a symlink to testspiffs.txt"); + + Dbprintf(" Making a symlink to testspiffs.txt"); rdv40_spiffs_make_symlink((char *)"testspiffs.txt", (char *)"linktotestspiffs.txt", RDV40_SPIFFS_SAFETY_SAFE); - Dbprintf("* Printing tree again......."); + + Dbprintf(" Printing tree again......."); rdv40_spiffs_safe_print_tree(false); + // TODO READBACK, rename,print tree read back, remove, print tree; - Dbprintf("* Rollbacking The mount status IF things have changed"); + Dbprintf(" Rollbacking The mount status IF things have changed"); rdv40_spiffs_lazy_mount_rollback(changed); - Dbprintf("All done"); + + Dbprintf(_GREEN_("All done")); return; } diff --git a/client/Makefile b/client/Makefile index 58bdf7592..1fef2cd9b 100644 --- a/client/Makefile +++ b/client/Makefile @@ -109,9 +109,11 @@ ifneq ($(SKIPQT),1) endif ifneq ($(QTLDLIBS),) + QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o PM3CFLAGS += -DHAVE_GUI else + QTGUISRCS = guidummy.cpp QTGUIOBJS = $(OBJDIR)/guidummy.o endif @@ -257,7 +259,6 @@ ifeq ($(MULTIARCHSRCS), ) CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c endif -QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o) CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o) diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 3ae332397..16e4029db 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -2920,7 +2920,7 @@ void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose) { if (k_sector == NULL) emptySectorTable(); - success = mfkey32_moebius(data, &key); + success = mfkey32_moebius(&data, &key); if (success) { uint8_t sector = data.sector; uint8_t keytype = data.keytype; diff --git a/client/cmdlf.c b/client/cmdlf.c index 57c28c1b0..4d7c72acc 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -63,12 +63,12 @@ static int usage_lf_cmdread(void) { PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h This help"); PrintAndLogEx(NORMAL, " d delay OFF period, (0 for bitbang mode) (decimal)"); - PrintAndLogEx(NORMAL, " z time period ZERO, (decimal)"); - PrintAndLogEx(NORMAL, " o time period ONE, (decimal)"); - PrintAndLogEx(NORMAL, " c Command bytes (in ones and zeros)"); + PrintAndLogEx(NORMAL, " z ZERO time period (decimal)"); + PrintAndLogEx(NORMAL, " o ONE time period (decimal)"); + PrintAndLogEx(NORMAL, " c Command bytes (in ones and zeros)"); PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(NORMAL, " ************* All periods in microseconds (ms)"); - PrintAndLogEx(NORMAL, " ************* Use lf config to configure options."); + PrintAndLogEx(NORMAL, " ************* " _YELLOW_("All periods in microseconds (us)")); + PrintAndLogEx(NORMAL, " ************* Use " _YELLOW_("'lf config'") "to configure options."); PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, " lf cmdread d 80 z 100 o 200 c 11000"); return PM3_SUCCESS; @@ -77,7 +77,7 @@ static int usage_lf_read(void) { PrintAndLogEx(NORMAL, "Usage: lf read [h] [s] [d numofsamples]"); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h This help"); - PrintAndLogEx(NORMAL, " s silent run no printout"); + PrintAndLogEx(NORMAL, " s silent run, no printout"); PrintAndLogEx(NORMAL, " d #samples # samples to collect (optional)"); PrintAndLogEx(NORMAL, "Use 'lf config' to set parameters."); PrintAndLogEx(NORMAL, ""); diff --git a/client/cmdlfawid.c b/client/cmdlfawid.c index afd2206f3..e9fe6d6e1 100644 --- a/client/cmdlfawid.c +++ b/client/cmdlfawid.c @@ -523,7 +523,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "this help"}, {"demod", CmdAWIDDemod, AlwaysAvailable, "demodulate an AWID FSK tag from the GraphBuffer"}, {"read", CmdAWIDRead, IfPm3Lf, "attempt to read and extract tag data"}, - {"clone", CmdAWIDClone, IfPm3Lf, "clone AWID to T55x7"}, + {"clone", CmdAWIDClone, IfPm3Lf, "clone AWID tag to T55x7 (or to q5/T5555)"}, {"sim", CmdAWIDSim, IfPm3Lf, "simulate AWID tag"}, {"brute", CmdAWIDBrute, IfPm3Lf, "Bruteforce card number against reader"}, {"watch", CmdAWIDWatch, IfPm3Lf, "continuously watch for cards. Reader mode"}, diff --git a/client/cmdlfgallagher.c b/client/cmdlfgallagher.c index d32c9ade9..f8d513a13 100644 --- a/client/cmdlfgallagher.c +++ b/client/cmdlfgallagher.c @@ -135,7 +135,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdGallagherDemod, AlwaysAvailable, "Demodulate an GALLAGHER tag from the GraphBuffer"}, {"read", CmdGallagherRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdGallagherClone, IfPm3Lf, "clone GALLAGHER tag"}, + {"clone", CmdGallagherClone, IfPm3Lf, "clone GALLAGHER tag to T55x7"}, {"sim", CmdGallagherSim, IfPm3Lf, "simulate GALLAGHER tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfguard.c b/client/cmdlfguard.c index a8cd8a65b..79ec13c71 100644 --- a/client/cmdlfguard.c +++ b/client/cmdlfguard.c @@ -238,7 +238,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "this help"}, {"demod", CmdGuardDemod, AlwaysAvailable, "demodulate a G Prox II tag from the GraphBuffer"}, {"read", CmdGuardRead, IfPm3Lf, "attempt to read and extract tag data from the antenna"}, - {"clone", CmdGuardClone, IfPm3Lf, "clone Guardall tag"}, + {"clone", CmdGuardClone, IfPm3Lf, "clone Guardall tag to T55x7"}, {"sim", CmdGuardSim, IfPm3Lf, "simulate Guardall tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index 004248e43..f5ad3717b 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -452,7 +452,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "this help"}, {"demod", CmdHIDDemod, AlwaysAvailable, "demodulate HID Prox tag from the GraphBuffer"}, {"read", CmdHIDRead, IfPm3Lf, "attempt to read and extract tag data"}, - {"clone", CmdHIDClone, IfPm3Lf, "clone HID to T55x7"}, + {"clone", CmdHIDClone, IfPm3Lf, "clone HID tag to T55x7"}, {"sim", CmdHIDSim, IfPm3Lf, "simulate HID tag"}, {"brute", CmdHIDBrute, IfPm3Lf, "bruteforce card number against reader"}, {"watch", CmdHIDWatch, IfPm3Lf, "continuously watch for cards. Reader mode"}, diff --git a/client/cmdlfindala.c b/client/cmdlfindala.c index e57368400..443435f88 100644 --- a/client/cmdlfindala.c +++ b/client/cmdlfindala.c @@ -534,7 +534,7 @@ static command_t CommandTable[] = { {"demod", CmdIndalaDemod, AlwaysAvailable, "demodulate an indala tag (PSK1) from GraphBuffer"}, {"altdemod", CmdIndalaDemodAlt, AlwaysAvailable, "alternative method to Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, {"read", CmdIndalaRead, IfPm3Lf, "read an Indala Prox tag from the antenna"}, - {"clone", CmdIndalaClone, IfPm3Lf, "clone Indala to T55x7"}, + {"clone", CmdIndalaClone, IfPm3Lf, "clone Indala tag to T55x7"}, {"sim", CmdIndalaSim, IfPm3Lf, "simulate Indala tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfio.c b/client/cmdlfio.c index 3aefd7b55..57a8a64d1 100644 --- a/client/cmdlfio.c +++ b/client/cmdlfio.c @@ -282,7 +282,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "this help"}, {"demod", CmdIOProxDemod, AlwaysAvailable, "demodulate an IOProx tag from the GraphBuffer"}, {"read", CmdIOProxRead, IfPm3Lf, "attempt to read and extract tag data"}, - {"clone", CmdIOProxClone, IfPm3Lf, "clone IOProx to T55x7"}, + {"clone", CmdIOProxClone, IfPm3Lf, "clone IOProx tag to T55x7 (or to q5/T5555)"}, {"sim", CmdIOProxSim, IfPm3Lf, "simulate IOProx tag"}, {"watch", CmdIOProxWatch, IfPm3Lf, "continuously watch for cards. Reader mode"}, {NULL, NULL, NULL, NULL} diff --git a/client/cmdlfjablotron.c b/client/cmdlfjablotron.c index 3633902f2..a1f5b0592 100644 --- a/client/cmdlfjablotron.c +++ b/client/cmdlfjablotron.c @@ -217,7 +217,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdJablotronDemod, AlwaysAvailable, "Demodulate an Jablotron tag from the GraphBuffer"}, {"read", CmdJablotronRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdJablotronClone, IfPm3Lf, "clone jablotron tag"}, + {"clone", CmdJablotronClone, IfPm3Lf, "clone jablotron tag to T55x7 (or to q5/T5555)"}, {"sim", CmdJablotronSim, IfPm3Lf, "simulate jablotron tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfkeri.c b/client/cmdlfkeri.c index 9e9bbdb49..b36be56b9 100644 --- a/client/cmdlfkeri.c +++ b/client/cmdlfkeri.c @@ -209,7 +209,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdKeriDemod, AlwaysAvailable, "Demodulate an KERI tag from the GraphBuffer"}, {"read", CmdKeriRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdKeriClone, IfPm3Lf, "clone KERI to T55x7"}, + {"clone", CmdKeriClone, IfPm3Lf, "clone KERI tag to T55x7 (or to q5/T5555)"}, {"sim", CmdKeriSim, IfPm3Lf, "simulate KERI tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfmotorola.c b/client/cmdlfmotorola.c index e306827ed..87ea53a3b 100644 --- a/client/cmdlfmotorola.c +++ b/client/cmdlfmotorola.c @@ -192,7 +192,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdMotorolaDemod, AlwaysAvailable, "Demodulate an MOTOROLA tag from the GraphBuffer"}, {"read", CmdMotorolaRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdMotorolaClone, IfPm3Lf, "clone MOTOROLA to T55x7"}, + {"clone", CmdMotorolaClone, IfPm3Lf, "clone MOTOROLA tag to T55x7"}, {"sim", CmdMotorolaSim, IfPm3Lf, "simulate MOTOROLA tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfnexwatch.c b/client/cmdlfnexwatch.c index 8d40d47d6..1a204ed41 100644 --- a/client/cmdlfnexwatch.c +++ b/client/cmdlfnexwatch.c @@ -152,7 +152,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdNexWatchDemod, AlwaysAvailable, "Demodulate a NexWatch tag (nexkey, quadrakey) from the GraphBuffer"}, {"read", CmdNexWatchRead, IfPm3Lf, "Attempt to Read and Extract tag data from the antenna"}, - {"clone", CmdNexWatchClone, IfPm3Lf, "clone NexWatch tag"}, + {"clone", CmdNexWatchClone, IfPm3Lf, "clone NexWatch tag to T55x7"}, {"sim", CmdNexWatchSim, IfPm3Lf, "simulate NexWatch tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfnoralsy.c b/client/cmdlfnoralsy.c index 79fbb3913..ceebb8e2d 100644 --- a/client/cmdlfnoralsy.c +++ b/client/cmdlfnoralsy.c @@ -219,7 +219,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdNoralsyDemod, AlwaysAvailable, "Demodulate an Noralsy tag from the GraphBuffer"}, {"read", CmdNoralsyRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdNoralsyClone, IfPm3Lf, "clone Noralsy to T55x7"}, + {"clone", CmdNoralsyClone, IfPm3Lf, "clone Noralsy tag to T55x7 (or to q5/T5555)"}, {"sim", CmdNoralsySim, IfPm3Lf, "simulate Noralsy tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfpac.c b/client/cmdlfpac.c index 9b735f02e..eb1b20cd9 100644 --- a/client/cmdlfpac.c +++ b/client/cmdlfpac.c @@ -135,7 +135,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdPacDemod, AlwaysAvailable, "Demodulate an PAC tag from the GraphBuffer"}, {"read", CmdPacRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdPacClone, IfPm3Lf, "clone PAC tag"}, + {"clone", CmdPacClone, IfPm3Lf, "clone PAC tag to T55x7"}, {"sim", CmdPacSim, IfPm3Lf, "simulate PAC tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfparadox.c b/client/cmdlfparadox.c index d2c8d64b5..c154e7efa 100644 --- a/client/cmdlfparadox.c +++ b/client/cmdlfparadox.c @@ -224,7 +224,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdParadoxDemod, AlwaysAvailable, "Demodulate a Paradox FSK tag from the GraphBuffer"}, {"read", CmdParadoxRead, IfPm3Lf, "Attempt to read and Extract tag data from the antenna"}, - {"clone", CmdParadoxClone, IfPm3Lf, "clone paradox tag"}, + {"clone", CmdParadoxClone, IfPm3Lf, "clone paradox tag to T55x7"}, {"sim", CmdParadoxSim, IfPm3Lf, "simulate paradox tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfpresco.c b/client/cmdlfpresco.c index 06645e86f..abce377f4 100644 --- a/client/cmdlfpresco.c +++ b/client/cmdlfpresco.c @@ -176,7 +176,7 @@ static int CmdPrescoSim(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"read", CmdPrescoRead, IfPm3Lf, "Attempt to read and Extract tag data"}, - {"clone", CmdPrescoClone, IfPm3Lf, "clone presco tag"}, + {"clone", CmdPrescoClone, IfPm3Lf, "clone presco tag to T55x7 (or to q5/T5555)"}, {"sim", CmdPrescoSim, IfPm3Lf, "simulate presco tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index d8c9511a6..a36bd34e3 100644 --- a/client/cmdlfpyramid.c +++ b/client/cmdlfpyramid.c @@ -300,7 +300,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "this help"}, {"demod", CmdPyramidDemod, AlwaysAvailable, "demodulate a Pyramid FSK tag from the GraphBuffer"}, {"read", CmdPyramidRead, IfPm3Lf, "attempt to read and extract tag data"}, - {"clone", CmdPyramidClone, IfPm3Lf, "clone pyramid tag"}, + {"clone", CmdPyramidClone, IfPm3Lf, "clone pyramid tag to T55x7 (or to q5/T5555)"}, {"sim", CmdPyramidSim, IfPm3Lf, "simulate pyramid tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfsecurakey.c b/client/cmdlfsecurakey.c index 64e8a2121..48ec731ce 100644 --- a/client/cmdlfsecurakey.c +++ b/client/cmdlfsecurakey.c @@ -180,7 +180,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdSecurakeyDemod, AlwaysAvailable, "Demodulate an Securakey tag from the GraphBuffer"}, {"read", CmdSecurakeyRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, - {"clone", CmdSecurakeyClone, IfPm3Lf, "clone Securakey tag"}, + {"clone", CmdSecurakeyClone, IfPm3Lf, "clone Securakey tag to T55x7"}, {"sim", CmdSecurakeySim, IfPm3Lf, "simulate Securakey tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 1607dc746..e1f84b32b 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -371,8 +371,42 @@ static int usage_t55xx_dangerraw() { return PM3_SUCCESS; } +static int usage_t55xx_clonehelp(){ + PrintAndLogEx(NORMAL, "For cloning specific techs on T55xx tags, see commands available in corresponding LF sub-menus, e.g.:"); + PrintAndLogEx(NORMAL, _GREEN_("lf awid clone")); +// todo: rename to clone + PrintAndLogEx(NORMAL, _GREEN_("lf em 410x_write")); +// todo: implement restore +// PrintAndLogEx(NORMAL, _GREEN_("lf em 4x05_write")); +// PrintAndLogEx(NORMAL, _GREEN_("lf em 4x50_write")); + PrintAndLogEx(NORMAL, _GREEN_("lf fdx clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf gallagher clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf gproxii clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf hid clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf indala clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf io clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf jablotron clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf keri clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf nedap clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf noralsy clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf motorola clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf pac clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf paradox clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf presco clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf pyramid clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf securakey clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf viking clone")); + PrintAndLogEx(NORMAL, _GREEN_("lf visa2000 clone")); + return PM3_SUCCESS; +} + static int CmdHelp(const char *Cmd); +static int CmdT55xxCloneHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + return usage_t55xx_clonehelp(); +} + void T55x7_SaveBlockData(uint8_t idx, uint32_t data) { if (idx < T55x7_BLOCK_COUNT) { cardmem[idx].valid = true; @@ -3652,6 +3686,7 @@ static command_t CommandTable[] = { {"bruteforce", CmdT55xxBruteForce, IfPm3Lf, " Simple bruteforce attack to find password"}, {"config", CmdT55xxSetConfig, AlwaysAvailable, "Set/Get T55XX configuration (modulation, inverted, offset, rate)"}, {"chk", CmdT55xxChkPwds, IfPm3Lf, "Check passwords from dictionary/flash"}, + {"clonehelp", CmdT55xxCloneHelp, IfPm3Lf, "Shows the available clone commands"}, {"dangerraw", CmdT55xxDangerousRaw, IfPm3Lf, "Sends raw bitstream. Dangerous, do not use!! b t "}, {"detect", CmdT55xxDetect, AlwaysAvailable, "[1] Try detecting the tag modulation from reading the configuration block."}, {"deviceconfig", CmdT55xxSetDeviceConfig, IfPm3Lf, "Set/Get T55XX device configuration (startgap, writegap, write0, write1, readgap"}, diff --git a/client/cmdlfviking.c b/client/cmdlfviking.c index 3a2ad6a5d..c404b4f0a 100644 --- a/client/cmdlfviking.c +++ b/client/cmdlfviking.c @@ -160,8 +160,8 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdVikingDemod, AlwaysAvailable, "Demodulate a Viking tag from the GraphBuffer"}, {"read", CmdVikingRead, IfPm3Lf, "Attempt to read and Extract tag data from the antenna"}, - {"clone", CmdVikingClone, IfPm3Lf, "<8 digit ID number> clone viking tag"}, - {"sim", CmdVikingSim, IfPm3Lf, "<8 digit ID number> simulate viking tag"}, + {"clone", CmdVikingClone, IfPm3Lf, "clone Viking tag to T55x7 (or to q5/T5555)"}, + {"sim", CmdVikingSim, IfPm3Lf, "simulate Viking tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdlfvisa2000.c b/client/cmdlfvisa2000.c index a32dc5aeb..677562e12 100644 --- a/client/cmdlfvisa2000.c +++ b/client/cmdlfvisa2000.c @@ -228,7 +228,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"demod", CmdVisa2kDemod, AlwaysAvailable, "demodulate an VISA2000 tag from the GraphBuffer"}, {"read", CmdVisa2kRead, IfPm3Lf, "attempt to read and extract tag data from the antenna"}, - {"clone", CmdVisa2kClone, IfPm3Lf, "clone Visa2000 to t55x7"}, + {"clone", CmdVisa2kClone, IfPm3Lf, "clone Visa2000 tag to T55x7 (or to q5/T5555)"}, {"sim", CmdVisa2kSim, IfPm3Lf, "simulate Visa2000 tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/cmdparser.c b/client/cmdparser.c index f116b5ecd..72628f2fb 100644 --- a/client/cmdparser.c +++ b/client/cmdparser.c @@ -154,9 +154,11 @@ void CmdsHelp(const command_t Commands[]) { if (Commands[0].Name == NULL) return; int i = 0; while (Commands[i].Name) { - if (Commands[i].IsAvailable()) -// PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); - printf(_GREEN_("%-16s")" %s\n", Commands[i].Name, Commands[i].Help); + if (Commands[i].IsAvailable()) { + g_printAndLog = PRINTANDLOG_PRINT; + PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); + g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; + } ++i; } } diff --git a/client/hardnested/hardnested_bruteforce.c b/client/hardnested/hardnested_bruteforce.c index 3aea34a96..4af190d71 100644 --- a/client/hardnested/hardnested_bruteforce.c +++ b/client/hardnested/hardnested_bruteforce.c @@ -164,7 +164,7 @@ crack_states_thread(void *x) { statelist_t *bucket = buckets[current_bucket]; if (bucket) { #if defined (DEBUG_BRUTE_FORCE) - printf("Thread %u starts working on bucket %u\n", thread_id, current_bucket); + PrintAndLogEx(INFO, "Thread %u starts working on bucket %u\n", thread_id, current_bucket); #endif const uint64_t key = crack_states_bitsliced(thread_arg->cuid, thread_arg->best_first_bytes, bucket, &keys_found, &num_keys_tested, nonces_to_bruteforce, bf_test_nonce_2nd_byte, thread_arg->nonces); if (key != -1) { diff --git a/client/mifare/mfkey.c b/client/mifare/mfkey.c index bdccd302e..ee0c9f052 100644 --- a/client/mifare/mfkey.c +++ b/client/mifare/mfkey.c @@ -89,25 +89,25 @@ uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t } // recover key from 2 different reader responses on same tag challenge -bool mfkey32(nonces_t data, uint64_t *outputkey) { +bool mfkey32(nonces_t *data, uint64_t *outputkey) { struct Crypto1State *s, *t; uint64_t outkey = 0; uint64_t key = 0; // recovered key bool isSuccess = false; uint8_t counter = 0; - uint32_t p640 = prng_successor(data.nonce, 64); + uint32_t p640 = prng_successor(data->nonce, 64); - s = lfsr_recovery32(data.ar ^ p640, 0); + s = lfsr_recovery32(data->ar ^ p640, 0); for (t = s; t->odd | t->even; ++t) { lfsr_rollback_word(t, 0, 0); - lfsr_rollback_word(t, data.nr, 1); - lfsr_rollback_word(t, data.cuid ^ data.nonce, 0); + lfsr_rollback_word(t, data->nr, 1); + lfsr_rollback_word(t, data->cuid ^ data->nonce, 0); crypto1_get_lfsr(t, &key); - crypto1_word(t, data.cuid ^ data.nonce, 0); - crypto1_word(t, data.nr2, 1); - if (data.ar2 == (crypto1_word(t, 0, 0) ^ p640)) { + crypto1_word(t, data->cuid ^ data->nonce, 0); + crypto1_word(t, data->nr2, 1); + if (data->ar2 == (crypto1_word(t, 0, 0) ^ p640)) { outkey = key; counter++; if (counter == 20) break; @@ -121,26 +121,26 @@ bool mfkey32(nonces_t data, uint64_t *outputkey) { // recover key from 2 reader responses on 2 different tag challenges // skip "several found keys". Only return true if ONE key is found -bool mfkey32_moebius(nonces_t data, uint64_t *outputkey) { +bool mfkey32_moebius(nonces_t *data, uint64_t *outputkey) { struct Crypto1State *s, *t; uint64_t outkey = 0; uint64_t key = 0; // recovered key bool isSuccess = false; int counter = 0; - uint32_t p640 = prng_successor(data.nonce, 64); - uint32_t p641 = prng_successor(data.nonce2, 64); + uint32_t p640 = prng_successor(data->nonce, 64); + uint32_t p641 = prng_successor(data->nonce2, 64); - s = lfsr_recovery32(data.ar ^ p640, 0); + s = lfsr_recovery32(data->ar ^ p640, 0); for (t = s; t->odd | t->even; ++t) { lfsr_rollback_word(t, 0, 0); - lfsr_rollback_word(t, data.nr, 1); - lfsr_rollback_word(t, data.cuid ^ data.nonce, 0); + lfsr_rollback_word(t, data->nr, 1); + lfsr_rollback_word(t, data->cuid ^ data->nonce, 0); crypto1_get_lfsr(t, &key); - crypto1_word(t, data.cuid ^ data.nonce2, 0); - crypto1_word(t, data.nr2, 1); - if (data.ar2 == (crypto1_word(t, 0, 0) ^ p641)) { + crypto1_word(t, data->cuid ^ data->nonce2, 0); + crypto1_word(t, data->nr2, 1); + if (data->ar2 == (crypto1_word(t, 0, 0) ^ p641)) { outkey = key; ++counter; if (counter == 20) break; @@ -153,20 +153,20 @@ bool mfkey32_moebius(nonces_t data, uint64_t *outputkey) { } // recover key from reader response and tag response of one authentication sequence -int mfkey64(nonces_t data, uint64_t *outputkey) { +int mfkey64(nonces_t *data, uint64_t *outputkey) { uint64_t key = 0; // recovered key uint32_t ks2; // keystream used to encrypt reader response uint32_t ks3; // keystream used to encrypt tag response struct Crypto1State *revstate; // Extract the keystream from the messages - ks2 = data.ar ^ prng_successor(data.nonce, 64); - ks3 = data.at ^ prng_successor(data.nonce, 96); + ks2 = data->ar ^ prng_successor(data->nonce, 64); + ks3 = data->at ^ prng_successor(data->nonce, 96); revstate = lfsr_recovery64(ks2, ks3); lfsr_rollback_word(revstate, 0, 0); lfsr_rollback_word(revstate, 0, 0); - lfsr_rollback_word(revstate, data.nr, 1); - lfsr_rollback_word(revstate, data.cuid ^ data.nonce, 0); + lfsr_rollback_word(revstate, data->nr, 1); + lfsr_rollback_word(revstate, data->cuid ^ data->nonce, 0); crypto1_get_lfsr(revstate, &key); crypto1_destroy(revstate); *outputkey = key; diff --git a/client/mifare/mfkey.h b/client/mifare/mfkey.h index 36ca8ed11..e108d5fa7 100644 --- a/client/mifare/mfkey.h +++ b/client/mifare/mfkey.h @@ -17,9 +17,9 @@ #include "mifare.h" uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par_info, uint64_t ks_info, uint64_t **keys); -bool mfkey32(nonces_t data, uint64_t *outputkey); -bool mfkey32_moebius(nonces_t data, uint64_t *outputkey); -int mfkey64(nonces_t data, uint64_t *outputkey); +bool mfkey32(nonces_t *data, uint64_t *outputkey); +bool mfkey32_moebius(nonces_t *data, uint64_t *outputkey); +int mfkey64(nonces_t *data, uint64_t *outputkey); int compare_uint64(const void *a, const void *b); uint32_t intersection(uint64_t *listA, uint64_t *listB); diff --git a/client/proxmark3.c b/client/proxmark3.c index db8434e07..fb02396bd 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -29,6 +29,8 @@ static void showBanner(void) { + g_printAndLog = PRINTANDLOG_PRINT; + PrintAndLogEx(NORMAL, "\n"); #if defined(__linux__) || (__APPLE__) || (_WIN32) PrintAndLogEx(NORMAL, _BLUE_("██████╗ ███╗ ███╗ ████╗ ") " ...iceman fork"); @@ -50,6 +52,8 @@ static void showBanner(void) { // printf("\nMonero: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP"); PrintAndLogEx(NORMAL, "\n"); fflush(stdout); + + g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; } int check_comm(void) { @@ -466,6 +470,35 @@ finish2: return ret; } +// Check if windows AnsiColor Support is enabled in the registery +// [HKEY_CURRENT_USER\Console] +// "VirtualTerminalLevel"=dword:00000001 +static bool DetectWindowsAnsiSupport(void) { + bool ret = false; +#if defined(_WIN32) + HKEY hKey = NULL; + + if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) { + DWORD dwType = REG_SZ; + BYTE KeyValue[sizeof(dwType)]; + DWORD len = sizeof(KeyValue); + + if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) { + uint8_t i; + uint32_t Data = 0; + for (i = 0; i < 4; i++) + Data += KeyValue[i] << (8 * i); + + if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled + ret = true; + } + } + RegCloseKey(hKey); + } +#endif + return ret; +} + int main(int argc, char *argv[]) { srand(time(0)); @@ -683,34 +716,7 @@ int main(int argc, char *argv[]) { return 1; } - session.supports_colors = false; - -#if defined(_WIN32) - // Check if windows AnsiColor Support is enabled in the registery - // [HKEY_CURRENT_USER\Console] - // "VirtualTerminalLevel"=dword:00000001 - - HKEY hKey = NULL; - - if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) { - DWORD dwType = REG_SZ; - BYTE KeyValue[sizeof(dwType)]; - DWORD len = sizeof(KeyValue); - - if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) { - uint8_t i; - uint32_t Data = 0; - for (i = 0; i < 4; i++) - Data += KeyValue[i] << (8 * i); - - if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled - session.supports_colors = true; - } - } - RegCloseKey(hKey); - } - -#endif + session.supports_colors = DetectWindowsAnsiSupport(); session.stdinOnTTY = isatty(STDIN_FILENO); session.stdoutOnTTY = isatty(STDOUT_FILENO);