Proxmark3 developers community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

#1 2018-02-05 21:18:17

Aleandro23
Contributor
Registered: 2018-02-05
Posts: 4

Problems reading and writing MIFARE cards with pc

I would read and write a mifare card with card reader ACR122U. I have all the keys, but nfc-mfclassic can't read keys file, why? Thank you all.

root@DESKTOP-VUM18JR:~# mfoc -f keys.txt -O keys.mfd
The custom key 0xA4CF1E372438 has been added to the default keys
The custom key 0x06A88D253FF2 has been added to the default keys
The custom key 0x4FAF05BD81D4 has been added to the default keys
The custom key 0x9CA7F33DE94D has been added to the default keys
The custom key 0xB4C132439EEF has been added to the default keys
The custom key 0xB53E298E9C33 has been added to the default keys
The custom key 0x37F534237653 has been added to the default keys
The custom key 0xEE5FBEAB12BC has been added to the default keys
The custom key 0xF4018AFA69EF has been added to the default keys
Found Mifare Classic Mini tag
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
* UID size: single
* bit frame anticollision supported
       UID (NFCID1): ad  dd  44  12  
      SAK (SEL_RES): 09  
* Not compliant with ISO/IEC 14443-4
* Not compliant with ISO/IEC 18092

Fingerprinting based on MIFARE type Identification Procedure:
* MIFARE Mini 0.3K
* SmartMX with MIFARE 1K emulation
Other possible matches based on ATQA & SAK values:

Try to authenticate to all sectors with default keys...
Symbols: '.' no key found, '/' A key found, '\' B key found, 'x' both keys found
[Key: a4cf1e372438] -> [./...]
[Key: 06a88d253ff2] -> [.//..]
[Key: 4faf05bd81d4] -> [.///.]
[Key: 9ca7f33de94d] -> [.////]
[Key: b4c132439eef] -> [\////]
[Key: b53e298e9c33] -> [\x///]
[Key: 37f534237653] -> [\xx//]
[Key: ee5fbeab12bc] -> [\xxx/]
[Key: f4018afa69ef] -> [\xxxx]
[Key: ffffffffffff] -> [\xxxx]
[Key: a0a1a2a3a4a5] -> [xxxxx]
[Key: d3f7d3f7d3f7] -> [xxxxx]
[Key: 000000000000] -> [xxxxx]
[Key: b0b1b2b3b4b5] -> [xxxxx]
[Key: 4d3a99c351dd] -> [xxxxx]
[Key: 1a982c7e459a] -> [xxxxx]
[Key: aabbccddeeff] -> [xxxxx]
[Key: 714c5c886e97] -> [xxxxx]
[Key: 587ee5f9350f] -> [xxxxx]
[Key: a0478cc39091] -> [xxxxx]
[Key: 533cb6c723f6] -> [xxxxx]
[Key: 8fd0a4f256e9] -> [xxxxx]

Sector 00 -  FOUND_KEY   [A]  Sector 00 -  FOUND_KEY   [B]  
Sector 01 -  FOUND_KEY   [A]  Sector 01 -  FOUND_KEY   [B]  
Sector 02 -  FOUND_KEY   [A]  Sector 02 -  FOUND_KEY   [B]  
Sector 03 -  FOUND_KEY   [A]  Sector 03 -  FOUND_KEY   [B]  
Sector 04 -  FOUND_KEY   [A]  Sector 04 -  FOUND_KEY   [B]  

We have all sectors encrypted with the default keys..

Auth with all sectors succeeded, dumping keys to a file!
Block 19, type A, key 9ca7f33de94d :00  00  00  00  00  00  78  77  88  00  00  00  00  00  00  00  
Block 18, type A, key 9ca7f33de94d :55  01  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 17, type A, key 9ca7f33de94d :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  01  
Block 16, type A, key 9ca7f33de94d :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 15, type A, key 4faf05bd81d4 :00  00  00  00  00  00  78  77  88  00  00  00  00  00  00  00  
Block 14, type A, key 4faf05bd81d4 :55  01  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 13, type A, key 4faf05bd81d4 :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  01  
Block 12, type A, key 4faf05bd81d4 :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 11, type A, key 06a88d253ff2 :00  00  00  00  00  00  78  77  88  11  00  00  00  00  00  00  
Block 10, type A, key 06a88d253ff2 :55  03  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 09, type A, key 06a88d253ff2 :00  14  00  14  00  00  00  00  00  00  00  00  00  00  00  03  
Block 08, type A, key 06a88d253ff2 :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  02  
Block 07, type A, key a4cf1e372438 :00  00  00  00  00  00  78  77  88  15  00  00  00  00  00  00  
Block 06, type A, key a4cf1e372438 :aa  02  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 05, type A, key a4cf1e372438 :01  00  00  01  00  00  80  01  00  01  00  00  00  00  80  01  
Block 04, type A, key a4cf1e372438 :01  00  00  6d  17  00  80  5d  4b  01  00  00  00  00  ec  02  
Block 03, type A, key a0a1a2a3a4a5 :00  00  00  00  00  00  78  77  88  c1  00  00  00  00  00  00  
Block 02, type A, key a0a1a2a3a4a5 :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  
Block 01, type A, key a0a1a2a3a4a5 :62  00  48  88  49  88  4a  88  4b  88  00  00  00  00  00  00  
Block 00, type A, key a0a1a2a3a4a5 :ad  dd  44  12  26  89  04  00  c8  34  00  20  00  00  00  16  



root@DESKTOP-VUM18JR:~# hexdump -vC keys.mfd
00000000  ad dd 44 12 26 89 04 00  c8 34 00 20 00 00 00 16  |..D.&....4. ....|
00000010  62 00 48 88 49 88 4a 88  4b 88 00 00 00 00 00 00  |b.H.I.J.K.......|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  a0 a1 a2 a3 a4 a5 78 77  88 c1 b4 c1 32 43 9e ef  |......xw....2C..|
00000040  01 00 00 6d 17 00 80 5d  4b 01 00 00 00 00 ec 02  |...m...]K.......|
00000050  01 00 00 01 00 00 80 01  00 01 00 00 00 00 80 01  |................|
00000060  aa 02 00 00                                       |....|
00000064



root@DESKTOP-VUM18JR:~# nfc-mfclassic r a mizip.mfd keys.mfd
NFC reader: ACS / ACR122U PICC Interface opened
Found MIFARE Classic card:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
       UID (NFCID1): ad  dd  44  12  
      SAK (SEL_RES): 09  
Guessing size: seems to be a 320-byte card
Could not read keys file: keys.mfd
root@DESKTOP-VUM18JR:~# 

Last edited by Aleandro23 (2018-02-05 21:18:37)

Offline

#2 2018-02-07 18:57:06

YoungJules
Contributor
Registered: 2012-01-29
Posts: 59

Re: Problems reading and writing MIFARE cards with pc

Little bit off-topic, you're probably better off asking in the libnfc forum... but... I see in nfc-mfclassic that there is a check on the number of bytes it reads... and gives the same message as it does if the file just doesn't exist... so I suspect if the file is there, and is readable, there's probably something wrong with the format or how many bytes are in your file or... something...

00665     if (fread(&mtKeys, 1, (uiBlocks + 1) * sizeof(mifare_classic_block), pfKeys) != (uiBlocks + 1) * sizeof(mifare_classic_block)) {
00666       printf("Could not read keys file: %s\n", argv[4]);

What does

ls -l keys.mfd

return?

Offline

#3 2018-02-07 23:20:14

Aleandro23
Contributor
Registered: 2018-02-05
Posts: 4

Re: Problems reading and writing MIFARE cards with pc

YoungJules wrote:

Little bit off-topic, you're probably better off asking in the libnfc forum... but... I see in nfc-mfclassic that there is a check on the number of bytes it reads... and gives the same message as it does if the file just doesn't exist... so I suspect if the file is there, and is readable, there's probably something wrong with the format or how many bytes are in your file or... something...

00665     if (fread(&mtKeys, 1, (uiBlocks + 1) * sizeof(mifare_classic_block), pfKeys) != (uiBlocks + 1) * sizeof(mifare_classic_block)) {
00666       printf("Could not read keys file: %s\n", argv[4]);

What does

ls -l keys.mfd

return?

Sorry for off topic and thanks for the reply. In the first post I showed the content of keys.mfd with command hexdump. I have already keys, I inserted its in a file .txt, I ran mfoc and put output in keys.mfd.

root@DESKTOP-VUM18JR:~# ls -l keys.mfd
-rw-r--r-- 1 root root 100 Feb  5 11:00 keys.mfd

Offline

#4 2018-02-08 21:38:13

YoungJules
Contributor
Registered: 2012-01-29
Posts: 59

Re: Problems reading and writing MIFARE cards with pc

Looks to me like your keys.mfd is the 'wrong' size.

Normally I would expect the .mfd file to be 1024 bytes or 4096 bytes (for 1k or 4k Mifare) or even 320 bytes for a Mifare mini tag.

Looks like mfoc doesn't handle it properly and only writes 100 bytes to the .mfd file?

<wanders off muttering... sure I've got a Mifare mini tag somewhere...>

Offline

#5 2018-02-08 22:20:40

iceman
Administrator
Registered: 2013-04-25
Posts: 6,689
Website

Re: Problems reading and writing MIFARE cards with pc

moved topic,  but still for the record,  this is a dedicated proxmark forum.


If you feel the love,  https://www.patreon.com/iceman1001

modhex(hkhehghthbhudcfcdchkigiehgduiehg)

Offline

#6 2018-02-08 22:35:59

YoungJules
Contributor
Registered: 2012-01-29
Posts: 59

Re: Problems reading and writing MIFARE cards with pc

@iceman
Thanks, and noted! Hopefully this puts the issue to bed. smile

@Aleandro23
The following should write a correct .mfd file with just the keys... I'm writing to test_keys.mfd so just make sure you don't already have a file with that name that you want to keep! smile

#Blocks 0 to 3 (sector 0), UID addd4412 key a0a1a2a3a4a5
echo -e -n \\xad\\xdd\\x44\\x12\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 > test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 4 to 7 (sector 1), key a4cf1e372438
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\xa4\\xcf\\x1e\\x37\\x24\\x38\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 8 to 11 (sector 2), key 06a88d253ff2
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x06\\xa8\\x8d\\x25\\x3f\\xf2\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 12 to 15 (sector 3), key 4faf05bd81d4
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x4f\\xaf\\x05\\xbd\\x81\\xd4\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 16 to 19 (sector 4), key 9ca7f33de94d
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x9c\\xa7\\xf3\\x3d\\xe9\\x4d\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

Copy the code above, paste it into a text file (make_key.sh for example)...
Make the file executable...

chmod +x make_key.sh

Run it...

./make_key.sh

Then try the nfc_mfclassic command again with test_keys.mfd (use the read command as before but use the new mfd)

nfc-mfclassic r a mizip.mfd test_keys.mfd

If it still don't work... use a Proxmark tongue

Offline

#7 2018-02-09 17:35:18

Aleandro23
Contributor
Registered: 2018-02-05
Posts: 4

Re: Problems reading and writing MIFARE cards with pc

YoungJules wrote:

@iceman
Thanks, and noted! Hopefully this puts the issue to bed. smile

@Aleandro23
The following should write a correct .mfd file with just the keys... I'm writing to test_keys.mfd so just make sure you don't already have a file with that name that you want to keep! smile

#Blocks 0 to 3 (sector 0), UID addd4412 key a0a1a2a3a4a5
echo -e -n \\xad\\xdd\\x44\\x12\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 > test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 4 to 7 (sector 1), key a4cf1e372438
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\xa4\\xcf\\x1e\\x37\\x24\\x38\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 8 to 11 (sector 2), key 06a88d253ff2
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x06\\xa8\\x8d\\x25\\x3f\\xf2\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 12 to 15 (sector 3), key 4faf05bd81d4
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x4f\\xaf\\x05\\xbd\\x81\\xd4\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

#Blocks 16 to 19 (sector 4), key 9ca7f33de94d
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd
echo -e -n \\x9c\\xa7\\xf3\\x3d\\xe9\\x4d\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 >> test_keys.mfd

Copy the code above, paste it into a text file (make_key.sh for example)...
Make the file executable...

chmod +x make_key.sh

Run it...

./make_key.sh

Then try the nfc_mfclassic command again with test_keys.mfd (use the read command as before but use the new mfd)

nfc-mfclassic r a mizip.mfd test_keys.mfd

If it still don't work... use a Proxmark tongue

Thank you very much! You solved my problem smile

Offline

Board footer

Powered by FluxBB