Merge pull request #394 from lab-401/master-4k-magic

Adding support for 4K magic cards
This commit is contained in:
Philippe Teuwen 2017-03-02 15:01:05 +01:00 committed by GitHub
commit 787382f4d5
2 changed files with 26 additions and 13 deletions

View file

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

View file

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