mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-05 20:41:34 -07:00
Enhance Hitag S annotation and debugging
This commit is contained in:
parent
3d0c8cab5c
commit
64a4f6cd81
4 changed files with 85 additions and 3 deletions
|
@ -474,6 +474,9 @@ static int hts_send_receive(const uint8_t *tx, size_t txlen, uint8_t *rx, size_t
|
|||
// Disable timer 1 with external trigger to avoid triggers during our own modulation
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
|
||||
|
||||
DBG Dbprintf("tx %d bits:", txlen);
|
||||
DBG Dbhexdump((txlen + 7) / 8, tx, false);
|
||||
|
||||
// Wait for HITAG_T_WAIT_SC carrier periods after the last tag bit before transmitting,
|
||||
// Since the clock counts since the last falling edge, a 'one' means that the
|
||||
// falling edge occurred halfway the period. with respect to this falling edge,
|
||||
|
@ -500,6 +503,9 @@ static int hts_send_receive(const uint8_t *tx, size_t txlen, uint8_t *rx, size_t
|
|||
hitag_reader_receive_frame(rx, sizeofrx, rxlen, &start_time, ledcontrol, m, sof_bits);
|
||||
// hts_receive_frame(rx, sizeofrx, rxlen, &start_time, ledcontrol);
|
||||
|
||||
DBG Dbprintf("rx %d bits:", *rxlen);
|
||||
DBG Dbhexdump((*rxlen + 7) / 8, rx, false);
|
||||
|
||||
// Check if frame was captured and store it
|
||||
if (*rxlen > 0) {
|
||||
DBG {
|
||||
|
|
|
@ -36,7 +36,83 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response) {}
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t nbits, bool is_response) {
|
||||
size_t exp_len = 0;
|
||||
uint8_t command = 0;
|
||||
|
||||
if (is_response) {
|
||||
// Handle responses
|
||||
if (nbits == 32) {
|
||||
exp_len = snprintf(exp, size, "UID: [%02X%02X%02X%02X]", cmd[0], cmd[1], cmd[2], cmd[3]);
|
||||
} else if (nbits == 40) {
|
||||
exp_len = snprintf(exp, size, "Data");
|
||||
}
|
||||
} else if (nbits >= 5) {
|
||||
concatbits(&command, 0, cmd, 0, 5, false);
|
||||
|
||||
if (nbits == 5) {
|
||||
concatbits(&command, 0, cmd, 0, 5, false);
|
||||
|
||||
switch (command) {
|
||||
case HITAGS_UID_REQ_STD:
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "UID Request (Standard 00110)");
|
||||
break;
|
||||
case HITAGS_UID_REQ_ADV1:
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "UID Request (Advanced 11000)");
|
||||
break;
|
||||
case HITAGS_UID_REQ_ADV2:
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "UID Request (Advanced 11001)");
|
||||
break;
|
||||
case HITAGS_UID_REQ_FADV:
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "UID Request (Fast Advanced 11010)");
|
||||
break;
|
||||
}
|
||||
} else if (nbits == 4 + 8 + 8) {
|
||||
concatbits(&command, 0, cmd, 0, 4, false);
|
||||
|
||||
if (command == HITAGS_READ_PAGE) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "READ");
|
||||
} else if (command == HITAGS_WRITE_PAGE) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "WRITE");
|
||||
} else if (command == HITAGS_READ_BLOCK) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "READ_BLOCK");
|
||||
} else if (command == HITAGS_WRITE_BLOCK) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "WRITE_BLOCK");
|
||||
} else if (command == HITAGS_QUIET) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "QUIET");
|
||||
}
|
||||
// Hitag 1 commands
|
||||
else if (command == HITAG1_RDCPAGE) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "RDCPAGE");
|
||||
} else if (command == HITAG1_RDCBLK) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "RDCBLK");
|
||||
} else if (command == HITAG1_WRCPAGE) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "WRCPAGE");
|
||||
} else if (command == HITAG1_WRCBLK) {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "WRCBLK");
|
||||
} else {
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "Unknown (%02X)", command);
|
||||
}
|
||||
|
||||
uint8_t page = 0;
|
||||
concatbits(&page, 0, cmd, 5, 8, false);
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, " Page: %d", page);
|
||||
} else if (nbits == 32 + 8) {
|
||||
concatbits(&command, 0, cmd, 0, 5, false);
|
||||
exp_len += snprintf(exp + exp_len, size - exp_len, "Data");
|
||||
} else if (nbits == 5 + 32 + 8 || nbits == 5 + 32 + 1 + 8) {
|
||||
concatbits(&command, 0, cmd, 0, 5, false);
|
||||
|
||||
if (command == HITAGS_SELECT) {
|
||||
uint8_t uid[4] = {0};
|
||||
concatbits(uid, 0, cmd, 5, 32, false);
|
||||
exp_len = snprintf(exp, size, "SELECT UID: %02X%02X%02X%02X", uid[0], uid[1], uid[2], uid[3]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exp_len = snprintf(exp, size, "Invalid command (too short)");
|
||||
}
|
||||
}
|
||||
|
||||
static const char *hts_get_type_str(uint32_t uid) {
|
||||
// source 1: https://www.scorpio-lk.com/downloads/Tango/HITAG_Classification.pdf
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "common.h"
|
||||
#include "hitag.h"
|
||||
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response);
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t nbits, bool is_response);
|
||||
|
||||
int CmdLFHitagS(const char *Cmd);
|
||||
|
||||
|
|
|
@ -801,7 +801,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
|||
annotateHitag2(explanation, sizeof(explanation), frame, data_len, parityBytes[0], hdr->isResponse, mfDicKeys, mfDicKeysCount, false);
|
||||
break;
|
||||
case PROTO_HITAGS:
|
||||
annotateHitagS(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||
annotateHitagS(explanation, sizeof(explanation), frame, (data_len * 8) - ((8 - parityBytes[0]) % 8), hdr->isResponse);
|
||||
break;
|
||||
case ICLASS:
|
||||
annotateIclass(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue