Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 views
in Technique[技术] by (71.8m points)

permissions - Can I recover a MIFARE Classic card?

My problem is that I used the "read and write" example on the Arduino to re-write an RFID card (MIFARE Classic 1K) block by block. I started writing at block 4. At block 7 it stopped and now I can't read any sector. I wrote zeros to each block.

The DumpToSerial function just prints for every sector

PCD_Authenticate() failed: Timeout in communication.

It can still read the UID, the SAK, and the PICC type.

Did I destroy the card or can I recover it?

Some more info:

  • Card: MIFARE Classic 1K
  • Arduino Mega2560 from Elegoo
  • RC522 from the starter-kit
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With MIFARE Classic 1K, every 4th block is the sector trailer (each 4 blocks are grouped into one sector). The sector trailer contains the access keys (key A on bytes 0..5, key B on bytes 10..15) and access conditions (access bits on bytes 6..8) for a sector.

The access conditions are protected by a redundancy mechanism where each access bit is present multiple times in positive and negative logic. A MIFARE Classic card allows overwriting these access conditions with invalid values (impossible combinations of access bits). However, once the access conditions are set to such an invalid value, the security logic of the chip will disable all access to the wole sector. Consequently, writing invalid access conditions to the sector trailer renders the whole sector unusable. This state is permanent and cannot be reverted.

You wrote all blocks starting at block 4 with all-zeros. Consequently, you wrote the sector trailer of sector 1 (in block 7) with the access conditions set to all-zeros. This is an invalid value for the access conditions. Therefore, sector 1 is permanently unusable. Since you indicated that you immediately received errors after writing block 7, you might be lucky and did not overwrite other sector trailers (e.g. block 11 for sector 2). In that case, those other sectors should still be usable. Similarly, since you started writing at block 4, the first sector (sector 0, blocks 0..3) should also still be accessible.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...