8000 Payload limited to 38 characters on Mifare Classic 1k · Issue #241 · ZaparooProject/zaparoo-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Payload limited to 38 characters on Mifare Classic 1k #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
geocybrid opened this issue May 15, 2025 · 5 comments
Closed

Payload limited to 38 characters on Mifare Classic 1k #241

geocybrid opened this issue May 15, 2025 · 5 comments

Comments

@geocybrid
Copy link

Thanks for the great tool!

I encountered this weird problem: bunch of no-name Mifare Classic 1k cards from many different sources seem to be limited to only 38 characters of payload both for reading as well as writing. This happens with df52fad-dev (mister) web UI as well as android app.

I get an error when trying to write/read these cards either with the ACR122U or the android phone (relatively modern Samsung with up to date OS).

error reads something like "maximum size of the nfc tag exceeded", even when there is less than 50 characters to write.

When reading, the "value" of the card is not shown if the payload exceeds 38 characters (tested with NFC tools for desktop, which can reliably read and write longer texts on the same cards).

Note that from the factory the cards were not usable with zaparoo at all (could not be written or formatted). I had to prepare the cards with the following commands:

mifare-classic-format -y
mifare-classic-write-ndef -y

After that the card is usable but with the above limitation. Note that if I follow the recommendation to just add any text field using NFC tools for desktop before using mifare classic 1k with zaparoo, these cards are still not writable - app says they are not ndef formatted. After the above two commands the card is usable without writing a text field manually.

Also note that after a failure to write from the core (i.e. trying to write big text or unformatted card) some thread likely crashes in the server and it is no longer usable until reboot. This could be considered a separate bug, but that one is much less disruptive of course.

Thank you and let me know if any more information is needed.
(attaching screenshot of the NFC Tool with some card details)

Image
Image

@geocybrid
Copy link
Author

Quick update - just running mifare-classic-write-ndef -y is enough to make card usable with zaparoo, however with the same limitation of 38 character payload. The format command is not necessary.

@geocybrid
Copy link
Author

Another update - Tagwriter on android refuses to write messages longer than 44 bytes and says capacity of the card is 46 bytes. On all cards. Formatting doesn't help. It also says the cards are 1k, not sure how this both can be true :)

I suspect the cards are somehow formatted wrong, but not sure what else could I try. Any ideas welcome :)

@wizzomafizzo
Copy link
Member

Hi. I can only really think that these particular cards may actually only have a tiny capacity or have some sort of defect. You are definitely doing everything correctly

The reason I say that is because the NFC backend used by the phone app is totally managed by Android itself, it's not like on the Core version where we use custom libraries, so it's unlikely there's an issue with the app or phone itself on the Android version. If you've got your heart set on using Mifare classic cards, maybe you find some to test from a more reputable place?

The crash you experienced could be fixed, I've got an open issue atm where a comma written to a Mifare car has reported as crashing Core which sounds similar. If you've can reproduce it with a certain card please let me know what was written on it

@geocybrid
Copy link
Author

The adventure had a happy ending after some tinkering :) Posting here with the hope that other folks can benefit:

sudo apt install libnfc-bin libfreefare-bin libnfc-dev libfreefare-dev
pip install ndeftool
yes 0123456789 | tr -d '\n' | head -c 700 > large.txt
ndeftool text "$(cat large.txt)" save large.ndef
mifare-classic-write-ndef -y -i large.ndef

Some explanation:

  • The problem seemed to be with the initial text written by mifare-classic-write-ndef. If you just use it without parameters, it writes some dummy short text and only allocates enough space to roughly fit that text. So the trick is to write large text - in this case 700 bytes.
  • We need both libnfc and friends, as well as ndeftool (which is in python). The latter is used to generate the payload for the former to write to the card.
  • Payload is just a text with 700 bytes of 0..9 repeating (I picked it so that I could see in the byte dump where the data went, specific content doesn't not matter of course now).
  • After you write this big thing, the app as well as core itself are happy to write longer strings no problem (up to 700 bytes of course).
  • If you have tons of cards and want to make batch writing a bit less of a pain, run something like this :)
while true; do read -n1 -s && mifare-classic-write-ndef -y -i large.ndef; echo "done"; done

Regarding the crash: it happens to the core, every single time I try to write string longer than the allocated space on these cards (i.e. noname mifare classic 1k card "formatted" with mifare-classic-write-ndef -y out of the box, i.e. zero it completely to wipe NDEF and then do just this command).
On mobile - it doesn't crash, however it does crash in apparently the same way when trying to format the card from the app. Then you have to close the app and re-open it for it to even read any card.

I think we can close this issue at this point and thanks for your response Callan. And for the awesome app to the author of course!

@wizzomafizzo
Copy link
Member

I'm glad you got it working in the end!

Thank you so much for thoroughly documenting everything you did. I hope I can incorporate it back into Core so there's no need for all these extra tools. I don't use the Mifare cards myself so that support hasn't gotten much love

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0