PN532: How to write blocks of Chinese Clone Mifare card by the libs on Arduino?
There is a program nfc-mfclassic based on libnfc with chip PN532.It’s can unlock special Mifare 1K cards (Chinese clones) which can be read or write all the blocks without authentication. How can I read or write the special Mifare Card on Arduino? Thanks! In the source code of nfc-mfclassic,it send a special command 0x40 0x43.
// special unlock command
uint8_t abtUnlock1[1] = { 0x40 };
uint8_t abtUnlock2[1] = { 0x43 };
Here is the code of unlock in the source code of nfc-mfclassic
static bool
unlock_card(void)
{
if (magic2) {
printf("Don't use R/W with this card, this is not required!\n");
return false;
}
// Configure the CRC
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
nfc_perror(pnd, "nfc_configure");
return false;
}
// Use raw send/receive methods
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
nfc_perror(pnd, "nfc_configure");
return false;
}
iso14443a_crc_append(abtHalt, 2);
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;
}
// reset reader
// Configure the CRC
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, true) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
return false;
}
// Switch off raw send/receive methods
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, true) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
return false;
}
return true;
}
full source code https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-mfclassic.c
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 30 (1 by maintainers)
@aalistarh I have solved the problem you can see my repositories mifarecloner there is a method called Unlock()
@aalistarh I have reviewed your code Be careful if the Unlock() function was called successfully there is no need to call authenticateBlock() to auth the block you can read or write immediately see the following code in my repositories
Awsome, I will try it. Thank you very much.