mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Fix sniffing command.
Refactor hf list felica.
This commit is contained in:
parent
76215fffc6
commit
1a852e02c7
4 changed files with 36 additions and 18 deletions
|
@ -573,25 +573,26 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
||||||
|
|
||||||
int remFrames = (samplesToSkip) ? samplesToSkip : 0;
|
int remFrames = (samplesToSkip) ? samplesToSkip : 0;
|
||||||
|
|
||||||
Dbprintf("Sniff FelicaLiteS: Getting first %d frames, Skipping %d triggers.\n", samplesToSkip, triggersToSkip);
|
Dbprintf("Sniff FelicaLiteS: Getting first %d frames, Skipping %d triggers.\n", samplesToSkip, triggersToSkip);
|
||||||
|
|
||||||
iso18092_setup(FPGA_HF_ISO18092_FLAG_NOMOD);
|
iso18092_setup(FPGA_HF_ISO18092_FLAG_NOMOD);
|
||||||
|
LED_D_ON();
|
||||||
|
BigBuf_free();
|
||||||
|
BigBuf_Clear();
|
||||||
//the frame bits are slow enough.
|
//the frame bits are slow enough.
|
||||||
int n = BigBuf_max_traceLen() / sizeof(uint8_t); // take all memory
|
int n = BigBuf_max_traceLen() / sizeof(uint8_t); // take all memory
|
||||||
int numbts = 0;
|
int numbts = 0;
|
||||||
uint8_t *dest = (uint8_t *)BigBuf_get_addr();
|
uint8_t *dest = (uint8_t *)BigBuf_get_addr();
|
||||||
uint8_t *destend = dest + n - 2;
|
uint8_t *destend = dest + n - 2;
|
||||||
|
|
||||||
uint32_t endframe = GetCountSspClk();
|
uint32_t endframe = GetCountSspClk();
|
||||||
|
|
||||||
while (dest <= destend) {
|
// Set up the synchronous serial port
|
||||||
WDT_HIT();
|
FpgaSetupSsc();
|
||||||
if (BUTTON_PRESS()) break;
|
//FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP);
|
||||||
|
SpinDelay(100);
|
||||||
|
|
||||||
|
while (dest <= destend && !BUTTON_PRESS()) {
|
||||||
|
WDT_HIT();
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||||
uint8_t dist = (uint8_t)(AT91C_BASE_SSC->SSC_RHR);
|
uint8_t dist = (uint8_t)(AT91C_BASE_SSC->SSC_RHR);
|
||||||
Process18092Byte(dist);
|
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());
|
Dbprintf("Felica sniffing done, tracelen: %i, use hf list felica for annotations", BigBuf_get_traceLen());
|
||||||
reply_old(CMD_ACK, 1, numbts, 0, 0, 0);
|
reply_old(CMD_ACK, 1, numbts, 0, 0, 0);
|
||||||
|
LED_D_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define R_POLL0_LEN 0x16
|
#define R_POLL0_LEN 0x16
|
||||||
|
|
|
@ -97,6 +97,10 @@ uint8_t iso15693_CRC_check(uint8_t *d, uint8_t n) {
|
||||||
return check_crc(CRC_15693, d, 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
|
* @brief iclass_CRC_Ok Checks CRC in command or response
|
||||||
* @param isResponse
|
* @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) {
|
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
|
switch (cmd[3]) {
|
||||||
switch (cmd[0]) {
|
|
||||||
case FELICA_POLL_REQ:
|
case FELICA_POLL_REQ:
|
||||||
snprintf(exp, size, "POLLING");
|
snprintf(exp, size, "POLLING");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -31,6 +31,7 @@ void ClearAuthData(void);
|
||||||
|
|
||||||
uint8_t iso14443A_CRC_check(bool isResponse, uint8_t *d, uint8_t n);
|
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 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 mifare_CRC_check(bool isResponse, uint8_t *data, uint8_t len);
|
||||||
uint8_t iso15693_CRC_check(uint8_t *d, uint8_t n);
|
uint8_t iso15693_CRC_check(uint8_t *d, uint8_t n);
|
||||||
uint8_t iclass_CRC_check(bool isResponse, uint8_t *d, uint8_t n);
|
uint8_t iclass_CRC_check(bool isResponse, uint8_t *d, uint8_t n);
|
||||||
|
|
|
@ -257,7 +257,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
case ISO_14443B:
|
case ISO_14443B:
|
||||||
case TOPAZ:
|
case TOPAZ:
|
||||||
case FELICA:
|
case FELICA:
|
||||||
crcStatus = iso14443B_CRC_check(frame, data_len);
|
crcStatus = !felica_CRC_check(frame+2, data_len-4);
|
||||||
break;
|
break;
|
||||||
case PROTO_MIFARE:
|
case PROTO_MIFARE:
|
||||||
crcStatus = mifare_CRC_check(isResponse, frame, data_len);
|
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)
|
if (protocol == PROTO_MIFARE)
|
||||||
annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, parity_len, isResponse);
|
annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, parity_len, isResponse);
|
||||||
|
|
||||||
|
if(protocol == FELICA)
|
||||||
|
annotateFelica(explanation, sizeof(explanation), frame, data_len);
|
||||||
|
|
||||||
if (!isResponse) {
|
if (!isResponse) {
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case ICLASS:
|
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),
|
sprint_hex_inrow_spaces(mfData, mfDataLen, 2),
|
||||||
(crcc == 0 ? "!crc" : (crcc == 1 ? " ok " : " ")),
|
(crcc == 0 ? "!crc" : (crcc == 1 ? " ok " : " ")),
|
||||||
explanation);
|
explanation);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (is_last_record(tracepos, trace, traceLen)) return traceLen;
|
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;
|
return tracepos;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static void printFelica(uint16_t traceLen, uint8_t *trace) {
|
static void printFelica(uint16_t traceLen, uint8_t *trace) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "ISO18092 / FeliCa - Timings are not as accurate");
|
PrintAndLogEx(NORMAL, "ISO18092 / FeliCa - Timings are not as accurate");
|
||||||
PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |");
|
PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |");
|
||||||
PrintAndLogEx(NORMAL, "--------|-----|---------------------------------|----------|-------------------|");
|
PrintAndLogEx(NORMAL, "--------|-----|-------------------------------------------------------------------------|----------|-------------------|");
|
||||||
uint16_t tracepos = 0;
|
uint16_t tracepos = 0;
|
||||||
|
|
||||||
|
PrintAndLogEx(NORMAL, "traceLen: %i", traceLen);
|
||||||
|
PrintAndLogEx(NORMAL, "Raw trace: %s", sprint_hex(trace, traceLen));
|
||||||
while (tracepos < traceLen) {
|
while (tracepos < traceLen) {
|
||||||
|
PrintAndLogEx(NORMAL, "tracepos: %i", tracepos);
|
||||||
|
PrintAndLogEx(NORMAL, "traceLen: %i", traceLen);
|
||||||
|
|
||||||
if (tracepos + 3 >= traceLen) break;
|
if (tracepos + 3 >= traceLen) break;
|
||||||
|
|
||||||
|
|
||||||
uint16_t gap = *((uint16_t *)(trace + tracepos));
|
uint16_t gap = *((uint16_t *)(trace + tracepos));
|
||||||
uint8_t crc_ok = trace[tracepos + 2];
|
uint8_t crc_ok = trace[tracepos + 2];
|
||||||
tracepos += 3;
|
tracepos += 3;
|
||||||
|
@ -443,6 +449,7 @@ static void printFelica(uint16_t traceLen, uint8_t *trace) {
|
||||||
if (tracepos + 3 >= traceLen) break;
|
if (tracepos + 3 >= traceLen) break;
|
||||||
|
|
||||||
uint16_t len = trace[tracepos + 2];
|
uint16_t len = trace[tracepos + 2];
|
||||||
|
PrintAndLogEx(NORMAL, "LEN: %i", len);
|
||||||
|
|
||||||
//I am stripping SYNC
|
//I am stripping SYNC
|
||||||
tracepos += 3; //skip SYNC
|
tracepos += 3; //skip SYNC
|
||||||
|
@ -611,7 +618,7 @@ static void printFelica(uint16_t traceLen, uint8_t *trace) {
|
||||||
tracepos += len + 1;
|
tracepos += len + 1;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// sanity check. Don't use proxmark if it is offline and you didn't specify useTraceBuffer
|
// 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(SUCCESS, "Recorded Activity (TraceLen = %lu bytes)", traceLen);
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(INFO, "");
|
||||||
|
|
||||||
|
/*
|
||||||
if (protocol == FELICA) {
|
if (protocol == FELICA) {
|
||||||
printFelica(traceLen, trace);
|
printFelica(traceLen, trace);
|
||||||
} else if (showHex) {
|
} */
|
||||||
|
|
||||||
|
if (showHex) {
|
||||||
while (tracepos < traceLen) {
|
while (tracepos < traceLen) {
|
||||||
tracepos = printHexLine(tracepos, traceLen, trace, protocol);
|
tracepos = printHexLine(tracepos, traceLen, trace, protocol);
|
||||||
}
|
}
|
||||||
|
@ -844,6 +855,7 @@ int CmdTraceList(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "ISO7816-4 / Smartcard - Timings N/A yet");
|
PrintAndLogEx(NORMAL, "ISO7816-4 / Smartcard - Timings N/A yet");
|
||||||
if (protocol == PROTO_HITAG)
|
if (protocol == PROTO_HITAG)
|
||||||
PrintAndLogEx(NORMAL, "Hitag2 / HitagS - Timings in ETU (8us)");
|
PrintAndLogEx(NORMAL, "Hitag2 / HitagS - Timings in ETU (8us)");
|
||||||
|
if (protocol == FELICA)
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");
|
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue