-
Notifications
You must be signed in to change notification settings - Fork 132
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
Mifare Classic 1K: Authentication Error after Multiple Writes #16
Comments
Hi @therealri, Just to clarify: Thanks for your answer. |
Hey @pokusew, So it works just the first time but thereafter the card becomes unusable. So yes, it allows me to write data just once using the Exact Script in the Gist and thereafter it's not possible use the card again. Thanks! |
@therealri And does it work when you restart the script (CTRL-C and run again)? |
@therealri I have got the idea, where the problem comes from. ❗️❗️❗️ |
@therealri I think that the problem is here: I am looking into the technical documentation of Mifare Classic 1K. Section 8.6 is about Memory organization.
When accessing these blocks with this library, blocks are numbered as follows:
That's important, it's that the last block in each sector is "sector trailer" (see Section 8.6.3), which contains access conditions for the other 3 data blocks. So block 7, which you are trying to write to in your code, is not for data. After you write to it, it changes access conditions (including key) and you cannot authenticate your card then. I don't have any Mifare Classic card to test it, but according to documentation it is quite clear. Could you please update your code (remove interaction with block 7, see updated gist here) and test it with a NEW BLANK card if it works? Hope it helps and looking forward to your answer. PS Don't forget to star ⭐️ my library, if you find it useful. 😃 Thanks. |
Hi @therealri, I have just noticed another problem in you gist, on line 100, 104, 108, 112 you forgot to add the third, blockSize, argument 16 (4, 16, 16). It probably causes unneeded read operations. Just to be sure, you probably do know it, 16bit integer takes just 2 bytes, not 16 bytes (1 bytes = 8 bits). So before writing only 2-byte 16-bit integer into 16-byte unsafely-allocated Buffer, add I fixed all these things in my fork here. Take a look! Also let me know, if everything works for you as expected, and I will close the issue then. Thanks. Hope it helps. PS Don't forget to star ⭐️ my library, if you find it useful. 😃 Thanks. |
Hey @pokusew, Thanks so much and sorry for not getting back to you sooner, I have been travelling. I also needed to get some extra Mifare Classic 1K Stock. I have read through your comments and see where I went wrong on the configuration. I appreciate the updated code and all your help and time! I have tested and it works perfectly, I have a clear understanding of the Mifare Classic 1K Data Layout now :) Thanks so much! |
it is not working with angular 6 and it throwing error while importing like "nfc is not a constructor". reason i found fs module will not work with angular 6. by inbuilt nfc containing fs . because of these reason i accessed nfc from html and i declared in angular 6 component like "declare var NFC: any; " |
@therealri I have been having troubles trying to read some data from my Mifare Class 1k card. Do you think you could spare some time and help out? |
Hi @fabioloreggian, what troubles do you have? I am happy to help. 🙂 |
Hi @pokusew,
Something weird is happening when attempting multiple writes. I have the following simple script that (1) Authenticates Blocks 4-7, Reads Blocks 4-7 and then Writes to Blocks 4-7.
It seems that the cards become unusable after attempting multiple write operations as they refuse to Authenticate. I have also tried this using promises.
I really like this package due to its quality, straightforward installation across platforms and Electron support.
Any suggestions or advice from your side?
https://gist.github.com/therealri/96adfa625d8bb3b2929a956ec1919cda
The text was updated successfully, but these errors were encountered: