From ae9659d32dec51fc6e1d2a382b8119043f3fa012 Mon Sep 17 00:00:00 2001 From: Astra <93453568+Astrrra@users.noreply.github.com> Date: Mon, 27 Mar 2023 10:28:13 +0300 Subject: [PATCH 1/2] [FL-3193] Additional checks before invalidating the key (#2533) --- lib/nfc/nfc_worker.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/nfc/nfc_worker.c b/lib/nfc/nfc_worker.c index 4561ff2af..c2b89c71a 100644 --- a/lib/nfc/nfc_worker.c +++ b/lib/nfc/nfc_worker.c @@ -638,7 +638,8 @@ static void nfc_worker_mf_classic_key_attack( (uint32_t)key); if(mf_classic_authenticate(tx_rx, block_num, key, MfClassicKeyA)) { mf_classic_set_key_found(data, i, MfClassicKeyA, key); - FURI_LOG_D(TAG, "Key found"); + FURI_LOG_D( + TAG, "Key A found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); nfc_worker->callback(NfcWorkerEventFoundKeyA, nfc_worker->context); uint64_t found_key; @@ -661,7 +662,8 @@ static void nfc_worker_mf_classic_key_attack( (uint32_t)key); if(mf_classic_authenticate(tx_rx, block_num, key, MfClassicKeyB)) { mf_classic_set_key_found(data, i, MfClassicKeyB, key); - FURI_LOG_D(TAG, "Key found"); + FURI_LOG_D( + TAG, "Key B found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); nfc_worker->callback(NfcWorkerEventFoundKeyB, nfc_worker->context); } } @@ -760,9 +762,13 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) { furi_hal_nfc_sleep(); deactivated = true; } else { - mf_classic_set_key_not_found(data, i, MfClassicKeyA); - is_key_a_found = false; - FURI_LOG_D(TAG, "Key %dA not found in attack", i); + // If the key A is marked as found and matches the searching key, invalidate it + if(mf_classic_is_key_found(data, i, MfClassicKeyA) && + data->block[i].value[0] == key) { + mf_classic_set_key_not_found(data, i, MfClassicKeyA); + is_key_a_found = false; + FURI_LOG_D(TAG, "Key %dA not found in attack", i); + } } if(!is_key_b_found) { is_key_b_found = mf_classic_is_key_found(data, i, MfClassicKeyB); @@ -775,9 +781,13 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) { } deactivated = true; } else { - mf_classic_set_key_not_found(data, i, MfClassicKeyB); - is_key_b_found = false; - FURI_LOG_D(TAG, "Key %dB not found in attack", i); + // If the key B is marked as found and matches the searching key, invalidate it + if(mf_classic_is_key_found(data, i, MfClassicKeyB) && + data->block[i].value[10] == key) { + mf_classic_set_key_not_found(data, i, MfClassicKeyB); + is_key_b_found = false; + FURI_LOG_D(TAG, "Key %dB not found in attack", i); + } } if(is_key_a_found && is_key_b_found) break; if(nfc_worker->state != NfcWorkerStateMfClassicDictAttack) break; From 27341fc1934ee309ee2ba1a2a42322449a12d7f4 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Mon, 27 Mar 2023 16:39:24 +0900 Subject: [PATCH 2/2] Fix typo in fbt.md (#2539) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit availabe -> available Co-authored-by: あく --- documentation/fbt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/fbt.md b/documentation/fbt.md index a47174631..65729c5c8 100644 --- a/documentation/fbt.md +++ b/documentation/fbt.md @@ -72,7 +72,7 @@ To run cleanup (think of `make clean`) for specified targets, add the `-c` optio - `get_stlink` - output serial numbers for attached STLink probes. Used for specifying an adapter with `OPENOCD_ADAPTER_SERIAL=...`. - `lint`, `format` - run clang-format on the C source code to check and reformat it according to the `.clang-format` specs. - `lint_py`, `format_py` - run [black](https://black.readthedocs.io/en/stable/index.html) on the Python source code, build system files & application manifests. -- `firmware_pvs` - generate a PVS Studio report for the firmware. Requires PVS Studio to be availabe on your system's `PATH`. +- `firmware_pvs` - generate a PVS Studio report for the firmware. Requires PVS Studio to be available on your system's `PATH`. - `cli` - start a Flipper CLI session over USB. ### Firmware targets