Skip to content
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

Unlock read/write magic card fallback #322

Merged
merged 5 commits into from
Nov 4, 2015
Merged

Unlock read/write magic card fallback #322

merged 5 commits into from
Nov 4, 2015

Conversation

quantum-x
Copy link
Contributor

Current Situation

  • nfc-mfclassic knows two types of magic cards: direct-write, or 'full magic' cards.
  • 'Full magic' cards can use the R/W flags [fully unlocked read / writes]
  • 'Direct Write' cards are designated by the 'magic2' flag, and must use the w/r flags.
    If a 'Direct Write' card is used with a R/W flag, an error is thrown, and the program halts

Proposed Situation

  • If a 'Direct Write' card is used with a R/W flag, a warning is shown, and the program gracefully degrades to 'standard' operation for Direct Write cards.
    This seems to be a more logical behavior, allowing a user to place their 'magic' card (of any type) - using the 'R/W' flags, and getting a known result - useful in automated situations.

This code has been tested with both types of magic cards, and works perfectly.
Thank you for your consideration.

Direct Write card, with R flag given (New behavior)

sudo ./nfc-mfclassic R a /tmp/testdump1.dmp
NFC reader: pn532_uart:/dev/ttyAMA0 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  02
       UID (NFCID1): ec  6b  91  7f
      SAK (SEL_RES): 18
Guessing size: seems to be a 4096-byte card
Note: This card does not require an unlocked write (R)
Reading out 256 blocks |................................................................................................................................................................................................................................................................|
Done, 256 of 256 blocks read.
Writing data to file: /tmp/testdump1.dmp ...Done.

Direct Write card, with r flag given (Standard behavior)

sudo ./nfc-mfclassic r a /tmp/testdump1.dmp
NFC reader: pn532_uart:/dev/ttyAMA0 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  02
       UID (NFCID1): ec  6b  91  7f
      SAK (SEL_RES): 18
Guessing size: seems to be a 4096-byte card
Reading out 256 blocks |................................................................................................................................................................................................................................................................|
Done, 256 of 256 blocks read.
Writing data to file: /tmp/testdump1.dmp ...Done.

Direct Write card, with W flag given (New behavior)

sudo ./nfc-mfclassic W a /tmp/testdump1.dmp
NFC reader: pn532_uart:/dev/ttyAMA0 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  02
       UID (NFCID1): ec  6b  91  7f
      SAK (SEL_RES): 18
Guessing size: seems to be a 4096-byte card
Note: This card does not require an unlocked write (W)
Writing 256 blocks |................................................................................................................................................................................................................................................................|
Done, 256 of 256 blocks written.

Direct Write card, with w flag given (Standard behavior)

sudo ./nfc-mfclassic w a /tmp/testdump1.dmp
NFC reader: pn532_uart:/dev/ttyAMA0 opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  02
       UID (NFCID1): ec  6b  91  7f
      SAK (SEL_RES): 18
Guessing size: seems to be a 4096-byte card
Writing 256 blocks |................................................................................................................................................................................................................................................................|

Modifying behavior relating to magic cards.
If a user has a 'magic2' card (IE, direct-write, not a 'fully magic' card) - we'll warn them that they don't need to use the W / R modes, and then proceed with the unlock operation, instead of exiting.
Removing typo
Tweaking back the unlocked_read / write_block_zero after magic2 card discovered
neomilium added a commit that referenced this pull request Nov 4, 2015
Unlock read/write magic card fallback
@neomilium neomilium merged commit 2046fb9 into nfc-tools:master Nov 4, 2015
@neomilium
Copy link
Member

Thanks :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants