Adding support for 4K magic cards

This commit is contained in:
Simon Yorkston 2017-03-01 18:41:16 +01:00
parent c51caf424a
commit 6c44c20ffc
2 changed files with 26 additions and 13 deletions

View file

@ -365,13 +365,23 @@ main(int argc, char *argv[])
// now reset UID
iso14443a_crc_append(abtHalt, 2);
transmit_bytes(abtHalt, 4);
transmit_bits(abtUnlock1, 7);
if (format) {
transmit_bytes(abtWipe, 1);
transmit_bytes(abtHalt, 4);
transmit_bits(abtUnlock1, 7);
if (!transmit_bits(abtUnlock1, 7)) {
printf("Warning: Unlock command [1/2]: failed / not acknowledged.\n");
} else {
if (format) {
transmit_bytes(abtWipe, 1);
transmit_bytes(abtHalt, 4);
transmit_bits(abtUnlock1, 7);
}
if (transmit_bytes(abtUnlock2, 1)) {
printf("Card unlocked\n");
} else {
printf("Warning: Unlock command [2/2]: failed / not acknowledged.\n");
}
}
transmit_bytes(abtUnlock2, 1);
transmit_bytes(abtWrite, 4);
transmit_bytes(abtData, 18);
if (format) {

View file

@ -70,6 +70,7 @@ static bool bForceKeyFile;
static bool bTolerateFailures;
static bool bFormatCard;
static bool magic2 = false;
static bool unlocked = false;
static uint8_t uiBlocks;
static uint8_t keys[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -248,12 +249,14 @@ unlock_card(void)
transmit_bytes(abtHalt, 4);
// now send unlock
if (!transmit_bits(abtUnlock1, 7)) {
printf("unlock failure!\n");
return false;
}
if (!transmit_bytes(abtUnlock2, 1)) {
printf("unlock failure!\n");
return false;
printf("Warning: Unlock command [1/2]: failed / not acknowledged.\n");
} else {
if (transmit_bytes(abtUnlock2, 1)) {
printf("Card unlocked\n");
unlocked = true;
} else {
printf("Warning: Unlock command [2/2]: failed / not acknowledged.\n");
}
}
// reset reader
@ -668,7 +671,7 @@ main(int argc, const char *argv[])
print_nfc_target(&nt, false);
// Guessing size
if ((nt.nti.nai.abtAtqa[1] & 0x02) == 0x02)
if ((nt.nti.nai.abtAtqa[1] & 0x02) == 0x02 || nt.nti.nai.btSak == 0x18)
// 4K
uiBlocks = 0xff;
else if (nt.nti.nai.btSak == 0x09)