mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
changed "data dectectclock" to try all clocks when not called with any params. Adapted the "lf search -1u" - with text and it should be more intuitive
This commit is contained in:
parent
bdbfa26f9a
commit
2bfc31a7b6
3 changed files with 71 additions and 56 deletions
|
@ -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 `data detectclock` - now tries all clocks if called w/o any params (@iceman1001)
|
||||||
- Changed `lf search -1u` - improved the autocorrelation detection for unknown signals (@iceman1001)
|
- Changed `lf search -1u` - improved the autocorrelation detection for unknown signals (@iceman1001)
|
||||||
- Fixed `hf emrtd dump` stack smashing on device side (@iceman1001)
|
- Fixed `hf emrtd dump` stack smashing on device side (@iceman1001)
|
||||||
- Changed `dbprint` on device side to use max 200 chars strings. (@iceman1001)
|
- Changed `dbprint` on device side to use max 200 chars strings. (@iceman1001)
|
||||||
|
|
|
@ -818,10 +818,6 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
||||||
window = len;
|
window = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
|
||||||
PrintAndLogEx(INFO, "performing " _YELLOW_("%zu") " correlations", g_GraphTraceLen - window);
|
|
||||||
}
|
|
||||||
|
|
||||||
//test
|
//test
|
||||||
double autocv = 0.0; // Autocovariance value
|
double autocv = 0.0; // Autocovariance value
|
||||||
size_t correlation = 0;
|
size_t correlation = 0;
|
||||||
|
@ -852,7 +848,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
||||||
|
|
||||||
// keep track of which distance is repeating.
|
// keep track of which distance is repeating.
|
||||||
// A value near 1.0 or more indicates a correlation in the signal
|
// A value near 1.0 or more indicates a correlation in the signal
|
||||||
if (ac_value > 0.95) {
|
if (ac_value > 0.95f) {
|
||||||
correlation = i - lastmax;
|
correlation = i - lastmax;
|
||||||
lastmax = i;
|
lastmax = i;
|
||||||
|
|
||||||
|
@ -882,10 +878,10 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
||||||
|
|
||||||
if (distance > -1) {
|
if (distance > -1) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "possible correlation at "_YELLOW_("%4d") " samples", distance);
|
PrintAndLogEx(SUCCESS, "Possible correlation at "_YELLOW_("%4d") " samples", distance);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(HINT, "no repeating pattern found, try increasing window size");
|
PrintAndLogEx(HINT, "No repeating pattern found, try increasing window size");
|
||||||
// return value -1, indication to increase window size
|
// return value -1, indication to increase window size
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1150,7 @@ static int CmdDetectClockRate(const char *Cmd) {
|
||||||
arg_lit0(NULL, "psk", "specify PSK modulation clock detection"),
|
arg_lit0(NULL, "psk", "specify PSK modulation clock detection"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
bool a = arg_get_lit(ctx, 1);
|
bool a = arg_get_lit(ctx, 1);
|
||||||
bool f = arg_get_lit(ctx, 2);
|
bool f = arg_get_lit(ctx, 2);
|
||||||
bool n = arg_get_lit(ctx, 3);
|
bool n = arg_get_lit(ctx, 3);
|
||||||
|
@ -1165,6 +1161,25 @@ static int CmdDetectClockRate(const char *Cmd) {
|
||||||
if (tmp > 1) {
|
if (tmp > 1) {
|
||||||
PrintAndLogEx(WARNING, "Only specify one modulation");
|
PrintAndLogEx(WARNING, "Only specify one modulation");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
} else if (tmp == 0) {
|
||||||
|
|
||||||
|
int clock = GetFskClock("", false);
|
||||||
|
if (clock > 0) {
|
||||||
|
PrintAndLogEx(SUCCESS, "FSK Clock... %d", clock);
|
||||||
|
}
|
||||||
|
clock = GetAskClock("", false);
|
||||||
|
if (clock > 0) {
|
||||||
|
PrintAndLogEx(SUCCESS, "ASK Clock... %d", clock);
|
||||||
|
}
|
||||||
|
clock = GetNrzClock("", false);
|
||||||
|
if (clock > 0) {
|
||||||
|
PrintAndLogEx(SUCCESS, "NRZ Clock... %d", clock);
|
||||||
|
}
|
||||||
|
clock = GetPskClock("", false);
|
||||||
|
if (clock > 0) {
|
||||||
|
PrintAndLogEx(SUCCESS, "PSK Clock... %d", clock);
|
||||||
|
}
|
||||||
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
|
|
|
@ -1562,30 +1562,34 @@ static int check_autocorrelate(const char *prefix, int clock) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, _CYAN_("%s - auto correlations"), prefix);
|
PrintAndLogEx(INFO, _CYAN_("%s - auto correlations"), prefix);
|
||||||
for (int win = 2000; win < 30000; win += 2000) {
|
for (int win = 2000; win < 30000; win += 2000) {
|
||||||
int ans = AutoCorrelate(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, win, false, false);
|
int samples = AutoCorrelate(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, win, false, false);
|
||||||
if (ans == -1) {
|
if (samples == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ans > 1) {
|
if ((samples > 1) && (clock > 0)) {
|
||||||
PrintAndLogEx(SUCCESS, " " _YELLOW_("%d") " repeating samples", ans);
|
|
||||||
|
|
||||||
// If we got a field clock / bit rate from before
|
// If we got a field clock / bit rate from before
|
||||||
// we can use it for predict number of repeating bytes
|
// we can use it for predict number of repeating bytes within
|
||||||
// this signal contain.
|
|
||||||
if (clock > 0) {
|
|
||||||
int bytes = round( (float)ans / (8 * clock));
|
|
||||||
int mod = (bytes % 4);
|
|
||||||
int blocks = (bytes / 4);
|
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, " " _YELLOW_("%u") " clock, " _YELLOW_("%d") " bytes repeating", clock, bytes);
|
int bytes = (samples / (8 * clock));
|
||||||
|
int mod = (bytes % 4);
|
||||||
|
if (mod)
|
||||||
|
bytes++;
|
||||||
|
|
||||||
if (mod == 0 && blocks < 7) {
|
int blocks = (bytes / 4);
|
||||||
PrintAndLogEx(SUCCESS, " " _YELLOW_("%d") " T5577 block%c needed", (bytes / 4), (mod == 1) ? ' ' : 's');
|
PrintAndLogEx(SUCCESS, " " _YELLOW_("%d") " samples / 8 bits / " _YELLOW_("%d") " clock", samples, clock);
|
||||||
}
|
PrintAndLogEx(SUCCESS, " " _YELLOW_("%d") " bytes repeating", bytes);
|
||||||
|
|
||||||
|
if (blocks < 7) {
|
||||||
|
PrintAndLogEx(SUCCESS, " " _YELLOW_("%d") " block%c", blocks, (blocks == 1) ? ' ' : 's');
|
||||||
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(INFO, " " _YELLOW_("%d") " blocks ( too large for T5577 )", blocks);
|
||||||
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
return PM3_EFAILED;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "");
|
|
||||||
return PM3_SUCCESS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
@ -1598,16 +1602,16 @@ int CmdLFfind(const char *Cmd) {
|
||||||
CLIParserInit(&ctx, "lf search",
|
CLIParserInit(&ctx, "lf search",
|
||||||
"Read and search for valid known tag. For offline mode, you can `data load` first then search.",
|
"Read and search for valid known tag. For offline mode, you can `data load` first then search.",
|
||||||
"lf search -> try reading data from tag & search for known tag\n"
|
"lf search -> try reading data from tag & search for known tag\n"
|
||||||
"lf search -1 -> use data from the GraphBuffer & search for known tag\n"
|
|
||||||
"lf search -u -> try reading data from tag & search for known and unknown tag\n"
|
"lf search -u -> try reading data from tag & search for known and unknown tag\n"
|
||||||
"lf search -1u -> use data from the GraphBuffer & search for known and unknown tag\n"
|
"lf search -1 -> use data from the GraphBuffer & search for known tag\n"
|
||||||
|
"lf search -1uc -> use data from the GraphBuffer & search for known and unknown tag\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
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 (offline mode)"),
|
||||||
arg_lit0("c", NULL, "Continue searching even after a first hit"),
|
arg_lit0("c", NULL, "Continue searching after successful match"),
|
||||||
arg_lit0("u", NULL, "Search for unknown tags. If not set, reads only known tags"),
|
arg_lit0("u", NULL, "Search for unknown tags"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
@ -1627,13 +1631,11 @@ int CmdLFfind(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search_cont) {
|
if (search_cont) {
|
||||||
PrintAndLogEx(INFO, "Continuous search enabled");
|
PrintAndLogEx(INFO, "Continue searching after successful match");
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "NOTE: some demods output possible binary");
|
PrintAndLogEx(INFO, "Note: False Positives " _YELLOW_("ARE") " possible");
|
||||||
PrintAndLogEx(INFO, "if it finds something that looks like a tag");
|
|
||||||
PrintAndLogEx(INFO, "False Positives " _YELLOW_("ARE") " possible");
|
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(INFO, "");
|
||||||
PrintAndLogEx(INFO, _CYAN_("Checking for known tags..."));
|
PrintAndLogEx(INFO, _CYAN_("Checking for known tags..."));
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(INFO, "");
|
||||||
|
@ -1913,6 +1915,15 @@ int CmdLFfind(const char *Cmd) {
|
||||||
// test unknown tag formats (raw mode)
|
// test unknown tag formats (raw mode)
|
||||||
PrintAndLogEx(INFO, _CYAN_("Checking for unknown tags...") "\n");
|
PrintAndLogEx(INFO, _CYAN_("Checking for unknown tags...") "\n");
|
||||||
|
|
||||||
|
uint8_t ones[] = {
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
};
|
||||||
|
|
||||||
// FSK
|
// FSK
|
||||||
PrintAndLogEx(INFO, "FSK clock.......... " NOLF);
|
PrintAndLogEx(INFO, "FSK clock.......... " NOLF);
|
||||||
int clock = GetFskClock("", false);
|
int clock = GetFskClock("", false);
|
||||||
|
@ -1920,12 +1931,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, _GREEN_("detected"));
|
PrintAndLogEx(NORMAL, _GREEN_("detected"));
|
||||||
if (FSKrawDemod(0, 0, 0, 0, true) == PM3_SUCCESS) {
|
if (FSKrawDemod(0, 0, 0, 0, true) == PM3_SUCCESS) {
|
||||||
check_autocorrelate("FSK", clock);
|
check_autocorrelate("FSK", clock);
|
||||||
|
found++;
|
||||||
if (search_cont) {
|
|
||||||
found++;
|
|
||||||
} else {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "FSK demodulation... " _RED_("failed"));
|
PrintAndLogEx(INFO, "FSK demodulation... " _RED_("failed"));
|
||||||
}
|
}
|
||||||
|
@ -1944,12 +1950,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, _GREEN_("ASK") " modulation / Manchester encoding detected!");
|
PrintAndLogEx(INFO, _GREEN_("ASK") " modulation / Manchester encoding detected!");
|
||||||
PrintAndLogEx(INFO, " could also be ASK/Biphase - try " _YELLOW_("'data rawdemod --ab'"));
|
PrintAndLogEx(INFO, " could also be ASK/Biphase - try " _YELLOW_("'data rawdemod --ab'"));
|
||||||
check_autocorrelate("ASK", clock);
|
check_autocorrelate("ASK", clock);
|
||||||
|
found++;
|
||||||
if (search_cont) {
|
|
||||||
found++;
|
|
||||||
} else {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "ASK demodulation... " _RED_("failed"));
|
PrintAndLogEx(INFO, "ASK demodulation... " _RED_("failed"));
|
||||||
}
|
}
|
||||||
|
@ -1960,15 +1961,18 @@ int CmdLFfind(const char *Cmd) {
|
||||||
// NZR
|
// NZR
|
||||||
PrintAndLogEx(INFO, "NRZ clock.......... " NOLF);
|
PrintAndLogEx(INFO, "NRZ clock.......... " NOLF);
|
||||||
clock = GetNrzClock("", false);
|
clock = GetNrzClock("", false);
|
||||||
if (clock) {
|
if (clock && clock > 8) {
|
||||||
PrintAndLogEx(NORMAL, _GREEN_("detected"));
|
PrintAndLogEx(NORMAL, _GREEN_("detected"));
|
||||||
if (NRZrawDemod(0, 0, 0, true) == PM3_SUCCESS) {
|
if (NRZrawDemod(0, 0, 0, true) == PM3_SUCCESS) {
|
||||||
check_autocorrelate("NRZ", clock);
|
|
||||||
|
|
||||||
if (search_cont) {
|
int min = MIN(g_DemodBufferLen, sizeof(ones));
|
||||||
|
// if demodulated binary is only 1, skip autocorrect
|
||||||
|
if (memcmp(g_DemodBuffer, ones, min) != 0) {
|
||||||
|
check_autocorrelate("NRZ", clock);
|
||||||
found++;
|
found++;
|
||||||
} else {
|
} else {
|
||||||
goto out;
|
PrintAndLogEx(INFO, "NRZ ............... " _RED_("false positive"));
|
||||||
|
PrintAndLogEx(NORMAL, "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "NRZ demodulation... " _RED_("failed"));
|
PrintAndLogEx(INFO, "NRZ demodulation... " _RED_("failed"));
|
||||||
|
@ -1988,12 +1992,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
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"));
|
||||||
check_autocorrelate("PSK", clock);
|
check_autocorrelate("PSK", clock);
|
||||||
|
found++;
|
||||||
if (search_cont) {
|
|
||||||
found++;
|
|
||||||
} else {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "PSK demodulation... " _RED_("failed"));
|
PrintAndLogEx(INFO, "PSK demodulation... " _RED_("failed"));
|
||||||
}
|
}
|
||||||
|
@ -2002,7 +2001,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == 0) {
|
if (found == 0) {
|
||||||
PrintAndLogEx(FAILED, _RED_("Failed to determine any modulations or patterns"));
|
PrintAndLogEx(FAILED, _RED_("Failed to demodulated signal"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue