Add option -c to lf search to continue searching after first hit

This commit is contained in:
Philippe Teuwen 2021-04-18 23:23:48 +02:00
commit 68e8705278
2 changed files with 251 additions and 41 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Change `lf search` - add option `-c` to continue searching after first hit (@doegox)
- Fix DESFire mis-annotation (@VortixDev) - Fix DESFire mis-annotation (@VortixDev)
- Change `lf pac demod` - now also search for inverted bitstreams (@iceman1001) - Change `lf pac demod` - now also search for inverted bitstreams (@iceman1001)
- Change `hf 14b reader` - now supports continous mode (@iceman1001) - Change `hf 14b reader` - now supports continous mode (@iceman1001)

View file

@ -1343,14 +1343,16 @@ int CmdLFfind(const char *Cmd) {
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("1", NULL, "Use data from Graphbuffer to search"), arg_lit0("1", NULL, "Use data from Graphbuffer to search"),
arg_lit0("u", NULL, "Search for unknown tags, if not set, reads only known tags"), arg_lit0("c", NULL, "Continue searching even after a first hit"),
arg_lit0("u", NULL, "Search for unknown tags. If not set, reads only known tags"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
bool use_gb = arg_get_lit(ctx, 1); bool use_gb = arg_get_lit(ctx, 1);
bool search_unk = arg_get_lit(ctx, 2); bool search_cont = arg_get_lit(ctx, 2);
bool search_unk = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
int found = 0;
bool is_online = (session.pm3_present && (use_gb == false)); bool is_online = (session.pm3_present && (use_gb == false));
if (is_online) if (is_online)
lf_read(false, 30000); lf_read(false, 30000);
@ -1367,6 +1369,10 @@ int CmdLFfind(const char *Cmd) {
PrintAndLogEx(INFO, "False Positives " _YELLOW_("ARE") " possible"); PrintAndLogEx(INFO, "False Positives " _YELLOW_("ARE") " possible");
PrintAndLogEx(INFO, ""); PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, "Checking for known tags..."); PrintAndLogEx(INFO, "Checking for known tags...");
if (search_cont)
PrintAndLogEx(INFO, "We'll go over all possible demods");
else
PrintAndLogEx(INFO, "We'll stop at first hit");
PrintAndLogEx(INFO, ""); PrintAndLogEx(INFO, "");
// only run these tests if device is online // only run these tests if device is online
@ -1375,14 +1381,22 @@ int CmdLFfind(const char *Cmd) {
if (IfPm3Hitag()) { if (IfPm3Hitag()) {
if (readHitagUid()) { if (readHitagUid()) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Hitag") " found!"); PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Hitag") " found!");
return PM3_SUCCESS; if (search_cont) {
found++;
} else {
return PM3_SUCCESS;
}
} }
} }
if (IfPm3EM4x50()) { if (IfPm3EM4x50()) {
if (read_em4x50_uid() == PM3_SUCCESS) { if (read_em4x50_uid() == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM4x50 ID") " found!"); PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM4x50 ID") " found!");
return PM3_SUCCESS; if (search_cont) {
found++;
} else {
return PM3_SUCCESS;
}
} }
} }
@ -1393,61 +1407,241 @@ int CmdLFfind(const char *Cmd) {
PrintAndLogEx(INPLACE, "Searching for MOTOROLA tag..."); PrintAndLogEx(INPLACE, "Searching for MOTOROLA tag...");
if (readMotorolaUid()) { if (readMotorolaUid()) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Motorola FlexPass ID") " found!"); PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Motorola FlexPass ID") " found!");
return PM3_SUCCESS; if (search_cont) {
found++;
} else {
return PM3_SUCCESS;
}
} }
PrintAndLogEx(INPLACE, "Searching for COTAG tag..."); PrintAndLogEx(INPLACE, "Searching for COTAG tag...");
if (readCOTAGUid()) { if (readCOTAGUid()) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("COTAG ID") " found!"); PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("COTAG ID") " found!");
return PM3_SUCCESS; if (search_cont) {
found++;
} else {
return PM3_SUCCESS;
}
} }
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(FAILED, _RED_("No data found!")); PrintAndLogEx(FAILED, _RED_("No data found!"));
PrintAndLogEx(INFO, "Signal looks like noise. Maybe not an LF tag?"); PrintAndLogEx(INFO, "Signal looks like noise. Maybe not an LF tag?");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return PM3_ESOFT; if (! search_cont) {
return PM3_ESOFT;
}
} }
} }
int retval = PM3_SUCCESS; int retval = PM3_SUCCESS;
// ask / man // ask / man
if (demodEM410x(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM410x ID") " found!"); goto out;} if (demodEM410x(true) == PM3_SUCCESS) {
if (demodDestron(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-A FECAVA Destron ID") " found!"); goto out;} // to do before HID PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM410x ID") " found!");
if (demodGallagher(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!"); goto out;} if (search_cont) {
if (demodNoralsy(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Noralsy ID") " found!"); goto out;} found++;
if (demodPresco(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Presco ID") " found!"); goto out;} } else {
if (demodSecurakey(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!"); goto out;} goto out;
if (demodViking(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!"); goto out;} }
if (demodVisa2k(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!"); goto out;} }
if (demodDestron(true) == PM3_SUCCESS) { // to do before HID
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-A FECAVA Destron ID") " found!"); if (! search_cont) goto out;
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodGallagher(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodNoralsy(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Noralsy ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodPresco(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Presco ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodSecurakey(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodViking(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodVisa2k(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Visa2000 ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
// ask / bi // ask / bi
if (demodFDXB(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-B ID") " found!"); goto out;} if (demodFDXB(true) == PM3_SUCCESS) {
if (demodJablotron(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Jablotron ID") " found!"); goto out;} PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-B ID") " found!");
if (demodGuard(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Guardall G-Prox II ID") " found!"); goto out; } if (search_cont) {
if (demodNedap(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NEDAP ID") " found!"); goto out;} found++;
} else {
goto out;
}
}
if (demodJablotron(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Jablotron ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodGuard(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Guardall G-Prox II ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodNedap(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NEDAP ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
// nrz // nrz
if (demodPac(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("PAC/Stanley ID") " found!"); goto out;} if (demodPac(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("PAC/Stanley ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
// fsk // fsk
if (demodHID(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("HID Prox ID") " found!"); goto out;} if (demodHID(true) == PM3_SUCCESS) {
if (demodAWID(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("AWID ID") " found!"); goto out;} PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("HID Prox ID") " found!");
if (demodIOProx(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("IO Prox ID") " found!"); goto out;} if (search_cont) {
if (demodPyramid(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Pyramid ID") " found!"); goto out;} found++;
if (demodParadox(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Paradox ID") " found!"); goto out;} } else {
goto out;
}
}
if (demodAWID(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("AWID ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodIOProx(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("IO Prox ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodPyramid(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Pyramid ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodParadox(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Paradox ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
// psk // psk
if (demodIdteck(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Idteck ID") " found!"); goto out;} if (demodIdteck(true) == PM3_SUCCESS) {
if (demodKeri(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("KERI ID") " found!"); goto out;} PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Idteck ID") " found!");
if (demodNexWatch(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NexWatch ID") " found!"); goto out;} if (search_cont) {
if (demodIndala(true) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Indala ID") " found!"); goto out;} found++;
} else {
// if (demodTI() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Texas Instrument ID") " found!"); goto out;} goto out;
// if (demodFermax() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fermax ID") " found!"); goto out;} }
}
PrintAndLogEx(FAILED, _RED_("No known 125/134 kHz tags found!")); if (demodKeri(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("KERI ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodNexWatch(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NexWatch ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodIndala(true) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Indala ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
/*
if (demodTI() == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Texas Instrument ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
if (demodFermax() == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fermax ID") " found!");
if (search_cont) {
found++;
} else {
goto out;
}
}
*/
if (found == 0) {
PrintAndLogEx(FAILED, _RED_("No known 125/134 kHz tags found!"));
}
if (search_unk) { if (search_unk) {
//test unknown tag formats (raw mode) //test unknown tag formats (raw mode)
@ -1465,7 +1659,11 @@ int CmdLFfind(const char *Cmd) {
if (GetFskClock("", false)) { if (GetFskClock("", false)) {
if (FSKrawDemod(0, 0, 0, 0, true) == PM3_SUCCESS) { if (FSKrawDemod(0, 0, 0, 0, true) == PM3_SUCCESS) {
PrintAndLogEx(INFO, "Unknown FSK Modulated Tag found!"); PrintAndLogEx(INFO, "Unknown FSK Modulated Tag found!");
goto out; if (search_cont) {
found++;
} else {
goto out;
}
} }
} }
@ -1473,7 +1671,11 @@ int CmdLFfind(const char *Cmd) {
if (ASKDemod_ext(0, 0, 0, 0, false, true, false, 1, &st) == PM3_SUCCESS) { if (ASKDemod_ext(0, 0, 0, 0, false, true, false, 1, &st) == PM3_SUCCESS) {
PrintAndLogEx(INFO, "Unknown ASK Modulated and Manchester encoded Tag found!"); PrintAndLogEx(INFO, "Unknown ASK Modulated and Manchester encoded Tag found!");
PrintAndLogEx(INFO, "if it does not look right it could instead be ASK/Biphase - try " _YELLOW_("'data rawdemod --ab'")); PrintAndLogEx(INFO, "if it does not look right it could instead be ASK/Biphase - try " _YELLOW_("'data rawdemod --ab'"));
goto out; if (search_cont) {
found++;
} else {
goto out;
}
} }
if (CmdPSK1rawDemod("") == PM3_SUCCESS) { if (CmdPSK1rawDemod("") == PM3_SUCCESS) {
@ -1481,19 +1683,26 @@ int CmdLFfind(const char *Cmd) {
PrintAndLogEx(INFO, " Could also be PSK2 - try " _YELLOW_("'data rawdemod --p2'")); PrintAndLogEx(INFO, " Could also be PSK2 - try " _YELLOW_("'data rawdemod --p2'"));
PrintAndLogEx(INFO, " Could also be PSK3 - [currently not supported]"); PrintAndLogEx(INFO, " Could also be PSK3 - [currently not supported]");
PrintAndLogEx(INFO, " Could also be NRZ - try " _YELLOW_("'data rawdemod --nr")); PrintAndLogEx(INFO, " Could also be NRZ - try " _YELLOW_("'data rawdemod --nr"));
goto out; if (search_cont) {
found++;
} else {
goto out;
}
} }
PrintAndLogEx(FAILED, _RED_("No data found!")); if (found == 0) {
PrintAndLogEx(FAILED, _RED_("No data found!"));
}
} }
retval = PM3_ESOFT; if (found == 0) {
retval = PM3_ESOFT;
}
out: out:
// identify chipset // identify chipset
if (CheckChipType(is_online) == false) { if (CheckChipType(is_online) == false) {
PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed")); PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed"));
retval = false;
} }
return retval; return retval;
} }