Fix sniffing command.

Refactor hf list felica.
This commit is contained in:
Thomas Sutter 2019-10-30 13:35:03 +01:00
parent 76215fffc6
commit 1a852e02c7
4 changed files with 36 additions and 18 deletions

View file

@ -573,25 +573,26 @@ void felica_sendraw(PacketCommandNG *c) {
}
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
int remFrames = (samplesToSkip) ? samplesToSkip : 0;
Dbprintf("Sniff FelicaLiteS: Getting first %d frames, Skipping %d triggers.\n", samplesToSkip, triggersToSkip);
iso18092_setup(FPGA_HF_ISO18092_FLAG_NOMOD);
LED_D_ON();
BigBuf_free();
BigBuf_Clear();
//the frame bits are slow enough.
int n = BigBuf_max_traceLen() / sizeof(uint8_t); // take all memory
int numbts = 0;
uint8_t *dest = (uint8_t *)BigBuf_get_addr();
uint8_t *destend = dest + n - 2;
uint32_t endframe = GetCountSspClk();
while (dest <= destend) {
WDT_HIT();
if (BUTTON_PRESS()) break;
// Set up the synchronous serial port
FpgaSetupSsc();
//FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP);
SpinDelay(100);
while (dest <= destend && !BUTTON_PRESS()) {
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
uint8_t dist = (uint8_t)(AT91C_BASE_SSC->SSC_RHR);
Process18092Byte(dist);
@ -636,6 +637,7 @@ void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
Dbprintf("Felica sniffing done, tracelen: %i, use hf list felica for annotations", BigBuf_get_traceLen());
reply_old(CMD_ACK, 1, numbts, 0, 0, 0);
LED_D_OFF();
}
#define R_POLL0_LEN 0x16

View file

@ -97,6 +97,10 @@ uint8_t iso15693_CRC_check(uint8_t *d, uint8_t n) {
return check_crc(CRC_15693, d, n);
}
uint8_t felica_CRC_check(uint8_t *d, uint8_t n) {
return check_crc(CRC_FELICA, d, n);
}
/**
* @brief iclass_CRC_Ok Checks CRC in command or response
* @param isResponse
@ -889,8 +893,7 @@ void annotateLegic(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
}
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
switch (cmd[0]) {
switch (cmd[3]) {
case FELICA_POLL_REQ:
snprintf(exp, size, "POLLING");
break;

View file

@ -31,6 +31,7 @@ void ClearAuthData(void);
uint8_t iso14443A_CRC_check(bool isResponse, uint8_t *d, uint8_t n);
uint8_t iso14443B_CRC_check(uint8_t *d, uint8_t n);
uint8_t felica_CRC_check(uint8_t *d, uint8_t n);
uint8_t mifare_CRC_check(bool isResponse, uint8_t *data, uint8_t len);
uint8_t iso15693_CRC_check(uint8_t *d, uint8_t n);
uint8_t iclass_CRC_check(bool isResponse, uint8_t *d, uint8_t n);

View file

@ -257,7 +257,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case ISO_14443B:
case TOPAZ:
case FELICA:
crcStatus = iso14443B_CRC_check(frame, data_len);
crcStatus = !felica_CRC_check(frame+2, data_len-4);
break;
case PROTO_MIFARE:
crcStatus = mifare_CRC_check(isResponse, frame, data_len);
@ -349,6 +349,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (protocol == PROTO_MIFARE)
annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, parity_len, isResponse);
if(protocol == FELICA)
annotateFelica(explanation, sizeof(explanation), frame, data_len);
if (!isResponse) {
switch (protocol) {
case ICLASS:
@ -408,7 +411,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
sprint_hex_inrow_spaces(mfData, mfDataLen, 2),
(crcc == 0 ? "!crc" : (crcc == 1 ? " ok " : " ")),
explanation);
};
}
if (is_last_record(tracepos, trace, traceLen)) return traceLen;
@ -423,19 +426,22 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
return tracepos;
}
/*
static void printFelica(uint16_t traceLen, uint8_t *trace) {
PrintAndLogEx(NORMAL, "ISO18092 / FeliCa - Timings are not as accurate");
PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |");
PrintAndLogEx(NORMAL, "--------|-----|---------------------------------|----------|-------------------|");
PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |");
PrintAndLogEx(NORMAL, "--------|-----|-------------------------------------------------------------------------|----------|-------------------|");
uint16_t tracepos = 0;
PrintAndLogEx(NORMAL, "traceLen: %i", traceLen);
PrintAndLogEx(NORMAL, "Raw trace: %s", sprint_hex(trace, traceLen));
while (tracepos < traceLen) {
PrintAndLogEx(NORMAL, "tracepos: %i", tracepos);
PrintAndLogEx(NORMAL, "traceLen: %i", traceLen);
if (tracepos + 3 >= traceLen) break;
uint16_t gap = *((uint16_t *)(trace + tracepos));
uint8_t crc_ok = trace[tracepos + 2];
tracepos += 3;
@ -443,6 +449,7 @@ static void printFelica(uint16_t traceLen, uint8_t *trace) {
if (tracepos + 3 >= traceLen) break;
uint16_t len = trace[tracepos + 2];
PrintAndLogEx(NORMAL, "LEN: %i", len);
//I am stripping SYNC
tracepos += 3; //skip SYNC
@ -611,7 +618,7 @@ static void printFelica(uint16_t traceLen, uint8_t *trace) {
tracepos += len + 1;
}
PrintAndLogEx(NORMAL, "");
}
}*/
// sanity check. Don't use proxmark if it is offline and you didn't specify useTraceBuffer
/*
@ -819,9 +826,13 @@ int CmdTraceList(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = %lu bytes)", traceLen);
PrintAndLogEx(INFO, "");
/*
if (protocol == FELICA) {
printFelica(traceLen, trace);
} else if (showHex) {
} */
if (showHex) {
while (tracepos < traceLen) {
tracepos = printHexLine(tracepos, traceLen, trace, protocol);
}
@ -844,6 +855,7 @@ int CmdTraceList(const char *Cmd) {
PrintAndLogEx(NORMAL, "ISO7816-4 / Smartcard - Timings N/A yet");
if (protocol == PROTO_HITAG)
PrintAndLogEx(NORMAL, "Hitag2 / HitagS - Timings in ETU (8us)");
if (protocol == FELICA)
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");