diff --git a/examples/nfc-mfsetuid.c b/examples/nfc-mfsetuid.c index dd1e648..57ebd53 100644 --- a/examples/nfc-mfsetuid.c +++ b/examples/nfc-mfsetuid.c @@ -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) { diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 55c2bfe..dfa5314 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -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)