nfc-tools / mfoc-hardnested

A fork of mfoc integrating hardnested code from the proxmark
GNU General Public License v2.0
190 stars 32 forks source link

mfoc-hardnested-dump fails when rewriting back to card #15

Open ld21 opened 2 years ago

ld21 commented 2 years ago

Hi everyone

I successfully extracted the contents of a MIFARE classic card using mfoc-hardnested using mfoc-hardnested -f keys.txt -O extractedcard.mfd over an USB Adafruit PN532 Breakout Board:

# ./mfoc-hardnested -f keys.txt -O extractedcard.mfd 
ATS len = -20
Found Mifare Classic 1k tag
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
* UID size: single
* bit frame anticollision supported
       UID (NFCID1): 6d  02  b6  62  
      SAK (SEL_RES): 08  
* Not compliant with ISO/IEC 14443-4
* Not compliant with ISO/IEC 18092

Fingerprinting based on MIFARE type Identification Procedure:
* MIFARE Classic 1K
* MIFARE Plus (4 Byte UID or 4 Byte RID) 2K, Security level 1
* SmartMX with MIFARE 1K emulation
Other possible matches based on ATQA & SAK values:

Try to authenticate to all sectors with default keys...
...
...

However, when trying to write the dump back to the card using nfc-mfclassic w a extractedcard.mfd extractedcard.mfd, the process fails with

root@nfc:/home/to# LIBNFC_LOG_LEVEL=3 nfc-mfclassic w a extractedcard.mfd extractedcard.mfd
NFC reader: Adafruit PN532 Breakout opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
       UID (NFCID1): 6d  02  b6  62  
      SAK (SEL_RES): 08  
RATS support: no
Guessing size: seems to be a 1024-byte card
Writing 63 blocks |Failure to write to data block 1
xroot@nfc:/home/to# 

and the card remains unaltered. I'm using a fresh Kali linux and an uptodate libnfc (1.8.0).

Am I correct using nfc-mfclassic to write the dump back or should I use another program (since it identifies as a MIFARE Plus)?

Does anyone have an idea what the problem might be? Thanks!

caps6 commented 1 year ago

I had the same issue. I am using a 320 byte card and authentication failed for blocks 4, 8, 12 and 16. This problem came out after I have upgraded from Ubuntu 20.04 to 22.04 LTS and using the latest version of mfoc-hardnested. Removing libnfc-bin 1.8.0 and installing from source libnfc-bin 1.7.1 did the trick for me.

ld21 commented 1 year ago

I tried it with libnfc 1.7.1 – but that didn't solve the issue. Any other ideas?

gelotus commented 1 year ago

Compile and use the last trunk version, the last release version is seriously broken

Il dom 16 lug 2023, 12:48 Daniel @.***> ha scritto:

I tried it with libnfc 1.7.1 – but that didn't solve the issue. Any other ideas?

— Reply to this email directly, view it on GitHub https://github.com/nfc-tools/mfoc-hardnested/issues/15#issuecomment-1637050836, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPVKHDA4D4KXVDQ2KGDB3LXQPBGXANCNFSM54ZVO2YA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ld21 commented 1 year ago

I have recompiled libnfc 1.7.1 using Ludo1598's post https://github.com/nfc-tools/libnfc/issues/684#issuecomment-1634573967. Gelotus, I don't unterstand what you suggest: do you mean I should compile from the latest version of libnfc as in https://github.com/nfc-tools/libnfc? Thanks!

gelotus commented 1 year ago

1.8.0 release version have a broken nfc-mfclassic utility, so you have to use the trunk version (master, current, the version that is actually on github) compile and install

Il dom 16 lug 2023, 13:03 Daniel @.***> ha scritto:

I have recompiled libnfc 1.7.1 using Ludo1598's post https://github.com/nfc-tools/libnfc/issues/684#issuecomment-1634573967 http://url. Gelotus, I don't unterstand what you suggest: do you mean I should compile from the latest version of libnfc as in https://github.com/nfc-tools/libnfc http://url? Thanks!

— Reply to this email directly, view it on GitHub https://github.com/nfc-tools/mfoc-hardnested/issues/15#issuecomment-1637053672, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPVKHC54UVQJ2G76NZQDXTXQPDA3ANCNFSM54ZVO2YA . You are receiving this because you commented.Message ID: @.***>