hf 14a info: add ATR fingerprinting
This commit is contained in:
1 parent
7a81838f7d
commit
f93c9977ad
6 files changed
+79
-59
No files matched your search
@@ -1212,64 +1212,6 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void atsToEmulatedAtr(uint8_t *ats, uint8_t *atr, int *atrLen) {
|
||||
uint8_t historicalLen = 0;
|
||||
uint8_t offset = 2;
|
||||
|
||||
if (ats[0] < 2) {
|
||||
historicalLen = 0;
|
||||
} else {
|
||||
|
||||
if ((ats[1] & 64) != 0) {
|
||||
offset++;
|
||||
}
|
||||
if ((ats[1] & 32) != 0) {
|
||||
offset++;
|
||||
}
|
||||
if ((ats[1] & 16) != 0) {
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (offset >= ats[0]) {
|
||||
historicalLen = 0;
|
||||
} else {
|
||||
historicalLen = ats[0] - offset;
|
||||
}
|
||||
}
|
||||
|
||||
atr[0] = 0x3B;
|
||||
atr[1] = 0x80 | historicalLen;
|
||||
atr[2] = 0x80;
|
||||
atr[3] = 0x01;
|
||||
|
||||
uint8_t tck = atr[1] ^ atr[2] ^ atr[3];
|
||||
for (uint8_t i = 0; i < historicalLen; ++i) {
|
||||
atr[4 + i] = ats[offset + i];
|
||||
tck = tck ^ ats[offset + i];
|
||||
}
|
||||
atr[4 + historicalLen] = tck;
|
||||
|
||||
*atrLen = 5 + historicalLen;
|
||||
}
|
||||
|
||||
static void atqbToEmulatedAtr(uint8_t *atqb, uint8_t cid, uint8_t *atr, int *atrLen) {
|
||||
atr[0] = 0x3B;
|
||||
atr[1] = 0x80 | 8;
|
||||
atr[2] = 0x80;
|
||||
atr[3] = 0x01;
|
||||
|
||||
memcpy(atr + 4, atqb, 7);
|
||||
atr[11] = cid >> 4;
|
||||
|
||||
uint8_t tck = 0;
|
||||
for (int i = 1; i < 12; ++i) {
|
||||
tck = tck ^ atr[i];
|
||||
}
|
||||
atr[12] = tck;
|
||||
|
||||
*atrLen = 13;
|
||||
}
|
||||
|
||||
static int CmdPCSC(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "smart pcsc",
|
||||
|
||||
Reference in new issue
Block a user