hf mf: stop a refused nested auth from hanging autopwn and eating the keys
MifareNested collected nonces in 'while (target_nt[i] == 0)' with no attempt counter. When the tag NAKs the nested authentication the loop re-sent the identical frame forever, so the client's 2s wait expired and autopwn returned PM3_ETIMEOUT — throwing away every key recovered up to that point. Reported on a card whose sector 16 refuses the standard MFC EV1 keys: 32 keys cracked, nothing saved. A NAK is a refusal, not a glitch, so the device now gives up on it and reports PM3_EWRONGANSWER. autopwn names the sector it skipped and carries on, and a timeout falls through to the key table and the dump whenever anything was recovered. Co-Authored-By: Claude Opus 5 (1M context)
This commit is contained in:
1 parent
c615ef8930
commit
e19c6755fe
3 files changed
+53
No files matched your search
@@ -2228,6 +2228,9 @@ static int CmdHF14AMfNested(const char *Cmd) { //TODO: single mode broken? can't
|
||||
case PM3_EFAILED:
|
||||
PrintAndLogEx(FAILED, "Tag isn't vulnerable to Nested Attack (PRNG is not predictable).\n");
|
||||
break;
|
||||
case PM3_EWRONGANSWER:
|
||||
PrintAndLogEx(FAILED, "Tag refused the nested authentication for block " _YELLOW_("%u") "\n", trgBlockNo);
|
||||
break;
|
||||
case PM3_ESOFT:
|
||||
PrintAndLogEx(FAILED, "No valid key found");
|
||||
break;
|
||||
@@ -2331,6 +2334,11 @@ static int CmdHF14AMfNested(const char *Cmd) { //TODO: single mode broken? can't
|
||||
case PM3_EFAILED :
|
||||
PrintAndLogEx(FAILED, "Tag isn't vulnerable to Nested Attack (PRNG is not predictable)\n");
|
||||
break;
|
||||
case PM3_EWRONGANSWER:
|
||||
// tag refused this block, nothing to gain by retrying it
|
||||
PrintAndLogEx(FAILED, "Tag refused the nested authentication for sector " _YELLOW_("%u") "\n", sectorNo);
|
||||
calibrate = false;
|
||||
continue;
|
||||
case PM3_ESOFT:
|
||||
//key not found
|
||||
calibrate = false;
|
||||
@@ -2942,6 +2950,20 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
return isOK;
|
||||
}
|
||||
|
||||
// how many keys are in hand right now. a sector that can't be cracked should
|
||||
// not cost the ones that already came out
|
||||
static uint8_t mfc_found_key_count(const sector_t *e_sector, uint8_t sector_cnt) {
|
||||
uint8_t n = 0;
|
||||
for (uint8_t i = 0; i < sector_cnt; i++) {
|
||||
for (uint8_t j = MF_KEY_A; j <= MF_KEY_B; j++) {
|
||||
if (e_sector[i].foundKey[j]) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
@@ -3706,10 +3728,29 @@ tryNested:
|
||||
switch (isOK) {
|
||||
case PM3_ETIMEOUT: {
|
||||
PrintAndLogEx(ERR, "\nError: No response from Proxmark3.");
|
||||
|
||||
uint8_t havekeys = mfc_found_key_count(e_sector, sector_cnt);
|
||||
if (havekeys) {
|
||||
PrintAndLogEx(INFO, "Keeping the " _YELLOW_("%u") " key%s recovered so far",
|
||||
havekeys,
|
||||
(havekeys == 1) ? "" : "s"
|
||||
);
|
||||
goto all_found;
|
||||
}
|
||||
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
return isOK;
|
||||
}
|
||||
case PM3_EWRONGANSWER: {
|
||||
// the tag NAKed the nested auth for this block. it is a
|
||||
// refusal, so move on rather than grind the same sector
|
||||
PrintAndLogEx(FAILED, "Tag refused the nested authentication, skipping sector " _YELLOW_("%3d") " key type " _YELLOW_("%c"),
|
||||
current_sector_i,
|
||||
(current_key_type_i == MF_KEY_B) ? 'B' : 'A'
|
||||
);
|
||||
continue;
|
||||
}
|
||||
case PM3_EOPABORTED: {
|
||||
PrintAndLogEx(WARNING, "\nButton pressed. Aborted.");
|
||||
free(e_sector);
|
||||
|
||||
Reference in new issue
Block a user