flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

NFC: Emulating of SAVED Mifare Classic not working

Open AlexMilender opened this issue 1 year ago • 15 comments

Describe the bug.

Emulation of Mifare Classic produces different results depending on if the Mifare Classic fob has been saved or not.

I am able to successfully read a Mifare Classic key fob using NFC read functionality. If I do NOT save the read, but instead emulate it directly after the read. The emulation works as expected and i am able to open my key fob lock

If I DO save the read and then try to emulate that saved read. The emulation does not work as expected and I am unable to open my key fob lock

Reproduction

Successful able to open keyfob lock

  1. NFC
  2. Read
  3. More
  4. Emulate

Unsuccessful in opening keyfob lock

  1. NFC
  2. Read
  3. More
  4. Save the read
  5. NFC
  6. Saved
  7. Naviatege to saved read from step 4
  8. Emulate

Target

Flipper Zero Release 0.80.1

Logs

No response

Anything else?

No response

AlexMilender avatar Apr 12 '23 03:04 AlexMilender

What brand is the lock? I'd like to see if this is a problem for all emulation, or against a specific lock.

bettse avatar Apr 12 '23 04:04 bettse

Going to research it now on 0.81.1-rc

doomwastaken avatar Apr 12 '23 06:04 doomwastaken

If you could provide additional details about lock and what card you are using, that would be helpful, tried Mifare Classic 1k and 4k and was not succesful so far

doomwastaken avatar Apr 12 '23 12:04 doomwastaken

Also, having the full card dump will help out a lot

Astrrra avatar Apr 12 '23 12:04 Astrrra

I’m experiencing the same issue as OP. The reader is a Schlage lock

Indigo94 avatar Apr 12 '23 18:04 Indigo94

I have the same issue as OP.

Here's the Schlage model: https://www.schlage.com/en/home/products/BE467GRWFFF.html?fbclid=IwAR29B_GfcXJUn_cKD3ezzMMTAhIU_PCkSxDqYFbRcEwzHy6_i11rw30EsHI

Panduhsaur avatar Apr 12 '23 18:04 Panduhsaur

Could you please try to reproduce the issue on previous release

gornekich avatar Apr 12 '23 20:04 gornekich

What brand is the lock? I'd like to see if this is a problem for all emulation, or against a specific lock. @doomwastaken

The lock brand is Schlage. The same one @Panduhsaur mentioned (https://www.schlage.com/en/home/products/BE467GRWFFF.html)

Key fob is a Schlage 9651t

AlexMilender avatar Apr 12 '23 23:04 AlexMilender

Could you please try to reproduce the issue on previous release

How can I do this? I attempted to download the .zip and the tar.gz file, but when I go on qFlipper (windows) -> install from file -> and select one or the other, the downgrade fails

Indigo94 avatar Apr 13 '23 00:04 Indigo94

Could you please try to reproduce the issue on the previous release

@gornekich That did it! I used fbt to build and flash version 0.79.1 and I am now able to save and then emulate the key fob with success

Additional note ill mention for debugging purposes:

  1. Before downgrading to version 0.79.1 I updated to 0.81.1 and saw the same issues as I did in 0.80.1
  2. I am not able fully to extract all the keys from the fob (on any version of firmware that I have used) but I am still able to open the lock regardless Keys Found: 30/32 Sectors Read: 16/16

AlexMilender avatar Apr 13 '23 00:04 AlexMilender

Update: After successfully saving and emulating the keyfob in version 0.79.1. I then updated the firmware to version 0.81.1 and could emulate the saved keyfob with success.

AlexMilender avatar Apr 13 '23 01:04 AlexMilender

As the previous user mentioned, downgrading to version 0.79.1 fixed the issue. For users that would like to do this, do the following:

  1. Clone the following repository using the following command: git clone --recursive --branch 0.79.1 https://github.com/flipperdevices/flipperzero-firmware.git
  2. Go into the new 'flipper-zero firmware' folder
  3. run the fbt command: ./fbt
  4. Connect your Flipper and run the following command: ./fbt flash_usb

Indigo94 avatar Apr 13 '23 01:04 Indigo94

Could you please us dump of a key with latest release and 0.79.1, we would like to compare files. You could mail them to [email protected].

If by chance any of you have proxmark, then let us know a way to contact you

doomwastaken avatar Apr 15 '23 13:04 doomwastaken

Here are some of my observations: I have two mfc cards, one for workplace (A) and one for public transport (B)

(A) is purely UID based, all sectors are filled with zeroes with FFFFFFFFFFFF as both keys and 000/000/000/001 access bits (B) has non-default keys and is using sectors 0-8. Moreover single block of sector 4 has read and write disabled by access bits (111)

Results of emulating card A with flipper:

  • did not work with door sensors at my workplace
  • it did work with storage locker (some kind of battery powered reader)
  • Mifare Classic tool throws "NFC read error"
  • ACR122U
    • nfc-list lists card properly
    • trying to read card with mfoc or nfc-mfclassic immediately says "no tag was found"

Results of emulating card B:

  • Mifare Classic tool detects card, show it's UID but i'm unable to read card (guess that's to be expected with the way emulation works)
  • ACR122U
    • nfc-list works
    • trying to read card with mfoc or nfc-mfclassic also didn't work, but this time nfc-mfclassic displayed card details before throwing "tag disappeared" error.

There are no notable differences between 0.79.1 and 0.81 dumps in my case. For both cards it's limited to header:

@@ -1,9 +1,10 @@
 Filetype: Flipper NFC device
 Version: 3
-# Nfc device type can be UID, Mifare Ultralight, Mifare Classic
+# Nfc device type can be UID, Mifare Ultralight, Mifare Classic, Bank card or ISO15693
 Device type: Mifare Classic
 # UID, ATQA and SAK are common for all formats
 UID: .. .. .. ..
+# ISO14443 specific fields
 ATQA: 00 04
 SAK: 08
 # Mifare Classic specific data

m-kozlowski avatar Apr 17 '23 16:04 m-kozlowski

Could you please us dump of a key with latest release and 0.79.1, we would like to compare files. You could mail them to [email protected].

If by chance any of you have proxmark, then let us know a way to contact you

A key dump of the 2 versions you mentioned have been emailed to the link you provided. Unfortunately I do not own a proxmark

AlexMilender avatar Apr 22 '23 17:04 AlexMilender

I can confirm this issue is still ongoing on most recent firmware. When reading an NFC fob and emulating from the initial read it will function.

As soon as you save that read, the emulation will no longer work. I have the same Schlage device as the one previously listed.

davenukem avatar May 20 '23 23:05 davenukem

I also have identical Schlage lock and fob type. Confirming that on the latest version installed (0.83.1), I am unable to emulate the NFC from a saved Mifare classic 1K. I have 30/32 keys found and 16/16 sectors read.

When I read the key fob, I am able to confirm that emulation DOES work. However after saving emulation no longer functions/detected by the reader.

meppss avatar May 23 '23 01:05 meppss

Currently this fix is blocked by NFC refactoring process. I will update this issue once refactor is done, cannot give any ETA.

doomwastaken avatar May 23 '23 15:05 doomwastaken

Currently this fix is blocked by NFC refactoring process. I will update this issue once refactor is done, cannot give any ETA.

I'm confirming that this is still broken in the latest release [0.84.1]. Attempted on a freshly updated flipper.

meppss avatar Jun 04 '23 03:06 meppss

I was just wondering about this issue. Glad it's being worked on.

warnerlowe avatar Jun 05 '23 00:06 warnerlowe

fixed in dev

skotopes avatar Jun 09 '23 12:06 skotopes

fixed in dev

Can you share the PR this was fixed in? Thanks!

meppss avatar Jun 09 '23 12:06 meppss

fixed in dev

Can you share the PR this was fixed in? Thanks!

https://github.com/flipperdevices/flipperzero-firmware/pull/2620

doomwastaken avatar Jun 09 '23 13:06 doomwastaken

fixed in dev

Just installed the .85 RC. Completely possible I'm doing something wrong but this seems to actually eliminate the ability of the Flipper to even emulate the MIFARE classic initially. In the current firmware, you can emulate your MIFARE classic NFC after an initial read but upon saving it will no longer function if you attempt to emulate.

On the RC firmware .85, even the initial emulation fails for me now.

Rolling back to the .84.2 firmware initial emulation once again functions, saved emulation fails.

Not sure if this ties into the NFC refactoring you mentioned - but the issue doesn't appear to be fixed in .85

davenukem avatar Jun 09 '23 16:06 davenukem

fixed in dev

Just installed the .85 RC. Completely possible I'm doing something wrong but this seems to actually eliminate the ability of the Flipper to even emulate the MIFARE classic initially. In the current firmware, you can emulate your MIFARE classic NFC after an initial read but upon saving it will no longer function if you attempt to emulate.

On the RC firmware .85, even the initial emulation fails for me now.

Rolling back to the .84.2 firmware initial emulation once again functions, saved emulation fails.

Not sure if this ties into the NFC refactoring you mentioned - but the issue doesn't appear to be fixed in .85

So you actually get all keys and sectors on the card, but emulation does not work? Did you go through detect reader step again?

doomwastaken avatar Jun 09 '23 16:06 doomwastaken

I read 16/16 sectors and get 30/32 keys (same as firmware .84.2). I ran through the entire card read process again and detected reader to get nonces again as well (on both firmwares). Ran through the same process on both firmwares.

Firmware .85 will not even succeed at initial emulation, .84.2 will. Neither will allow an emulated saved read to function.

davenukem avatar Jun 09 '23 17:06 davenukem

I read 16/16 sectors and get 30/32 keys (same as firmware .84.2). I ran through the entire card read process again and detected reader to get nonces again as well (on both firmwares). Ran through the same process on both firmwares.

And you ran the Mfkey attack and scanned the key again after?

doomwastaken avatar Jun 09 '23 20:06 doomwastaken

I read 16/16 sectors and get 30/32 keys (same as firmware .84.2). I ran through the entire card read process again and detected reader to get nonces again as well (on both firmwares). Ran through the same process on both firmwares.

And you ran the Mfkey attack and scanned the key again after?

Yes. This is something I would love to work… so I went through the whole process twice to make sure it wasn’t me messing up.

davenukem avatar Jun 09 '23 22:06 davenukem

@davenukem can you please send all the files needed to reproduce your problem? Please include the card dumps from 0.84.2 and from 0.85, the nonce files from running Detect reader, along with the sector numbers and key letters to which the reader is trying authenticate (e.g. Sector 8 Key A).

If your card contains private data - you can send it to me directly: [email protected]. Also, do you have a proxmark3? Having a trace file from it would greatly simplify things.

Astrrra avatar Jun 13 '23 15:06 Astrrra

I’ll try and get this over in the next day or so.

I don’t have a proxmark (but maybe this is a reason to finally snag one!).

Expect an update shortly.

Edit: never using that reply from email feature again…

davenukem avatar Jun 13 '23 16:06 davenukem