Closed mandrean closed 5 years ago
Hi, you are probably correct about writing to sector 0 on mifare classic, probably this is safety feature so you don't write to sector 0 by accident, could you tell me more about this special card with writeable sector 0 ?
For example:
or
Also note that nfc-tools's nfc-mfclassic
tool supports these cards:
http://manpages.ubuntu.com/manpages/bionic/man1/nfc-mfclassic.1.html
The W option allows writing of special MIFARE cards that can be 'unlocked' to allow block 0 to be overwritten. This includes UID and manufacturer data. Take care when amending UIDs to set the correct BCC (UID checksum). Currently only 4 byte UIDs are supported.
*** Note that W and R options only work on special versions of MIFARE 1K cards (Chinese clones).
I reviewed library source code and I found that you could posiblly write to sector 0.
https://github.com/nfc-tools/libfreefare/blob/master/libfreefare/mifare_classic.c#L712:
https://github.com/nfc-tools/libfreefare/blob/master/libfreefare/mifare_classic.c#L585
But to be for sure, I suggest you try this with blank card and report result here, so we can solve this.
Yep, I found those two LoC when I was peeking around as well... They seem discouraging, but I will try it out!
The idea of this library is to make it easier to manipulate cards by providing high-level API. Therefore, it implements what cards are supposed to do, and although these Chinese cards have some "extensions", they are not coping with the specifications of the original cards.
So libfreefare will ensure that your code with work reliably and consistently with all cards, with and without these "extensions". If you need to rely on these extensions, I guess the simplest would be to fork the library and remove these special checks.
If you want this to be in libfreefare itself, I guess we can make this optional (add a configure flag to disable the extra checks), but please leave this disabled by default :smiley:
I'll close this for now since usually, people who want to write sector 0 are not writing some "real world application" but are rather doing a proof of concept, and this is not the purpose of libfreefare. If you really want to make this feature available as a configure option, feel free to open a Pull Request.
Thanks!
It seems like
libfreefare
assumes sector 0 is always read-only: https://github.com/nfc-tools/libfreefare/blob/master/libfreefare/mifare_classic.c#L712https://github.com/nfc-tools/libfreefare/blob/master/libfreefare/mifare_classic.c#L585
But there is also a special type of card with a writeable sector 0.
Does this mean
libfreefare
can't be used with those cards for writing to sector 0?