hf mf info: fix backdoor detection when using non-default key
Some checks failed
MacOS Build and Test / macos-cmake (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
MacOS Build and Test / macos-make (push) Has been cancelled
MacOS Build and Test / macos-make-btaddon (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make-btaddon (push) Has been cancelled
Ubuntu Build and Test / ubuntu-cmake (push) Has been cancelled
Windows Build and Test / proxspace (push) Has been cancelled
Windows Build and Test / wsl (push) Has been cancelled

This commit is contained in:
Philippe Teuwen 2025-07-15 10:44:19 +02:00
commit d933e329c4

View file

@ -10393,13 +10393,14 @@ static int CmdHF14AMfInfo(const char *Cmd) {
if ((fKeyType == MF_KEY_A) || (fKeyType == MF_KEY_B)) {
// we've a key but not a backdoor key
uint8_t blockdata2[MFBLOCK_SIZE] = {0};
if (mf_read_block(0, fKeyType + 4, key, blockdata2) == PM3_SUCCESS) {
if (mf_read_block(0, fKeyType + 4, fkey, blockdata2) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "Backdoor key..... " _GREEN_("same as key A/B"));
} else if (detect_classic_auth(MF_KEY_BD)) {
PrintAndLogEx(SUCCESS, "Backdoor key..... " _RED_("detected but unknown!"));
PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("hf mf nested --blk 0 -%s -k %s --tblk 0 --tc 4") "`"
PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("hf mf nested --blk 0 -%s -k %s --tblk 0 --tc %i") "`"
, (fKeyType == MF_KEY_A) ? "a" : "b"
, sprint_hex_inrow(fkey, MIFARE_KEY_SIZE)
, fKeyType + 4
);
fKeyType = MF_KEY_BD;
}