michnovka
michnovka

Reputation: 3389

Is there a way to write just specific sector of Mifare Classic using libnfc?

So I have successfully extracted Mifare Classic 1k keys using mfoc:

mfoc -O dump.mdf

now I duplicate the file into dump-new.mdf and I modify this with corresponding values. I only intend to edit sector 02, so I do my changes, save file and proceed with upload to card using

nfc-mfclassic w b dump-new.mdf dump.mdf f

As I understand, this looks up every 4th block in dump.mdf, extracts key B (the b after w in command), and uses this key to write dump-new.mdf contents into corresponding sectors/blocks on the card.

Now it happened to me that I blocked sector 00 by writing probably a damaged version of the file onto the card (access bits were not set properly as mentioned here), so in order to prevent this in future,

  1. Id like to write only to specific sectors. How to do that?

  2. If not possible, what happens if some of the sectors do not have write enabled for B but just for key A. by putting arg b into nfc-mfclassic call this will result in error. How should I upload an image of the card back to the card? Using key A, key B or both in some specific order?

Thanks guys

Upvotes: 3

Views: 4484

Answers (2)

Xavave
Xavave

Reputation: 695

A few years later… I’ve just implemented the option to write on specific sectors with nfc-mfclassic. I’ve also added possibility to force ACL. It’s here: https://github.com/xavave/libnfc_with_extra_tools And you can find this nfc-mfclassic compiled for windows-x64 on my github repo : https://github.com/xavave/Mifare-Windows-Tool

Upvotes: 0

michnovka
michnovka

Reputation: 3389

After few days of researching and working with libnfc, the answer is no, it is not possible. Always use the dump of the card and edit it with desired values, then save and upload to card using nfc-mfclassic

Upvotes: 2

Related Questions