Merge remote-tracking branch 'upstream/master' into felica_support_request_service
# Conflicts: # armsrc/felica.c # client/cmdhffelica.c
This commit is contained in:
commit
ce4c651853
68 files changed
+40575
-301
No files matched your search
+2
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -1872,7 +1872,7 @@ int CmdPlot(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdSave(const char *Cmd) {
|
||||
int CmdSave(const char *Cmd) {
|
||||
|
||||
int len = 0;
|
||||
char filename[FILE_PATH_SIZE] = {0x00};
|
||||
|
||||
@@ -53,6 +53,7 @@ int CmdHpf(const char *Cmd);
|
||||
int CmdLtrim(const char *Cmd); // used by cmd lf em4x, lf t55xx
|
||||
int CmdNorm(const char *Cmd); // used by cmd lf data (!)
|
||||
int CmdPlot(const char *Cmd); // used by cmd lf cotag
|
||||
int CmdSave(const char *Cmd); // used by cmd auto
|
||||
int CmdTuneSamples(const char *Cmd); // used by cmd lf hw
|
||||
int ASKbiphaseDemod(const char *Cmd, bool verbose); // used by cmd lf em4x, lf fdx, lf guard, lf jablotron, lf nedap, lf t55xx
|
||||
int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType); // used by cmd lf em4x, lf t55xx, lf viking
|
||||
|
||||
+19
-12
@@ -70,6 +70,8 @@ static int usage_hf_tune() {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
#define PROMPT_CLEARLINE PrintAndLogEx(INPLACE, " ")
|
||||
|
||||
int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
@@ -77,6 +79,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
PrintAndLogEx(INFO, "Checking for known tags...\n");
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for ThinFilm tag...");
|
||||
if (IfPm3NfcBarcode()) {
|
||||
if (infoThinFilm(false) == PM3_SUCCESS) {
|
||||
@@ -85,6 +88,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO14443-A tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
if (infoHF14A(false, false) > 0) {
|
||||
@@ -92,7 +96,8 @@ int CmdHFSearch(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO15693 tag...");
|
||||
if (IfPm3Iso15693()) {
|
||||
if (readHF15Uid(false) == 1) {
|
||||
@@ -104,6 +109,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
DropField();
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for LEGIC tag...");
|
||||
if (IfPm3Legicrf()) {
|
||||
if (readLegicUid(false) == PM3_SUCCESS) {
|
||||
@@ -112,6 +118,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for Topaz tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
if (readTopazUid() == PM3_SUCCESS) {
|
||||
@@ -120,7 +127,17 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for FeliCa tag...");
|
||||
if (IfPm3Felica()) {
|
||||
if (readFelicaUid(false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(NORMAL, "\nValid " _GREEN_("ISO18092 / FeliCa tag") " found\n");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
// 14b and iclass is the longest test (put last)
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO14443-B tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
if (readHF14B(false) == 1) {
|
||||
@@ -129,6 +146,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for iClass / PicoPass tag...");
|
||||
if (IfPm3Iclass()) {
|
||||
if (readIclass(false, false) == 1) {
|
||||
@@ -137,17 +155,6 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PrintAndLogEx(INPLACE, "Searching for FeliCa tag...");
|
||||
//if (IfPm3Felica()) {
|
||||
// ans = CmdHFFelicaReader("s");
|
||||
// if (ans) {
|
||||
// PrintAndLogEx(NORMAL, "\nValid " _GREEN_("ISO18092 / FeliCa tag") " found\n");
|
||||
// return ans;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
PrintAndLogEx(INPLACE, "No known/supported 13.56 MHz tags found");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_ESOFT;
|
||||
|
||||
+37
-36
@@ -36,7 +36,7 @@ static int usage_hf_felica_sim(void) {
|
||||
PrintAndLogEx(NORMAL, " v : (Optional) Verbose");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " hf felica sim t 1 ");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@ static int usage_hf_felica_sniff(void) {
|
||||
PrintAndLogEx(NORMAL, " t triggers to skip (decimal)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " hf felica sniff s 1000");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_felica_simlite(void) {
|
||||
PrintAndLogEx(NORMAL, "\n Emulating ISO/18092 FeliCa Lite tag \n");
|
||||
@@ -58,7 +58,7 @@ static int usage_hf_felica_simlite(void) {
|
||||
PrintAndLogEx(NORMAL, " uid : UID in hexsymbol");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " hf felica litesim 11223344556677");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_felica_dumplite(void) {
|
||||
PrintAndLogEx(NORMAL, "\n Dump ISO/18092 FeliCa Lite tag \n");
|
||||
@@ -68,7 +68,7 @@ static int usage_hf_felica_dumplite(void) {
|
||||
PrintAndLogEx(NORMAL, " h : This help");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " hf felica litedump");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_felica_raw(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf felica raw [-h] [-r] [-c] [-p] [-a] <0A 0B 0C ... hex>");
|
||||
@@ -78,7 +78,7 @@ static int usage_hf_felica_raw(void) {
|
||||
PrintAndLogEx(NORMAL, " -p leave the signal field ON after receive");
|
||||
PrintAndLogEx(NORMAL, " -a active signal field ON without select");
|
||||
PrintAndLogEx(NORMAL, " -s active signal field ON with select");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_request_service(void) {
|
||||
@@ -89,30 +89,30 @@ static int usage_hf_felica_request_service(void) {
|
||||
PrintAndLogEx(NORMAL, " -h this help");
|
||||
PrintAndLogEx(NORMAL, " -c calculate and append CRC");
|
||||
PrintAndLogEx(NORMAL, "Example: rqservice 01100910c11bc407 01 FFFF 2837");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf felica dump [-h] <outputfile>");
|
||||
PrintAndLogEx(NORMAL, " -h this help");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdHFFelicaList(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
//PrintAndLogEx(NORMAL, "Deprecated command, use 'hf list felica' instead");
|
||||
CmdTraceList("felica");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdHFFelicaReader(const char *Cmd) {
|
||||
bool verbose = !(Cmd[0] == 's' || Cmd[0] == 'S');
|
||||
readFelicaUid(verbose);
|
||||
return 0;
|
||||
bool verbose = !(tolower(Cmd[0]) == 's');
|
||||
return readFelicaUid(verbose);
|
||||
}
|
||||
|
||||
static int CmdHFFelicaDump(const char *Cmd) {
|
||||
if (strlen(Cmd) < 1) return usage_hf_felica_dump();
|
||||
return dump(*Cmd);
|
||||
clearCommandBuffer();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_hf_felica_dumplite();
|
||||
@@ -268,7 +268,7 @@ static int CmdHFFelicaSim(const char *Cmd) {
|
||||
while (!kbd_enter_pressed()) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -304,7 +304,7 @@ static int CmdHFFelicaSniff(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_FELICA_SNIFF, samples2skip, triggers2skip, 0, NULL, 0);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// uid hex
|
||||
@@ -316,7 +316,7 @@ static int CmdHFFelicaSimLite(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_FELICALITE_SIMULATE, uid, 0, 0, NULL, 0);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void printSep() {
|
||||
@@ -489,35 +489,35 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\n[!] aborted via keyboard!\n");
|
||||
DropField();
|
||||
return 1;
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
if (timeout > 100) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
DropField();
|
||||
return 1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
if (resp.oldarg[0] == 0) {
|
||||
PrintAndLogEx(WARNING, "\nButton pressed. Aborted.");
|
||||
return 1;
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
uint32_t tracelen = resp.oldarg[1];
|
||||
if (tracelen == 0) {
|
||||
PrintAndLogEx(WARNING, "\nNo trace data! Maybe not a FeliCa Lite card?");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
uint8_t *trace = calloc(tracelen, sizeof(uint8_t));
|
||||
if (trace == NULL) {
|
||||
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
||||
return 1;
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 0, NULL, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
free(trace);
|
||||
return 0;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %"PRIu64" bytes)", tracelen);
|
||||
@@ -532,7 +532,7 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||
printSep();
|
||||
|
||||
free(trace);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void waitCmdFelica(uint8_t iSelect) {
|
||||
@@ -624,7 +624,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||
continue;
|
||||
}
|
||||
PrintAndLogEx(WARNING, "Invalid char on input");
|
||||
return 0;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (crc && datalen > 0 && datalen < sizeof(data) - 2) {
|
||||
@@ -664,7 +664,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||
waitCmdFelica(0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int readFelicaUid(bool verbose) {
|
||||
@@ -675,7 +675,7 @@ int readFelicaUid(bool verbose) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "FeliCa card select failed");
|
||||
//SendCommandMIX(CMD_HF_FELICA_COMMAND, 0, 0, 0, NULL, 0);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
felica_card_select_t card;
|
||||
@@ -686,19 +686,20 @@ int readFelicaUid(bool verbose) {
|
||||
case 1: {
|
||||
if (verbose)
|
||||
PrintAndLogEx(WARNING, "card timeout");
|
||||
break;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
case 2: {
|
||||
if (verbose)
|
||||
PrintAndLogEx(WARNING, "card answered wrong");
|
||||
break;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
case 3: {
|
||||
if (verbose)
|
||||
PrintAndLogEx(WARNING, "CRC check failed");
|
||||
break;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
case 0: {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "FeliCa tag info");
|
||||
|
||||
PrintAndLogEx(NORMAL, "IDm %s", sprint_hex(card.IDm, sizeof(card.IDm)));
|
||||
@@ -713,24 +714,24 @@ int readFelicaUid(bool verbose) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int dump() {
|
||||
int dump(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_hf_felica_dumplite();
|
||||
|
||||
// TODO FINISH THIS METHOD
|
||||
PrintAndLogEx(SUCCESS, "NOT IMPLEMENTED YET!");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int request_service() {
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"----------- General -----------", CmdHelp, IfPm3Iso14443a, ""},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
@@ -769,7 +770,7 @@ static command_t CommandTable[] = {
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdHFFelica(const char *Cmd) {
|
||||
|
||||
+22
-9
@@ -2330,7 +2330,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
uint8_t found_offset = 0;
|
||||
uint32_t key_offset = 0;
|
||||
// main keychunk loop
|
||||
for (uint32_t key_offset = 0; key_offset < keycount; key_offset += chunksize) {
|
||||
for (key_offset = 0; key_offset < keycount; key_offset += chunksize) {
|
||||
|
||||
uint64_t t2 = msclock();
|
||||
uint8_t timeout = 0;
|
||||
@@ -2806,16 +2806,18 @@ int readIclass(bool loop, bool verbose) {
|
||||
FLAG_ICLASS_READER_ONE_TRY;
|
||||
|
||||
// loop in client not device - else on windows have a communication error
|
||||
PacketResponseNG resp;
|
||||
while (!kbd_enter_pressed()) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_ICLASS_READER, flags, 0, 0, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
|
||||
|
||||
uint8_t readStatus = resp.oldarg[0] & 0xff;
|
||||
uint8_t *data = resp.data.asBytes;
|
||||
|
||||
if (verbose) PrintAndLogEx(INFO, "Readstatus:%02x", readStatus);
|
||||
// if (verbose) PrintAndLogEx(INFO, "Readstatus:%02x", readStatus);
|
||||
|
||||
// no tag found or button pressed
|
||||
if ((readStatus == 0 && !loop) || readStatus == 0xFF) {
|
||||
@@ -2837,18 +2839,29 @@ int readIclass(bool loop, bool verbose) {
|
||||
printIclassDumpInfo(data);
|
||||
}
|
||||
|
||||
// if CSN ends with FF12E0, it's inside HID CSN range.
|
||||
bool isHidRange = (memcmp((uint8_t *)(data + 5), "\xFF\x12\xE0", 3) == 0);
|
||||
|
||||
if (readStatus & FLAG_ICLASS_READER_AIA) {
|
||||
bool legacy = (memcmp((uint8_t *)(data + 8 * 5), "\xff\xff\xff\xff\xff\xff\xff\xff", 8) == 0);
|
||||
|
||||
bool se_enabled = (memcmp((uint8_t *)(data + 8 * 5), "\xff\xff\xff\x00\x06\xff\xff\xff", 8) == 0);
|
||||
|
||||
PrintAndLogEx(NORMAL, " App IA: %s", sprint_hex(data + 8 * 5, 8));
|
||||
if (legacy)
|
||||
PrintAndLogEx(SUCCESS, " : Possible iClass (legacy credential tag)");
|
||||
else if (se_enabled)
|
||||
PrintAndLogEx(SUCCESS, " : Possible iClass (SE credential tag)");
|
||||
else
|
||||
PrintAndLogEx(WARNING, " : Possible iClass (NOT legacy tag)");
|
||||
|
||||
if (isHidRange) {
|
||||
if (legacy)
|
||||
PrintAndLogEx(SUCCESS, " : Possible iClass - legacy credential tag");
|
||||
|
||||
if (se_enabled)
|
||||
PrintAndLogEx(SUCCESS, " : Possible iClass - SE credential tag");
|
||||
}
|
||||
|
||||
if (isHidRange) {
|
||||
PrintAndLogEx(SUCCESS, " : Tag is "_YELLOW_("iClass")", CSN is in HID range");
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, " : Tag is "_YELLOW_("PicoPass")", CSN is not in HID range");
|
||||
}
|
||||
}
|
||||
|
||||
if (tagFound && !loop) {
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -1052,6 +1052,11 @@ static void estimate_sum_a8(void) {
|
||||
|
||||
|
||||
static int read_nonce_file(char *filename) {
|
||||
|
||||
if (filename == NULL) {
|
||||
PrintAndLogEx(WARNING, "Filename is NULL");
|
||||
return 1;
|
||||
}
|
||||
FILE *fnonces = NULL;
|
||||
char progress_text[80] = "";
|
||||
uint8_t read_buf[9];
|
||||
@@ -1061,6 +1066,7 @@ static int read_nonce_file(char *filename) {
|
||||
PrintAndLogEx(WARNING, "Could not open file %s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(progress_text, 80, "Reading nonces from file %s...", filename);
|
||||
hardnested_print_progress(0, progress_text, (float)(1LL << 47), 0);
|
||||
size_t bytes_read = fread(read_buf, 1, 6, fnonces);
|
||||
@@ -1766,7 +1772,7 @@ static void add_matching_states(statelist_t *candidates, uint8_t part_sum_a0, ui
|
||||
}
|
||||
|
||||
static statelist_t *add_more_candidates(void) {
|
||||
statelist_t *new_candidates = candidates;
|
||||
statelist_t *new_candidates;
|
||||
if (candidates == NULL) {
|
||||
candidates = (statelist_t *)malloc(sizeof(statelist_t));
|
||||
new_candidates = candidates;
|
||||
|
||||
+6
-6
@@ -63,12 +63,12 @@ static int usage_lf_cmdread(void) {
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
PrintAndLogEx(NORMAL, " d <delay> delay OFF period, (0 for bitbang mode) (decimal)");
|
||||
PrintAndLogEx(NORMAL, " z <zero> time period ZERO, (decimal)");
|
||||
PrintAndLogEx(NORMAL, " o <one> time period ONE, (decimal)");
|
||||
PrintAndLogEx(NORMAL, " c <cmd> Command bytes (in ones and zeros)");
|
||||
PrintAndLogEx(NORMAL, " z <zero> ZERO time period (decimal)");
|
||||
PrintAndLogEx(NORMAL, " o <one> ONE time period (decimal)");
|
||||
PrintAndLogEx(NORMAL, " c <cmd> 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, "");
|
||||
|
||||
+1
-1
@@ -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"},
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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"},
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+1
-1
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+37
-2
@@ -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;
|
||||
@@ -1049,7 +1083,7 @@ static int CmdT55xxDetect(const char *Cmd) {
|
||||
if (try_all_dl_modes) {
|
||||
for (uint8_t m = downlink_mode; m < 4; m++) {
|
||||
|
||||
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, try_with_pwd & usepwd, password, m) == false)
|
||||
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, try_with_pwd && usepwd, password, m) == false)
|
||||
continue;
|
||||
|
||||
// pre fill to save passing in.
|
||||
@@ -1077,7 +1111,7 @@ static int CmdT55xxDetect(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!found & usepwd)
|
||||
if (!found && usepwd)
|
||||
try_with_pwd = !try_with_pwd; // toggle so we loop back if not found and try with pwd
|
||||
|
||||
if (found)
|
||||
@@ -3652,6 +3686,7 @@ static command_t CommandTable[] = {
|
||||
{"bruteforce", CmdT55xxBruteForce, IfPm3Lf, "<start password> <end password> 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 <bitstream> t <timing>"},
|
||||
{"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"},
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ char *GetQ5ModulationStr(uint32_t id);
|
||||
char *GetModulationStr(uint32_t id, bool xmode);
|
||||
char *GetModelStrFromCID(uint32_t cid);
|
||||
char *GetSelectedModulationStr(uint8_t id);
|
||||
char *GetDownlinkModeStr(uint8_t dlmode);
|
||||
char *GetDownlinkModeStr(uint8_t downlink_mode);
|
||||
void printT5xxHeader(uint8_t page);
|
||||
void printT55xxBlock(uint8_t blockNum, bool page1);
|
||||
int printConfiguration(t55xx_conf_block_t b);
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
+59
-14
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h> // MingW
|
||||
#include <stdlib.h> // calloc
|
||||
|
||||
#include "comms.h"
|
||||
#include "cmdhf.h"
|
||||
@@ -38,20 +39,6 @@
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int CmdRem(const char *Cmd) {
|
||||
char buf[22] = {0};
|
||||
struct tm *ct, tm_buf;
|
||||
time_t now = time(NULL);
|
||||
#if defined(_WIN32)
|
||||
ct = gmtime_s(&tm_buf, &now) == 0 ? &tm_buf : NULL;
|
||||
#else
|
||||
ct = gmtime_r(&now, &tm_buf);
|
||||
#endif
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", ct); // ISO8601
|
||||
PrintAndLogEx(NORMAL, "%s remark: %s", buf, Cmd);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_msleep(void) {
|
||||
PrintAndLogEx(NORMAL, "Sleep for given amount of milliseconds");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -65,6 +52,63 @@ static int usage_msleep(void) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_auto(void) {
|
||||
PrintAndLogEx(NORMAL, "Run LF SEARCH / HF SEARCH / DATA PLOT / DATA SAVE ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: auto <ms>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " auto");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void AppendDate(char *s, size_t slen, char *fmt) {
|
||||
struct tm *ct, tm_buf;
|
||||
time_t now = time(NULL);
|
||||
#if defined(_WIN32)
|
||||
ct = gmtime_s(&tm_buf, &now) == 0 ? &tm_buf : NULL;
|
||||
#else
|
||||
ct = gmtime_r(&now, &tm_buf);
|
||||
#endif
|
||||
if (fmt == NULL)
|
||||
strftime(s, slen, "%Y-%m-%dT%H:%M:%SZ", ct); // ISO8601
|
||||
else
|
||||
strftime(s, slen, fmt, ct);
|
||||
}
|
||||
|
||||
static int CmdAuto(const char *Cmd) {
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_auto();
|
||||
|
||||
int ret = CmdLFfind("");
|
||||
if (ret == PM3_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = CmdHFSearch("");
|
||||
if (ret == PM3_SUCCESS)
|
||||
return ret;
|
||||
|
||||
PrintAndLogEx(INFO, "Failed both LF / HF SEARCH,");
|
||||
PrintAndLogEx(INFO, "Trying 'lf read' and save a trace for you...");
|
||||
|
||||
CmdPlot("");
|
||||
lf_read(true, 40000);
|
||||
char *fname = calloc(100, sizeof(uint8_t));
|
||||
AppendDate(fname, 100, "lf_unknown_%Y-%m-%d_%H:%M.pm3");
|
||||
CmdSave(fname);
|
||||
free(fname);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdRem(const char *Cmd) {
|
||||
char buf[22] = {0};
|
||||
AppendDate(buf, sizeof(buf), NULL);
|
||||
PrintAndLogEx(NORMAL, "%s remark: %s", buf, Cmd);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdMsleep(const char *Cmd) {
|
||||
uint32_t ms = 0;
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
@@ -90,6 +134,7 @@ static int CmdRev(const char *Cmd) {
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use '<command> help' for details of a particular command."},
|
||||
{"auto", CmdAuto, IfPm3Present, "Automated detection process for unknown tags"},
|
||||
{"analyse", CmdAnalyse, AlwaysAvailable, "{ Analyse utils... }"},
|
||||
{"data", CmdData, AlwaysAvailable, "{ Plot window / data buffer manipulation... }"},
|
||||
{"emv", CmdEMV, AlwaysAvailable, "{ EMV ISO-14443 / ISO-7816... }"},
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "cmdparser.h" // command_t
|
||||
|
||||
int CommandReceived(char *Cmd);
|
||||
int CmdRem(const char *Cmd);
|
||||
command_t *getTopLevelCommandTable(void);
|
||||
|
||||
#endif
|
||||
+5
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,7 +548,6 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||
//Validations
|
||||
if (errors || cmdp == 0) return usage_sm_upgrade();
|
||||
|
||||
|
||||
char sha512filename[FILE_PATH_SIZE] = {'\0'};
|
||||
char *bin_extension = filename;
|
||||
char *dot_position = NULL;
|
||||
@@ -556,11 +555,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||
bin_extension = dot_position + 1;
|
||||
}
|
||||
|
||||
if (!strcmp(bin_extension, "BIN")
|
||||
#ifdef _WIN32
|
||||
|| !strcmp(bin_extension, "bin")
|
||||
#endif
|
||||
) {
|
||||
if (!strcmp(bin_extension, "BIN") || !strcmp(bin_extension, "bin")) {
|
||||
memcpy(sha512filename, filename, strlen(filename) - strlen("bin"));
|
||||
strcat(sha512filename, "sha512.txt");
|
||||
} else {
|
||||
|
||||
+5
-5
@@ -150,11 +150,11 @@ int CmdWiegandDecode(const char *Cmd) {
|
||||
bool errors = false;
|
||||
char cmdp = 0;
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
uint32_t strlen = param_getlength(Cmd, cmdp);
|
||||
strlen++; // null termin
|
||||
if (strlen > 2) {
|
||||
char *s = calloc(strlen, sizeof(uint8_t));
|
||||
param_getstr(Cmd, cmdp, s, strlen);
|
||||
uint32_t slen = param_getlength(Cmd, cmdp);
|
||||
slen++; // null termin
|
||||
if (slen > 2) {
|
||||
char *s = calloc(slen, sizeof(uint8_t));
|
||||
param_getstr(Cmd, cmdp, s, slen);
|
||||
hexstring_to_u96(&top, &mid, &bot, s);
|
||||
free(s);
|
||||
gothex = true;
|
||||
|
||||
@@ -1089,7 +1089,7 @@ int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root) {
|
||||
char *icc_pk_c = emv_pk_dump_pk(icc_pk);
|
||||
JsonSaveStr(root, "$.ApplicationData.ICCPublicKeyDec", icc_pk_c);
|
||||
JsonSaveBufAsHex(root, "$.ApplicationData.ICCPublicKeyModulus", icc_pk->modulus, icc_pk->mlen);
|
||||
free(issuer_pk_c);
|
||||
free(icc_pk_c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -372,8 +372,8 @@ bool ParamLoadFromJson(struct tlvdb *tlv) {
|
||||
return false;
|
||||
}
|
||||
tlv_tag_t tag = 0;
|
||||
for (int i = 0; i < buflen; i++) {
|
||||
tag = (tag << 8) | buf[i];
|
||||
for (int j = 0; j < buflen; j++) {
|
||||
tag = (tag << 8) | buf[j];
|
||||
}
|
||||
|
||||
if (!HexToBuffer("TLV Error value:", tlvValue, buf, sizeof(buf) - 1, &buflen)) {
|
||||
|
||||
@@ -75,9 +75,9 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) {
|
||||
}
|
||||
|
||||
case CborSimpleType: {
|
||||
uint8_t type;
|
||||
cbor_value_get_simple_type(it, &type);
|
||||
printf("simple(%u)", type);
|
||||
uint8_t t;
|
||||
cbor_value_get_simple_type(it, &t);
|
||||
printf("simple(%u)", t);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ int TinyCborPrintFIDOPackage(uint8_t cmdCode, bool isResponse, uint8_t *data, si
|
||||
|
||||
if (err) {
|
||||
fprintf(stderr,
|
||||
"CBOR parsing failure at offset %" PRId32 " : %s\n",
|
||||
"CBOR parsing failure at offset %" PRIu32 " : %s\n",
|
||||
(uint32_t)(cb.ptr - data),
|
||||
cbor_error_string(err)
|
||||
);
|
||||
|
||||
@@ -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) {
|
||||
@@ -250,16 +250,16 @@ void prepare_bf_test_nonces(noncelist_t *nonces, uint8_t best_first_byte) {
|
||||
uint32_t bf_test_nonce_temp[4];
|
||||
uint8_t bf_test_nonce_par_temp[4];
|
||||
uint8_t bf_test_nonce_2nd_byte_temp[4];
|
||||
for (uint8_t i = 0; i < 4 && i < nonces_to_bruteforce; i++) {
|
||||
bf_test_nonce_temp[i] = bf_test_nonce[best_4[i]];
|
||||
for (uint8_t j = 0; j < 4 && j < nonces_to_bruteforce; j++) {
|
||||
bf_test_nonce_temp[j] = bf_test_nonce[best_4[j]];
|
||||
|
||||
bf_test_nonce_par_temp[i] = bf_test_nonce_par[best_4[i]];
|
||||
bf_test_nonce_2nd_byte_temp[i] = bf_test_nonce_2nd_byte[best_4[i]];
|
||||
bf_test_nonce_par_temp[j] = bf_test_nonce_par[best_4[j]];
|
||||
bf_test_nonce_2nd_byte_temp[j] = bf_test_nonce_2nd_byte[best_4[j]];
|
||||
}
|
||||
for (uint8_t i = 0; i < 4 && i < nonces_to_bruteforce; i++) {
|
||||
bf_test_nonce[i] = bf_test_nonce_temp[i];
|
||||
bf_test_nonce_par[i] = bf_test_nonce_par_temp[i];
|
||||
bf_test_nonce_2nd_byte[i] = bf_test_nonce_2nd_byte_temp[i];
|
||||
for (uint8_t j = 0; j < 4 && j < nonces_to_bruteforce; j++) {
|
||||
bf_test_nonce[j] = bf_test_nonce_temp[j];
|
||||
bf_test_nonce_par[j] = bf_test_nonce_par_temp[j];
|
||||
bf_test_nonce_2nd_byte[j] = bf_test_nonce_2nd_byte_temp[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
local getopt = require('getopt')
|
||||
|
||||
copyright = 'Copyright (c) 2019 IceSQL AB. All rights reserved.'
|
||||
author = 'Christian Herrmann'
|
||||
version = 'v1.0.0'
|
||||
desc = [[
|
||||
This script initialize a Proxmark3 RDV4.0 with
|
||||
- uploading dictionary files to flashmem
|
||||
- configuring the LF T55X7 device settings
|
||||
]]
|
||||
example = [[
|
||||
|
||||
script run init_rdv4
|
||||
]]
|
||||
usage = [[
|
||||
script run init_rdv4 -h
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
]]
|
||||
|
||||
local DEBUG = true
|
||||
---
|
||||
-- A debug printout-function
|
||||
local function dbg(args)
|
||||
if not DEBUG then return end
|
||||
if type(args) == 'table' then
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print('###', args)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
local function oops(err)
|
||||
print('ERROR:', err)
|
||||
core.clearCommandBuffer()
|
||||
return nil, err
|
||||
end
|
||||
---
|
||||
-- Usage help
|
||||
local function help()
|
||||
print(copyright)
|
||||
print(author)
|
||||
print(version)
|
||||
print(desc)
|
||||
print('Example usage')
|
||||
print(example)
|
||||
print(usage)
|
||||
end
|
||||
---
|
||||
-- The main entry point
|
||||
function main(args)
|
||||
local dash = string.rep('--', 20)
|
||||
|
||||
print( dash )
|
||||
print( dash )
|
||||
print()
|
||||
|
||||
-- Read the parameters
|
||||
for o, a in getopt.getopt(args, 'h') do
|
||||
if o == 'h' then return help() end
|
||||
end
|
||||
|
||||
print('Prepping your Proxmark3 RDV4')
|
||||
|
||||
-- Upload dictionaries
|
||||
print('Uploading dictionaries to RDV4 flashmemory')
|
||||
print(dash)
|
||||
core.console('mem load f mfc_default_keys m')
|
||||
core.console('mem load f t55xx_default_pwds t')
|
||||
core.console('mem load f iclass_default_keys i')
|
||||
print(dash)
|
||||
|
||||
-- T55x7 Device configuration
|
||||
print('Configure T55XX device side to match RDV4')
|
||||
print(dash)
|
||||
core.console('lf t55xx deviceconfig r 0 a 29 b 17 c 15 d 47 e 15 p')
|
||||
core.console('lf t55xx deviceconfig r 1 a 29 b 17 c 18 d 50 e 15 p')
|
||||
core.console('lf t55xx deviceconfig r 2 a 29 b 17 c 18 d 40 e 15 p')
|
||||
core.console('lf t55xx deviceconfig r 3 a 29 b 17 c 15 d 31 e 15 f 47 g 63 p')
|
||||
|
||||
print('')
|
||||
print('')
|
||||
core.console('hw status')
|
||||
print(dash)
|
||||
|
||||
print('all done!')
|
||||
|
||||
end
|
||||
|
||||
main(args)
|
||||
+1
-1
@@ -181,7 +181,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
||||
if (!res)
|
||||
res = res2;
|
||||
|
||||
if (verbose & !res2)
|
||||
if (verbose && !res2)
|
||||
PrintAndLogEx(NORMAL, "CRC8-MAD2 OK.");
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+34
-28
@@ -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);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "fileutils.h" // searchfile
|
||||
#include "cmdlf.h" // lf_config
|
||||
|
||||
static int returnToLuaWithError(lua_State *L, const char *fmt, ...) {
|
||||
char buffer[200];
|
||||
@@ -1056,6 +1057,22 @@ static int l_ndefparse(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_remark(lua_State *L) {
|
||||
//Check number of arguments
|
||||
int n = lua_gettop(L);
|
||||
if (n != 1) {
|
||||
return returnToLuaWithError(L, "Only one string allowed");
|
||||
}
|
||||
|
||||
size_t size;
|
||||
// data
|
||||
const char *s = luaL_checklstring(L, 1, &size);
|
||||
|
||||
int res = CmdRem(s);
|
||||
lua_pushinteger(L, res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_searchfile(lua_State *L) {
|
||||
//Check number of arguments
|
||||
int n = lua_gettop(L);
|
||||
@@ -1141,6 +1158,7 @@ int set_pm3_libraries(lua_State *L) {
|
||||
{"ndefparse", l_ndefparse},
|
||||
{"fast_push_mode", l_fast_push_mode},
|
||||
{"search_file", l_searchfile},
|
||||
{"rem", l_remark},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -672,16 +672,16 @@ void HIDDisplayUnpackedCard(wiegand_card_t *card, const cardformat_t format) {
|
||||
|
||||
char s[80] = {0};
|
||||
if (format.Fields.hasFacilityCode)
|
||||
snprintf(s, sizeof(s), "FC: %d", card->FacilityCode);
|
||||
snprintf(s, sizeof(s), "FC: %u", card->FacilityCode);
|
||||
|
||||
if (format.Fields.hasCardNumber)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " CN: %" PRIu64, card->CardNumber);
|
||||
|
||||
if (format.Fields.hasIssueLevel)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " Issue %d", card->IssueLevel);
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " Issue %u", card->IssueLevel);
|
||||
|
||||
if (format.Fields.hasOEMCode)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " OEM: %d", card->OEM);
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " OEM: %u", card->OEM);
|
||||
|
||||
if (format.Fields.hasParity)
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), " parity: %s", card->ParityValid ? "valid" : "invalid");
|
||||
|
||||
@@ -43,6 +43,6 @@ void HIDListFormats();
|
||||
int HIDFindCardFormat(const char *format);
|
||||
cardformat_t HIDGetCardFormat(int idx);
|
||||
bool HIDPack(int FormatIndex, wiegand_card_t *card, wiegand_message_t *packed);
|
||||
bool HIDTryUnpack(wiegand_message_t *packed, bool ignoreParity);
|
||||
bool HIDTryUnpack(wiegand_message_t *packed, bool ignore_parity);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user