Code Monkey home page Code Monkey logo

Comments (10)

pokusew avatar pokusew commented on June 9, 2024 6

@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.

riseansmal avatar riseansmal commented on June 9, 2024 2

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.

pokusew avatar pokusew commented on June 9, 2024

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.

riseansmal avatar riseansmal commented on June 9, 2024

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.

pokusew avatar pokusew commented on June 9, 2024

@therealri And does it work when you restart the script (CTRL-C and run again)?

from nfc-pcsc.

pokusew avatar pokusew commented on June 9, 2024

@therealri I have got the idea, where the problem comes from. ❗️❗️❗️

from nfc-pcsc.

pokusew avatar pokusew commented on June 9, 2024

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.

vamsideepak avatar vamsideepak commented on June 9, 2024

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.

fabioloreggian avatar fabioloreggian commented on June 9, 2024

@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.

pokusew avatar pokusew commented on June 9, 2024

Hi @fabioloreggian, what troubles do you have? I am happy to help. 🙂

from nfc-pcsc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.