mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
Revamped t55xx info: support offline block0, Q5, fix extended, add warns etc
This commit is contained in:
parent
43ca641939
commit
e88fa75fd0
2 changed files with 182 additions and 67 deletions
|
@ -81,13 +81,19 @@ int usage_t55xx_trace() {
|
|||
return 0;
|
||||
}
|
||||
int usage_t55xx_info() {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx info [1]");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx info [1] [d <data> [q]]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag.");
|
||||
PrintAndLogEx(NORMAL, " (default) - read data from tag.");
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer instead of reading tag.");
|
||||
PrintAndLogEx(NORMAL, " d <data> - 4 bytes of data (8 hex characters)");
|
||||
PrintAndLogEx(NORMAL, " if set, use these data instead of reading tag.");
|
||||
PrintAndLogEx(NORMAL, " q - if set, provided data are interpreted as Q5 config.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx info");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx info 1");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx info d 00083040");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx info d 6001805A q");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1251,7 +1257,6 @@ void printT5555Trace(t5555_tracedata_t data, uint8_t repeat) {
|
|||
*/
|
||||
}
|
||||
|
||||
//need to add Q5 info...
|
||||
int CmdT55xxInfo(const char *Cmd) {
|
||||
/*
|
||||
Page 0 Block 0 Configuration data.
|
||||
|
@ -1259,81 +1264,130 @@ int CmdT55xxInfo(const char *Cmd) {
|
|||
Extended mode
|
||||
*/
|
||||
bool pwdmode = false;
|
||||
bool frombuff = false;
|
||||
bool gotdata = false;
|
||||
bool dataasq5 = false;
|
||||
uint32_t password = 0;
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
uint32_t block0 = 0;
|
||||
uint8_t cmdp = 0;
|
||||
|
||||
if (strlen(Cmd) > 1 || cmdp == 'h') return usage_t55xx_info();
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_t55xx_info();
|
||||
case 'd':
|
||||
block0 = param_get32ex(Cmd, cmdp + 1, 0, 16);
|
||||
gotdata = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
case '1':
|
||||
frombuff = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'q':
|
||||
dataasq5 = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
return usage_t55xx_info();
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(Cmd) == 0) {
|
||||
if (gotdata && frombuff)
|
||||
return usage_t55xx_info();
|
||||
|
||||
if (dataasq5 && !gotdata)
|
||||
return usage_t55xx_info();
|
||||
|
||||
if (!frombuff && !gotdata) {
|
||||
// sanity check.
|
||||
if (!SanityOfflineCheck(false)) return 1;
|
||||
|
||||
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, pwdmode, password))
|
||||
return 1;
|
||||
}
|
||||
if (!gotdata) {
|
||||
if (!DecodeT55xxBlock()) return 1;
|
||||
|
||||
if (!DecodeT55xxBlock()) return 1;
|
||||
// too little space to start with
|
||||
if (DemodBufferLen < 32 + config.offset) return 1;
|
||||
|
||||
// too little space to start with
|
||||
if (DemodBufferLen < 32) return 1;
|
||||
|
||||
//
|
||||
//PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, DemodBufferLen);
|
||||
|
||||
uint8_t si = config.offset;
|
||||
uint32_t block0 = PackBits(si, 32, DemodBuffer);
|
||||
uint32_t safer = PackBits(si, 4, DemodBuffer);
|
||||
si += 4;
|
||||
uint32_t resv = PackBits(si, 7, DemodBuffer);
|
||||
si += 7;
|
||||
uint32_t dbr = PackBits(si, 3, DemodBuffer);
|
||||
si += 3;
|
||||
uint32_t extend = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t datamod = PackBits(si, 5, DemodBuffer);
|
||||
si += 5;
|
||||
uint32_t pskcf = PackBits(si, 2, DemodBuffer);
|
||||
si += 2;
|
||||
uint32_t aor = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t otp = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t maxblk = PackBits(si, 3, DemodBuffer);
|
||||
si += 3;
|
||||
uint32_t pwd = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t sst = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t fw = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t inv = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
uint32_t por = PackBits(si, 1, DemodBuffer);
|
||||
si += 1;
|
||||
|
||||
if (config.Q5)
|
||||
PrintAndLogEx(NORMAL, _RED_("* **Warning ***") " Config Info read off a Q5 will not display as expected");
|
||||
//PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, DemodBufferLen);
|
||||
block0 = PackBits(config.offset, 32, DemodBuffer);
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "-- T55x7 Configuration & Tag Information --------------------");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, " Safer key : %s", GetSaferStr(safer));
|
||||
PrintAndLogEx(NORMAL, " reserved : %d", resv);
|
||||
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, extend));
|
||||
PrintAndLogEx(NORMAL, " eXtended mode : %s", (extend) ? _YELLOW_("Yes - Warning") : "No");
|
||||
PrintAndLogEx(NORMAL, " Modulation : %s", GetModulationStr(datamod));
|
||||
PrintAndLogEx(NORMAL, " PSK clock frequency : %d", pskcf);
|
||||
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " OTP - One Time Pad : %s", (otp) ? _YELLOW_("Yes - Warning") : "No");
|
||||
PrintAndLogEx(NORMAL, " Max block : %d", maxblk);
|
||||
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Sequence Start Terminator : %s", (sst) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " POR-Delay : %s", (por) ? _GREEN_("Yes") : "No");
|
||||
if (config.Q5 || (gotdata && dataasq5)) {
|
||||
uint32_t header = (block0 >> (32 - 12)) & 0xFFF;
|
||||
uint32_t ps = (block0 >> (32 - 13)) & 0x01;
|
||||
uint32_t fw = (block0 >> (32 - 14)) & 0x01;
|
||||
uint32_t dbr = (block0 >> (32 - 20)) & 0x3F;
|
||||
uint32_t aor = (block0 >> (32 - 21)) & 0x01;
|
||||
uint32_t pwd = (block0 >> (32 - 22)) & 0x01;
|
||||
uint32_t pskcf = (block0 >> (32 - 24)) & 0x03;
|
||||
uint32_t inv = (block0 >> (32 - 25)) & 0x01;
|
||||
uint32_t datamod = (block0 >> (32 - 28)) & 0x07;
|
||||
uint32_t maxblk = (block0 >> (32 - 31)) & 0x07;
|
||||
uint32_t st = (block0 >> (32 - 32)) & 0x01;
|
||||
PrintAndLogEx(NORMAL, "-- Q5 Configuration & Tag Information -----------------------");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, " Header : 0x%03X%s", header, (header != 0x600) ? _RED_(" - Warning") : "");
|
||||
PrintAndLogEx(NORMAL, " Page select : %d", ps);
|
||||
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, 1));
|
||||
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " PSK clock frequency : %s", GetPskCfStr(pskcf, 1));
|
||||
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Modulation : %s", GetQ5ModulationStr(datamod));
|
||||
PrintAndLogEx(NORMAL, " Max block : %d", maxblk);
|
||||
PrintAndLogEx(NORMAL, " Sequence Terminator : %s", (st) ? _GREEN_("Yes") : "No");
|
||||
} else {
|
||||
uint32_t safer = (block0 >> (32 - 4)) & 0x0F;
|
||||
uint32_t extend = (block0 >> (32 - 15)) & 0x01;
|
||||
uint32_t resv, dbr;
|
||||
if (extend) {
|
||||
resv = (block0 >> (32 - 8)) & 0x0F;
|
||||
dbr = (block0 >> (32 - 14)) & 0x3F;
|
||||
} else {
|
||||
resv = (block0 >> (32 - 11)) & 0x7F;
|
||||
dbr = (block0 >> (32 - 14)) & 0x07;
|
||||
}
|
||||
uint32_t datamod = (block0 >> (32 - 20)) & 0x1F;
|
||||
uint32_t pskcf = (block0 >> (32 - 22)) & 0x03;
|
||||
uint32_t aor = (block0 >> (32 - 23)) & 0x01;
|
||||
uint32_t otp = (block0 >> (32 - 24)) & 0x01;
|
||||
uint32_t maxblk = (block0 >> (32 - 27)) & 0x07;
|
||||
uint32_t pwd = (block0 >> (32 - 28)) & 0x01;
|
||||
uint32_t sst = (block0 >> (32 - 29)) & 0x01;
|
||||
uint32_t fw = (block0 >> (32 - 30)) & 0x01;
|
||||
uint32_t inv = (block0 >> (32 - 31)) & 0x01;
|
||||
uint32_t por = (block0 >> (32 - 32)) & 0x01;
|
||||
|
||||
PrintAndLogEx(NORMAL, "-- T55x7 Configuration & Tag Information --------------------");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, " Safer key : %s", GetSaferStr(safer));
|
||||
PrintAndLogEx(NORMAL, " reserved : %d", resv);
|
||||
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, extend));
|
||||
PrintAndLogEx(NORMAL, " eXtended mode : %s", (extend) ? _YELLOW_("Yes - Warning") : "No");
|
||||
PrintAndLogEx(NORMAL, " Modulation : %s", GetModulationStr(datamod));
|
||||
PrintAndLogEx(NORMAL, " PSK clock frequency : %s", GetPskCfStr(pskcf, 0));
|
||||
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " OTP - One Time Pad : %s", (otp) ? ((extend) ? _YELLOW_("Yes - Warning") : _RED_("Yes - Warning")) : "No");
|
||||
PrintAndLogEx(NORMAL, " Max block : %d", maxblk);
|
||||
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Sequence %-12s : %s", (extend) ? "Start Marker" : "Terminator", (sst) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? ((extend) ? _GREEN_("Yes") : _RED_("Yes - Warning")) : "No");
|
||||
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? ((extend) ? _GREEN_("Yes") : _RED_("Yes - Warning")) : "No");
|
||||
PrintAndLogEx(NORMAL, " POR-Delay : %s", (por) ? _GREEN_("Yes") : "No");
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(NORMAL, " Raw Data - Page 0");
|
||||
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
|
||||
if (gotdata)
|
||||
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X", block0);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1383,6 +1437,32 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
|
|||
return !getSignalProperties()->isnoise;
|
||||
}
|
||||
|
||||
char *GetPskCfStr(uint32_t id, bool q5) {
|
||||
static char buf[25];
|
||||
char *retStr = buf;
|
||||
switch (id) {
|
||||
case 0:
|
||||
snprintf(retStr, sizeof(buf), "%u - RF/2", id);
|
||||
break;
|
||||
case 1:
|
||||
snprintf(retStr, sizeof(buf), "%u - RF/4", id);
|
||||
break;
|
||||
case 2:
|
||||
snprintf(retStr, sizeof(buf), "%u - RF/8", id);
|
||||
break;
|
||||
case 3:
|
||||
if (q5)
|
||||
snprintf(retStr, sizeof(buf), "%u - RF/8", id);
|
||||
else
|
||||
snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
|
||||
break;
|
||||
default:
|
||||
snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *GetBitRateStr(uint32_t id, bool xmode) {
|
||||
static char buf[25];
|
||||
|
||||
|
@ -1416,7 +1496,7 @@ char *GetBitRateStr(uint32_t id, bool xmode) {
|
|||
snprintf(retStr, sizeof(buf), "%u - RF/128", id);
|
||||
break;
|
||||
default:
|
||||
snprintf(retStr, sizeof(buf), "%u - (Unknown)", id);
|
||||
snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1477,10 +1557,43 @@ char *GetModulationStr(uint32_t id) {
|
|||
snprintf(retStr, sizeof(buf), "%u - Biphase a - AKA Conditional Dephase Encoding(CDP)", id);
|
||||
break;
|
||||
case 17:
|
||||
snprintf(retStr, sizeof(buf), "%u - Reserved", id);
|
||||
snprintf(retStr, sizeof(buf), "%u - " _YELLOW_("Reserved"), id);
|
||||
break;
|
||||
default:
|
||||
snprintf(retStr, sizeof(buf), "0x%02X (Unknown)", id);
|
||||
snprintf(retStr, sizeof(buf), "0x%02X " _RED_("(Unknown)"), id);
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *GetQ5ModulationStr(uint32_t id) {
|
||||
static char buf[60];
|
||||
char *retStr = buf;
|
||||
|
||||
switch (id) {
|
||||
case 0:
|
||||
snprintf(retStr, sizeof(buf), "%u - Manchester", id);
|
||||
break;
|
||||
case 1:
|
||||
snprintf(retStr, sizeof(buf), "%u - PSK 1 phase change when input changes", id);
|
||||
break;
|
||||
case 2:
|
||||
snprintf(retStr, sizeof(buf), "%u - PSK 2 phase change on bitclk if input high", id);
|
||||
break;
|
||||
case 3:
|
||||
snprintf(retStr, sizeof(buf), "%u - PSK 3 phase change on rising edge of input", id);
|
||||
break;
|
||||
case 4:
|
||||
snprintf(retStr, sizeof(buf), "%u - FSK 1a RF/5 RF/8", id);
|
||||
break;
|
||||
case 5:
|
||||
snprintf(retStr, sizeof(buf), "%u - FSK 2a RF/10 RF/8", id);
|
||||
break;
|
||||
case 6:
|
||||
snprintf(retStr, sizeof(buf), "%u - Biphase", id);
|
||||
break;
|
||||
case 7:
|
||||
snprintf(retStr, sizeof(buf), "%u - NRZ / Direct", id);
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
|
@ -1539,7 +1652,7 @@ char *GetSelectedModulationStr(uint8_t id) {
|
|||
snprintf(retStr, sizeof(buf), "BIPHASEa - (CDP)");
|
||||
break;
|
||||
default:
|
||||
snprintf(retStr, sizeof(buf), "(Unknown)");
|
||||
snprintf(retStr, sizeof(buf), _RED_("(Unknown)"));
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
|
|
|
@ -149,8 +149,10 @@ extern int CmdT55xxDetect(const char *Cmd);
|
|||
extern int CmdResetRead(const char *Cmd);
|
||||
extern int CmdT55xxWipe(const char *Cmd);
|
||||
|
||||
char *GetPskCfStr(uint32_t id, bool q5);
|
||||
char *GetBitRateStr(uint32_t id, bool xmode);
|
||||
char *GetSaferStr(uint32_t id);
|
||||
char *GetQ5ModulationStr(uint32_t id);
|
||||
char *GetModulationStr(uint32_t id);
|
||||
char *GetModelStrFromCID(uint32_t cid);
|
||||
char *GetSelectedModulationStr(uint8_t id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue