Comments (10)
@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.
... memory is organized in 16 sectors of 4 blocks. One block
contains 16 bytes.
When accessing these blocks with this library, blocks are numbered as follows:
- sector 0:
- block 0 – manufacturer data (read only)
- block 1 – data block
- block 2 – data block
- block 3 – sector trailer
- sector 1:
- block 4 – data block
- block 5 – data block
- block 6 – data block
- block 7 – sector trailer
- sector 2:
- block 8 – data block
- block 9 – data block
- block 10 – data block
- block 11 – sector trailer
- and so on
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.
from nfc-pcsc.
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!
from nfc-pcsc.
Hi @therealri,
Just to clarify:
Does the script fail always (so you cannot write any data) or does it work just for the first time (meaning that it allows you to write data just once)?
Thanks for your answer.
from nfc-pcsc.
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!
from nfc-pcsc.
@therealri And does it work when you restart the script (CTRL-C and run again)?
from nfc-pcsc.
@therealri I have got the idea, where the problem comes from. ❗️❗️❗️
from nfc-pcsc.
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 data.fill(0)
, more info here.
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.
from nfc-pcsc.
it is not working with angular 6 and it throwing error while importing like "nfc is not a constructor".
import {NFC} from 'nfc-pcsc' throwing error
ERROR in ./node_modules/bindings/bindings.js
Module not found: Error: Can't resolve 'fs' in 'C:\Users\Admin\Desktop\electronapp\node_modules\bindings'
ERROR in ./node_modules/bindings/bindings.js
Module not found: Error: Can't resolve 'path' in 'C:\Users\Admin\Desktop\electronapp\node_modules\bindings'
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; "
because of above i am getting nfc is not a constructor
from nfc-pcsc.
@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?
from nfc-pcsc.
Hi @fabioloreggian, what troubles do you have? I am happy to help. 🙂
from nfc-pcsc.
Related Issues (20)
- Mifare DESfire EV2 2k - error in step 2 - authenticate HOT 1
- Constructing APDU command on NTAG21x
- Error when writing data. Receives an Invalid data length error. HOT 3
- Authentication failed for same blocks BUT is Working in others HOT 1
- P2P Feature
- Empty Data
- Multi RFID Reader
- was compiled against a different Node.js version using NODE_MODULE_VERSION 111. This version of Node.js requires NODE_MODULE_VERSION 110. HOT 3
- UnhandledPromiseRejectionWarning: WriteError: Write operation failed: Status code: 0x6300 HOT 3
- I don't understand that code HOT 1
- Module not found: Error: Can't resolve 'fs' HOT 2
- Unable to run the basic example HOT 2
- Add disposition parameter in disconnect method
- MacOS installation issue using npm HOT 2
- Cannot access "events.EventEmitter" in client code HOT 4
- Context Aware Native Module, Electron Context Isolation and Node Integration Support
- Unsupported engine Please Help
- Emulate Tag NFC?
- Sveltekit build fails when running 'npm run build' but works on 'npm run dev' HOT 1
- It turned out to connect the library in CRA(React)? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nfc-pcsc.