Skip to content

Conversation

kormax
Copy link
Contributor

@kormax kormax commented Aug 20, 2025

To support execution of mfdes commands with "virtual" cards (VC), such as HCE-based Mifare2GO or cards with Mifare-VCA (Virtual card architecture) feature, an initial DF NAME SELECT must first be performed before any MIFARE commands can be issued.

To enable that use case, this PR adds dfname argument to the following commands:

  • detect;
  • auth;
  • getuid;
  • freemem;
  • getkeyversions;
  • getkeysettings;
  • getfileids;
  • getfileisoids;
  • getfilesettings;
  • lsfiles;
  • dump;

When dfname argument is specified, an ISO DF Name select is executed inside of DesfireSelectAndAuthenticateW before DESFIRE AID or ISO FID select.

Those updated commands have been tested to work with a virtual card in Google Wallet, and a real NDEF-formatted Mifare DESFire EV3 card. Here's a list of commands executed when validating the implementation on a real card:

# Executed on NDEF-formatted DESFire EV3 card

# General
hf mfdes detect
hf mfdes detect --dfname D2760000850100
hf mfdes auth -n 0 -t des -k 0000000000000000
hf mfdes auth -n 0 -t des -k 0000000000000000 --dfname D2760000850100

# PICC AID
hf mfdes getuid
hf mfdes freemem
hf mfdes getkeyversions
hf mfdes getkeyversions --aid 000000
hf mfdes getkeysettings
hf mfdes getkeysettings --aid 000000

# PICC DF Name
hf mfdes getuid --dfname D2760000850100
hf mfdes freemem --dfname D2760000850100
hf mfdes getkeyversions --dfname D2760000850100
hf mfdes getkeysettings --dfname D2760000850100

# NDEF AID
hf mfdes getkeysettings --aid 000001
hf mfdes getfileids -n 0 -t des -k 0000000000000000 --aid 000001
hf mfdes getfileisoids --aid 000001
hf mfdes getfilesettings --aid 000001
hf mfdes lsfiles --aid 000001
hf mfdes dump --aid 000001

# NDEF DF Name
hf mfdes getkeysettings --dfname D2760000850101
hf mfdes getfileids -n 0 -t des -k 0000000000000000 --dfname D2760000850101
hf mfdes getfileisoids --dfname D2760000850101
hf mfdes getfilesettings --dfname D2760000850101
hf mfdes lsfiles --dfname D2760000850101
hf mfdes dump --dfname D2760000850101

# DESFIRE DF Name -> NDEF AID
hf mfdes getfileids -n 0 -t des -k 0000000000000000 --dfname D2760000850100 --aid 000001
hf mfdes getfileisoids --dfname D2760000850100 --aid 000001
hf mfdes getfilesettings --dfname D2760000850100 --aid 000001
hf mfdes lsfiles --dfname D2760000850100 --aid 000001
hf mfdes dump --dfname D2760000850100 --aid 000001

Copy link

You are welcome to add an entry to the CHANGELOG.md as well

@iceman1001 iceman1001 merged commit 833eea4 into RfidResearchGroup:master Aug 20, 2025
12 checks passed
@iceman1001
Copy link
Collaborator

Wow!
What a pull request. Amazing!
Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants