hf mf autopwn: detect static encrypted nonce via the backdoor key

When no sector key was known, autopwn probed for a static encrypted
nonce using the default key FFFFFFFFFFFF. On a FM11RF08S with
non-default keys that auth fails, the probe returns NONCE_FAIL, and
autopwn fell through to darkside/nested instead of the sen recovery.
The later re-detections are gated on known_key, so nothing recovered it.

Probe the known Fudan backdoor keys first, as 'hf mf info' and
'hf mf sen' already do, and run the detection with MF_KEY_BD. The
default key stays as the fallback for cards without a backdoor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5 committed 2026-09-22 15:41:32 +02:00
1 parent 7346db71ff
commit e824501492
2 files changed
+19 -1

No files matched your search

+18 -1
View File
@@ -77,6 +77,18 @@ static int HFMFAutoPwnSEN(sector_t *e_sector, size_t sector_cnt, const char *suf
return HFMFSENRecover(false, false, false, false, 0, 0x1, true, e_sector, sector_cnt, suffix, no_save);
}
// look for a known backdoor key which can read block 0
static bool mf_find_backdoor_key(uint8_t *key) {
uint8_t blockdata[MFBLOCK_SIZE] = {0};
for (uint8_t i = 0; i < ARRAYLEN(fm11_backdoor_keys); i++) {
if (mf_read_block(0, MF_KEY_BD, fm11_backdoor_keys[i], blockdata) == PM3_SUCCESS) {
memcpy(key, fm11_backdoor_keys[i], MIFARE_KEY_SIZE);
return true;
}
}
return false;
}
// Static array for Saflok key levels
static const SaflokKeyLevel saflok_key_levels[] = {
{1, "Guest Key"},
@@ -3362,7 +3374,12 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
if (known_key) {
has_staticnonce = detect_classic_static_encrypted_nonce(loopupblk, keytype, key);
} else {
has_staticnonce = detect_classic_static_encrypted_nonce(0, MF_KEY_A, g_mifare_default_key);
uint8_t bdkey[MIFARE_KEY_SIZE] = {0};
if (mf_find_backdoor_key(bdkey)) {
has_staticnonce = detect_classic_static_encrypted_nonce(0, MF_KEY_BD, bdkey);
} else {
has_staticnonce = detect_classic_static_encrypted_nonce(0, MF_KEY_A, g_mifare_default_key);
}
}
}