MIFARE Classic 1K, 4K and Mini: Memory Layout and Key Recovery on Your Own Card

7 min read188 courses on OnlySecurity

MIFARE Classic is the card that taught the industry that a proprietary cipher is not a security model. It is still in service in many buildings, transport systems and hotels. This guide covers how the memory is laid out, how its keys work and how to recover them from a card you own using the current Iceman client. Test only cards and systems you own or are authorised to assess.

The three sizes

MIFARE Classic is a 13.56 MHz ISO 14443-A memory card. The memory is organised in 16-byte blocks that are grouped in sectors.

  1. Mini: 320 bytes, five sectors of four blocks.
  2. 1K: 1,024 bytes, sixteen sectors of four blocks.
  3. 4K: 4,096 bytes, thirty-two sectors of four blocks followed by eight sectors of sixteen blocks.

The client also has a --2k option for 2K cards, such as a MIFARE Plus 2K running in its Classic compatible mode.

Blocks, sectors and trailers

Every sector ends in a trailer block that holds the keys and the access conditions. The trailer has Key A in bytes 0 to 5, the access bits in bytes 6 to 8, a general purpose user data byte in byte 9, then Key B in bytes 10 to 15. The access bits decide which key can read, write or change each block of the sector, so two applications can share one card with different keys. When a reader reads a trailer, the card returns zeros in place of Key A.

Block 0 is the manufacturer block. It holds the UID (with its check byte on 4-byte UID cards) and manufacturer data. It is programmed and write protected in production, so on a genuine card it cannot be written. Block 3 of each 1K sector, and the last block in each larger sector, is the trailer. This is why an application’s data sits in blocks 1 and 2, 4 to 6 and so on.

Sector 0 of a MIFARE Classic 1K card, one of 16 sectors of 4 blocks of 16 bytes. Block 0 is the manufacturer block holding the UID, BCC, SAK, ATQA and maker data, shown with the docs demo value. Block 3, like the last block of every sector, is the trailer holding key A, access bits and key B, shown with the factory default key FF FF FF FF FF FF as demo. On a genuine card block 0 is locked at the factory; on a magic card it can be rewritten.
A magic card is defined by one thing: block 0 is writable.

Identifying a card

hf search
hf mf info

hf search confirms the ISO 14443-A card and hf mf info reports the UID, ATQA and SAK, tests common default keys, shows whether the card is a magic card and reports its random number generator behaviour, including a static nonce. It also recognises some clone chip makers, such as the Fudan FM11RF08 family and its backdoor keys.

The cipher and why it fails

The cards authenticate each sector with a 48-bit key using a proprietary stream cipher called Crypto1. Since 2008 researchers published a series of attacks that together make key recovery practical. The darkside attack (Nicolas Courtois, 2009) needs no known key. The nested attack (Garcia and colleagues at Radboud University, 2009) needs one known key and recovers the rest. The hardnested attack (Carlo Meijer and Roel Verdult, ACM CCS 2015) handles the hardened cards, such as the Classic EV1, that NXP released in response. A card that uses a static nonce has its own variant. In 2024 Philippe Teuwen of Quarkslab showed that the Fudan FM11RF08S, a compatible chip sold as resistant to every known card-only attack, carries a hardware backdoor key that is the same on every such card and lets its keys be recovered in minutes even when they are diversified; the older FM11RF08 has a similar backdoor. hf mf info reports these backdoor keys when it finds them. The core fact is that a 48-bit key and a weak cipher cannot hold up against an attacker with a reader, whether the keys are default or not.

Timeline of three MIFARE Classic generations: the original with a predictable PRNG that could be broken with only a card and a reader, a next generation with a stronger PRNG for which a costlier route was later documented, and a further generation with a static nonce that brought its own distinct weakness. Each closed one gap while the dated design stayed, ending in the recommendation to migrate to a properly keyed modern credential.
Each revision fixed one flaw; the answer for a client is migration.

Recovering keys on your own card

The Iceman client automates the process:

hf mf autopwn

It tries the default key dictionary first, falls back to the darkside attack if no key is found, uses the keys it has to run the nested, hardnested or static nested attack against the remaining sectors, and writes the keys and a dump file when it finishes. For a 1K card you can say so with --1k. If you only want to test the default keys, use:

hf mf chk --1k -k FFFFFFFFFFFF

The key FFFFFFFFFFFF is the factory default, and the client also ships a dictionary file of common keys. To dump the card once you have its keys:

hf mf dump --1k

The dump is saved as binary and JSON files. It takes its keys from the key file that hf mf autopwn or hf mf chk --dump wrote, and from v4.23346 --sk also saves the extracted keys. To read a single block or sector, use hf mf rdbl or hf mf rdsc. The attacks run against a card, so keep the card still and in the same position on the antenna for the whole run.

Copying a card

To copy a dump you need a card that accepts a write to block 0. These cards are called magic cards, and they come in a few generations.

  1. Gen1A: responds to special commands that unlock block 0 writes. In the client, hf mf csetuid -u 01020304 sets the UID, and hf mf cload -f <file> loads a dump.
  2. Gen2 or CUID: accepts direct writes to block 0 with ordinary commands, so a normal hf mf restore writes the whole card.
  3. Gen4 GTU, also called UMC (ultimate magic card): has a configurable behaviour, a shadow mode and optional password protected backdoor commands, and can emulate MIFARE Classic, Ultralight and NTAG chips.

Some systems check for magic cards by testing their special commands, so a copy that works on one reader can fail on another. The Proxmark3 documentation of magic cards lists the types and the commands that identify them.

Security in plain terms

Treat MIFARE Classic as broken. A card that uses only default keys can be copied in seconds, and a card that uses diversified keys can usually still be recovered with the nested attacks. The right defence is to move to a card that uses an AES or equivalent scheme, with keys that are unique to each card and application, such as DESFire EV2 or EV3.

Where it is used

Hotel keys, gym and building access, student cards, laundry and vending credits, and older city transport cards.

To see the whole workflow in an assessment, with reporting and remediation, read Attacking RFID Access Control: Assess, Report and Fix. The Proxmark3 commands are taught in Proxmark: RFID Research and Cloning and the RFID and NFC Ultimate Course. For handheld emulation of the same cards, see Chameleon Ultra: Cloning and Emulating RFID Cards.

Proxmark3 commands

These commands were checked against Iceman client v4.23346, released September 2026. Run -h on any of them for the options in your own build.

  1. hf mf info identifies the card and tests the default keys, and hf mf autopwn recovers the keys and dumps the card in one run.
  2. hf mf chk, hf mf fchk, hf mf darkside, hf mf nested, hf mf hardnested and hf mf staticnested run the individual steps. hf mf sen and hf mf isen handle static encrypted nonce cards such as the FM11RF08S.
  3. hf mf dump reads a card whose keys are known, hf mf rdbl and hf mf rdsc read a block or sector, and hf mf view shows a saved dump. From v4.23346 hf mf view also decodes VIGIK and HID PACS data, and hf mf dump accepts --sk.
  4. hf mf restore writes a dump back, hf mf wrbl writes one block, and hf mf wipe resets a card to zeros and default keys.
  5. hf mf sim simulates a card from emulator memory, loaded with hf mf eload and read back with hf mf eview.
  6. hf mf csetuid, hf mf cload and hf mf cwipe work on Gen1A magic cards, the hf mf g... commands on Gen3 and Gen4 cards, and the hf mf gdm... commands on GDM cards. hf mf acl decodes access bits.

Each chip in this guide has its own entry in the RFID and NFC Chip Database: MIFARE Classic 1K, MIFARE Classic 4K and MIFARE Classic Mini.

More in this series

Start with the hub guide, How to Identify an RFID or NFC Card. Related reading: MIFARE Ultralight and Ultralight C and MIFARE Plus.

More from this author