NFC

Recovering MIFARE Classic keys

Document image


If you couldnt read all the MIFARE Classic® cards sectors with the Read function or the sectors you read arent enough to get access, try exploiting vulnerabilities in MIFARE Classic NFC cards to get access.

On this page, youll learn how to conduct the MFKey32 attack, both with and without physical access to the card, as well as card-only attacks for which you don’t need access to the reader to calculate the keys.



MFKey32 attack

The MFKey32 attack exploits weaknesses in the Crypto-1 encryption algorithm. MFKey32 is the name of a tool/algorithm used to recover the MIFARE Classic keys from the reader’s Crypto-1 nonce pairs. It works by recovering the initial state of the Crypto-1 Linear Feedback Shift Register which contains the key.

With access to the reader and card

The best way to conduct the MFKey32 attack is to have access to the card, even if not all sectors were read. After getting the readers key, you can read more sectors of the card, which might be enough to get access.

To get the readers keys and read the MIFARE Classic card, do the following:

1

Read and save the card with your Flipper Zero.

2

Go to Main Menu -> NFC -> Saved -> Name of the saved card -> Extract MF Keys. Flipper Zero will emulate this card for the MFKey32 attack.

Your Flipper Zero is ready to collect the reader’s nonces
Your Flipper Zero is ready to collect the reader’s nonces

3

Tap the reader with your Flipper Zero, as shown below. When near the reader, your Flipper Zero will collect the readers nonces. Depending on the reader, you may need to tap the reader with your Flipper Zero several times until all 10 out 10 nonces are collected. On your Flipper Zeros screen, the number of collected nonce pairs should increase with each new tap of the reader. If the number of nonce pairs doesnt increase, the reader is not trying to authenticate the card emulated by your Flipper Zero.

To collect nonces, tap your Flipper Zero against the reader, pull it away, and repeat the process
To collect nonces, tap your Flipper Zero against the reader, pull it away, and repeat the process

4

Press %ok%OK to save the collected nonce pairs to the microSD card. Once the required number of nonce pairs is collected, the screen will display a Completed message. After that, you can press the %ok%OK button to view the captured data, including the sector and key from which it was obtained.

Once nonces are collected, you can save them to the microSD card
Once nonces are collected, you can save them to the microSD card

5

Recover keys from the collected nonces. You can do it via: Flipper Mobile App

  1. On your phone, run Flipper Mobile App and synchronize it with your Flipper Zero.
  2. Go to Tools -> Mfkey32 (Extract MF Keys).

Flipper Lab

  1. Connect your Flipper Zero to your computer via a USB-C cable.
  2. On your computer, go to lab.flipper.net.
  3. Go to NFC tools, then click the GIVE ME THE KEYS button.

MFKey app



If you dont have access to a smartphone or computer, you can recover keys from the collected nonces using only your Flipper Zero. Keep in mind that it takes several minutes to recover the keys due to the limited computing power of the device.

  1. On your Flipper Zero, go to Main Menu -> Apps -> NFC.
  2. Run the MFKey app and press the %ok%OK button.

The recovered keys will be displayed on the screen. After that, they can be added to the User dictionary. In some cases, the keys can’t be recovered from the nonces due to the reader not recognizing the Flipper Zero’s emulation properly.

6

Once new keys are added to the User dictionary, read the card again. The number of found keys and read sectors may increase, which indicates that necessary data is collected.

7

Emulate the card and hold your Flipper Zero near the reader to get access.

While emulating the NFC card, hold your Flipper Zero near the reader
While emulating the NFC card, hold your Flipper Zero near the reader



With access only to the reader

Even if you dont have access to the card, you can try to get the readers keys and then add them to the User dictionary to expand it.

To get and save the readers keys, do the following:

1

Go to Main Menu -> NFC -> Extract MF Keys. Flipper Zero will emulate an NFC card for the MFKey32 attack.

Your Flipper Zero is ready to collect the reader’s nonces
Your Flipper Zero is ready to collect the reader’s nonces

2

Tap the reader with your Flipper Zero as shown below. When near the reader, your Flipper Zero will collect the readers nonces. Depending on the reader, you may need to tap the reader with your Flipper Zero several times until all 10 out 10 nonces are collected. On your Flipper Zeros screen, the number of collected nonce pairs should increase with each new tap of the reader. If the number of nonce pairs doesnt increase, the reader is not trying to authenticate the card emulated by your Flipper Zero.

To collect nonces, tap your Flipper Zero against the reader, pull it away, and repeat the process
To collect nonces, tap your Flipper Zero against the reader, pull it away, and repeat the process

3

Press %ok%OK to save the collected nonce pairs to the microSD card. Once the required number of nonce pairs is collected, the screen will display a Completed message. After that, you can press the %ok%OK button to view the captured data, including the sector and key from which it was obtained.

Once nonces are collected, you can save them onto the microSD card
Once nonces are collected, you can save them onto the microSD card

4

Recover keys from the collected nonces. You can do it via: Flipper Mobile App

  1. On your phone, run Flipper Mobile App and synchronize it with your Flipper Zero.
  2. Go to Tools -> Mfkey32 (Extract MF Keys).

Flipper Lab

  1. Connect your Flipper Zero to your computer via a USB-C cable.
  2. On your computer, go to lab.flipper.net.
  3. Go to NFC tools, then click the GIVE ME THE KEYS button.

MFKey app

If you dont have access to a smartphone or computer, you can recover keys from the collected nonces using only your Flipper Zero. Keep in mind that it takes several minutes to recover the keys due to the limited computing power of the device.

  1. On your Flipper Zero, go to Main Menu -> Apps -> NFC.
  2. Run the MFKey app and press the %ok%OK button.

The recovered keys and sector numbers will be displayed on the screen. After that, they can be added to the User dictionary. In some cases, the keys can’t be recovered from the nonces because the reader won’t recognize the Flipper Zero emulation properly.



Card-only attacks



This type of attacks can be performed directly on the card exploiting vulnerabilities in MIFARE Classic cards. The goal of these attacks is to recover the cards data and keys, so that you can clone and emulate the card.

There are several card-only attacks that Flipper Zero performs based on the card type and available data: nested attacks, static nested attack, and hardnested attack. These attacks begin at the stage of reading the card (NFC -> Read). If card reading fails, Flipper Zero collects and saves card nonces to later calculate the keys via the MFKey app. The calculated keys are then added to the User dictionary of MIFARE Classic keys.





To get the cards keys and emulate the card, do the following:

1

Read the card to collect nonces, if you havent already.

Document image

2

(Optional) Check if the file with nonces is created on your Flipper Zero at /ext/nfc/.nested.log.

3

On your Flipper Zero, run the MFKey app by going to Main Menu -> Apps -> NFC -> MFKey and press %ok%ОК.

4

Wait until the card keys are calculated from the collected nonces — this takes a few minutes. After that, the new keys will be added to the User dictionary automatically.

5

Read the card again to unlock the sectors that were protected with the calculated key.

6

Emulate the card and hold your Flipper Zero against the reader to get access.

While emulating the NFC card, hold your Flipper Zero against the reader
While emulating the NFC card, hold your Flipper Zero against the reader




If the MFKey app fails to calculate keys

  • Reboot your Flipper Zero by pressing and holding the %left%LEFT and %back%BACK buttons for 5 seconds.
  • Delete the file with collected nonces, located at /ext/nfc/.nested.log. Then try collecting the nonces again and run MFKey.
  • Delete the file containing user keys, located at /ext/nfc/assets/mf_classic_dict_user.nfc. Then try collecting the nonces again and run MFKey. This action will permanently delete all the user keys. If you wish to retain your keys, back them up before deleting by downloading the file to your computer.


MIFARE and MIFARE Classic are registered trademarks of NXP B.V.

🤔
Have a question?
Our super-smart AI, knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.