Skip to content

Commit

Permalink
Adding support for 4K magic cards
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-x committed Mar 1, 2017
1 parent c51caf4 commit 6c44c20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
22 changes: 16 additions & 6 deletions examples/nfc-mfsetuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 10 additions & 7 deletions utils/nfc-mfclassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6c44c20

Please sign in to comment.