NFC CLI: Fix multiple apdu commands from not working when one of them gives an empty response (#2922)

* NFC CLI: Fix multiple apdu commands from not working when one of them gives an empty response
* Make PVS happy

Co-authored-by: hedger <hedger@users.noreply.github.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
erikj95 2023-08-02 17:24:02 +02:00 committed by GitHub
parent a7aef0bfc2
commit cf6706c42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -146,7 +146,7 @@ static void nfc_cli_apdu(Cli* cli, FuriString* args) {
resp_size = (tx_rx.rx_bits / 8) * 2;
if(!resp_size) {
printf("No response\r\n");
break;
continue;
}
resp_buffer = malloc(resp_size);
uint8_to_hex_chars(tx_rx.rx_data, resp_buffer, resp_size);

View File

@ -946,13 +946,13 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) {
}
if(!mf_classic_is_key_found(data, i, MfClassicKeyB)) {
if(mf_classic_authenticate_skip_activate(
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) {
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { //-V547
FURI_LOG_D(TAG, "Key B found: %012llX", key);
mf_classic_set_key_found(data, i, MfClassicKeyB, key);
nfc_worker->callback(NfcWorkerEventFoundKeyB, nfc_worker->context);
nfc_worker_mf_classic_key_attack(nfc_worker, key, &tx_rx, i + 1);
}
deactivated = true;
deactivated = true; //-V1048
} else {
// If the key B is marked as found and matches the searching key, invalidate it
MfClassicSectorTrailer* sec_trailer =
@ -964,12 +964,12 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) {
if(mf_classic_is_key_found(data, i, MfClassicKeyB) &&
memcmp(sec_trailer->key_b, current_key, 6) == 0) {
if(!mf_classic_authenticate_skip_activate(
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) {
&tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { //-V547
mf_classic_set_key_not_found(data, i, MfClassicKeyB);
FURI_LOG_D(TAG, "Key %dB not found in attack", i);
}
furi_hal_nfc_sleep();
deactivated = true;
deactivated = true; //-V1048
}
}
if(mf_classic_is_key_found(data, i, MfClassicKeyA) &&