hf mf sim -x: collect nonces for mfkey32v2 only if current sim key is invalid

This commit is contained in:
Philippe Teuwen 2024-10-15 23:48:17 +02:00
commit 8828c9513e

View file

@ -1141,6 +1141,12 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
nr = bytes_to_num(receivedCmd, 4); nr = bytes_to_num(receivedCmd, 4);
ar = bytes_to_num(&receivedCmd[4], 4); ar = bytes_to_num(&receivedCmd[4], 4);
// --- crypto
crypto1_word(pcs, nr, 1);
cardRr = ar ^ crypto1_word(pcs, 0, 0);
// test if auth KO
if (cardRr != prng_successor(nonce, 64)) {
// Collect AR/NR per keytype & sector // Collect AR/NR per keytype & sector
if ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) { if ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) {
@ -1183,13 +1189,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
} }
} }
} }
// --- crypto
crypto1_word(pcs, nr, 1);
cardRr = ar ^ crypto1_word(pcs, 0, 0);
// test if auth KO
if (cardRr != prng_successor(nonce, 64)) {
if (g_dbglevel >= DBG_EXTENDED) { if (g_dbglevel >= DBG_EXTENDED) {
Dbprintf("[MFEMUL_AUTH1] AUTH FAILED for sector %d with key %c. [nr=%08x cardRr=%08x] [nt=%08x succ=%08x]" Dbprintf("[MFEMUL_AUTH1] AUTH FAILED for sector %d with key %c. [nr=%08x cardRr=%08x] [nt=%08x succ=%08x]"
, cardAUTHSC , cardAUTHSC