Re: Help: Mifare 1k Beginners Programming Guide27. You will find in the net a lot of examples of how to communicate with a smart card product. The library of SDK you use depends from the operating system, the programming language and the smart card product you want to use. You must be logged in to reply to this topic. Re: Cracking Mifare Classic 1K The 14a list functionality was changed by piwi when more accurate timing was introduced (Maybe somewhere around r845. The data above looks like you are using a 'modern' client software but an old osimage without piwis changes.
I am developing an application for reading and writing data from mifare tags. I bought a device which can read and write mifare tag operations with NFC tech.NFC ShieldI have been using a mifare ultralight tag but I encounter a problem when trying to authenticate a specific memory address. For this reason I can't start reading. Here is my Arduino code:
This reading code was made for Arduino Mega 2560 and seedstudio NFC Shield v1.0 and mifare ultralight tags. Same problem encountered during the writing op too.
How can I solve this problem ?
Erçin AkçayErçin Akçay85533 gold badges1212 silver badges2929 bronze badges
4 Answers
I had the same issue and edited the Mifare Classic example to read out Mifare Ultralight cards instead. Here's my code: https://gist.github.com/SamDecrock/bd1ec55f083a71ecee95
Output should be something like this:
As you can see, page 0 and page 1 contain the UID ;-)
SamSam2,63311 gold badge1919 silver badges3030 bronze badges
MIFARE Ultralight is not the same as MIFARE Classic 1K. MIFARE Ultralight does not support (or need) authentication. You can just start reading without using authentication.
NFC guy9,66722 gold badges2121 silver badges5555 bronze badges
With PN532 library and NDEF library, you can read/write mifare classic tags and read mifare ultralight tags.
Yihui XiongYihui Xiong
In wikipedia you can read
'The MIFARE Ultralight has only 512 bits of memory (i.e. 64 bytes), without cryptographic security. The memory is provided in 16 pages of 4 bytes.'
So I think at least you must change the code removing the authenticateBlock and start reading blocks of 4 bytes long.
There is a document at adafruit.com where they explain how Mifare Classic and Mifare Ultralight work. There are some tips about the meaning of the bytes you read from Mifare Ultralight.
In the document they say about Mifare Ultralight:
Accessing Data Blocks
In order to access the cards, you must following two steps: 'Connect' to a Mifare Ultralight card and retrieve the 7 byte UID of the card. Memory can be read and written directly once a passive mode connection has been made. No authentication is required for Mifare Ultralight cards.
Read/Write Lengths
For compatability reasons, 'Read' requests to a Mifare Ultralight card will retrieve 16 bytes (4 pages) at a time (which corresponds to block size of a Mifare Classic card). For example, if you specify that you want to read page 3, in reality pages 3, 4, 5 and 6 will be read and returned, and you can simply discard the last 12 bytes if they aren't needed. If you select a higher page, the 16 byte read will wrap over to page 0. For example, reading page 14 will actually return page 14, 15, 0 and 1.
'Write' requests occur in pages (4 bytes), so there is no problem with overwriting data on subsequent pages.
UPDATE!!
I have found adafruit have two NFC libraries for adruino (one using I2C and the other SPI) and both implement one method named:
Libraries are here: learn.adafruit.com/adafruit-pn532-rfid-nfc/arduino-library
I hope they are compatible with your shield.
clubifaximaticclubifaximatic
Not the answer you're looking for? Browse other questions tagged arduinonfcmifare or ask your own question.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave 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
Comments
commented Aug 5, 2016
Hi! I've seen it in your TODO list. Could you add this feature? May be start just with checkbox in settings, that allows trying to read sectors up to 32? |
commented Aug 7, 2016
Hi @bildin, Thanks for reminding me of my TODO list :) I'm really not that active on this project lately... Just for the context: You want to read a Mifare Plus tag, right? Because I don't know any Mifare Classic tag that has 2k memory. Mifare Plus configured in Security Level 1 (SL1) should be fully compatible to Mifare Classic, if I'm not mistaken. Cheers! PS: Is Android detecting your tag as 1k Mifare Classic, although it's a 2k Mifare Pluss? |
commented Aug 8, 2016 • edited
edited
Yes, I am talking about Mifare Plus in SL1 mode. In Android there is no difference between 1K and 2K card detecting. Relying to AN10833 (MIFARE Type Identification Procedure) document there are no correlated flags to exclusively determine 2K cards: Just only if SAK equals 0x10 (Mifare Plus SL2), but this case is parsed by Android well. However, android sources tell: At the same time NFC TagInfo by NXP determines 2K cards. Using my TagDiag I see some extra commands before reading the tag: Then starts usual iteration over sectors with known keys. If tag is Mifare Plus iteration continues up to block 0x7C (sector 31), otherwise (in case of 1K card) - up to block 0x3C (sector 15). Cheers! UPD: So, looking for Mifare Plus discussions E080 is RATS command and response is ATS (found here): С2 is DESELECT command If you need, I can send a card sample via mail. |
commented Aug 16, 2016
Hi @bildin! Sorry for not answering earlier and thank you for all the information. I will try to implement the 'fixed sector count' feature as soon as possible. However this will not be that soon... For the next two weeks I will be on vacation. About that card... I really don't have any Mifare Plus tag for testing. Could you write me a email? You will find a address in the git commit log or on the Google Play page of MCT. Another off-topic question: Do you know your way around BCC? On 4 byte UID tags, it is the 5th byte of the very first block. But do you know if there is some thing like this for 7 or 10 byte UID tags? (Execpt for the communication. The BCC will always be part of the UID read process.) Maybe you could have a look at this thread. |
commented Oct 4, 2016 • edited
edited
MIFARE Classic 2k support has been merged into the master. It will be part of the next release. |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment