From 3e8e99990909c241e164f309a583d76ca3b7305e Mon Sep 17 00:00:00 2001 From: Astra <93453568+Astrrra@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:58:59 +0900 Subject: [PATCH 1/4] [FL-3470] Rename Applications to Apps (#2939) * Applications are now apps * Desktop: Apps in settings Co-authored-by: Aleksandr Kutuzov --- applications/services/loader/loader.h | 2 +- applications/services/loader/loader_cli.c | 2 +- .../desktop_settings/scenes/desktop_settings_scene_favorite.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/services/loader/loader.h b/applications/services/loader/loader.h index 9fc4059f2..3da676e65 100644 --- a/applications/services/loader/loader.h +++ b/applications/services/loader/loader.h @@ -6,7 +6,7 @@ extern "C" { #endif #define RECORD_LOADER "loader" -#define LOADER_APPLICATIONS_NAME "Applications" +#define LOADER_APPLICATIONS_NAME "Apps" typedef struct Loader Loader; diff --git a/applications/services/loader/loader_cli.c b/applications/services/loader/loader_cli.c index af3ebf9e0..cbec4adca 100644 --- a/applications/services/loader/loader_cli.c +++ b/applications/services/loader/loader_cli.c @@ -14,7 +14,7 @@ static void loader_cli_print_usage() { } static void loader_cli_list() { - printf("Applications:\r\n"); + printf("Apps:\r\n"); for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { printf("\t%s\r\n", FLIPPER_APPS[i].name); } diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c index 26e7bc587..e0b4c118e 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_favorite.c @@ -7,10 +7,10 @@ #define APPS_COUNT (FLIPPER_APPS_COUNT + FLIPPER_EXTERNAL_APPS_COUNT) -#define EXTERNAL_BROWSER_NAME ("Applications") +#define EXTERNAL_BROWSER_NAME ("Apps") #define EXTERNAL_BROWSER_INDEX (APPS_COUNT + 1) -#define EXTERNAL_APPLICATION_NAME ("[External Application]") +#define EXTERNAL_APPLICATION_NAME ("[Select App]") #define EXTERNAL_APPLICATION_INDEX (APPS_COUNT + 2) #define PRESELECTED_SPECIAL 0xffffffff From a7aef0bfc27541639aa7be0cfc06a2db0ecc8c9a Mon Sep 17 00:00:00 2001 From: AloneLiberty <111039319+AloneLiberty@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:06:38 +0000 Subject: [PATCH 2/4] NFC: Fix MFC key invalidation (#2912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * NFC: Fix key invalidation (again~) * NFC: shouldn't be there This code get called each time we check for B key Co-authored-by: あく --- lib/nfc/nfc_worker.c | 69 +++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/lib/nfc/nfc_worker.c b/lib/nfc/nfc_worker.c index 145007bd3..b2c845f07 100644 --- a/lib/nfc/nfc_worker.c +++ b/lib/nfc/nfc_worker.c @@ -810,16 +810,10 @@ static void nfc_worker_mf_classic_key_attack( uint8_t block_num = mf_classic_get_sector_trailer_block_num_by_sector(i); if(mf_classic_is_sector_read(data, i)) continue; if(!mf_classic_is_key_found(data, i, MfClassicKeyA)) { - FURI_LOG_D( - TAG, - "Trying A key for sector %d, key: %04lx%08lx", - i, - (uint32_t)(key >> 32), - (uint32_t)key); + FURI_LOG_D(TAG, "Trying A key for sector %d, key: %012llX", i, 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 A found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); + FURI_LOG_D(TAG, "Key A found: %012llX", key); nfc_worker->callback(NfcWorkerEventFoundKeyA, nfc_worker->context); uint64_t found_key; @@ -832,18 +826,13 @@ static void nfc_worker_mf_classic_key_attack( } } } + furi_hal_nfc_sleep(); } if(!mf_classic_is_key_found(data, i, MfClassicKeyB)) { - FURI_LOG_D( - TAG, - "Trying B key for sector %d, key: %04lx%08lx", - i, - (uint32_t)(key >> 32), - (uint32_t)key); + FURI_LOG_D(TAG, "Trying B key for sector %d, key: %012llX", i, 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 B found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); + FURI_LOG_D(TAG, "Key B found: %012llX", key); nfc_worker->callback(NfcWorkerEventFoundKeyB, nfc_worker->context); } } @@ -891,8 +880,9 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) { nfc_worker->callback(NfcWorkerEventNewSector, nfc_worker->context); uint8_t block_num = mf_classic_get_sector_trailer_block_num_by_sector(i); if(mf_classic_is_sector_read(data, i)) continue; - bool is_key_a_found = mf_classic_is_key_found(data, i, MfClassicKeyA); - bool is_key_b_found = mf_classic_is_key_found(data, i, MfClassicKeyB); + if(mf_classic_is_key_found(data, i, MfClassicKeyA) && + mf_classic_is_key_found(data, i, MfClassicKeyB)) + continue; uint16_t key_index = 0; while(mf_classic_dict_get_next_key(dict, &key)) { FURI_LOG_T(TAG, "Key %d", key_index); @@ -910,19 +900,12 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) { nfc_worker_mf_classic_key_attack(nfc_worker, prev_key, &tx_rx, i); deactivated = true; } - FURI_LOG_D( - TAG, - "Try to auth to sector %d with key %04lx%08lx", - i, - (uint32_t)(key >> 32), - (uint32_t)key); - if(!is_key_a_found) { - is_key_a_found = mf_classic_is_key_found(data, i, MfClassicKeyA); + FURI_LOG_D(TAG, "Try to auth to sector %d with key %012llX", i, key); + if(!mf_classic_is_key_found(data, i, MfClassicKeyA)) { if(mf_classic_authenticate_skip_activate( &tx_rx, block_num, key, MfClassicKeyA, !deactivated, cuid)) { mf_classic_set_key_found(data, i, MfClassicKeyA, key); - FURI_LOG_D( - TAG, "Key A found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); + FURI_LOG_D(TAG, "Key A found: %012llX", key); nfc_worker->callback(NfcWorkerEventFoundKeyA, nfc_worker->context); uint64_t found_key; @@ -952,17 +935,19 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) { if(mf_classic_is_key_found(data, i, MfClassicKeyA) && memcmp(sec_trailer->key_a, current_key, 6) == 0) { - 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(!mf_classic_authenticate_skip_activate( + &tx_rx, block_num, key, MfClassicKeyA, !deactivated, cuid)) { + mf_classic_set_key_not_found(data, i, MfClassicKeyA); + FURI_LOG_D(TAG, "Key %dA not found in attack", i); + } } + furi_hal_nfc_sleep(); + deactivated = true; } - if(!is_key_b_found) { - is_key_b_found = mf_classic_is_key_found(data, i, MfClassicKeyB); + if(!mf_classic_is_key_found(data, i, MfClassicKeyB)) { if(mf_classic_authenticate_skip_activate( &tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { - FURI_LOG_D( - TAG, "Key B found: %04lx%08lx", (uint32_t)(key >> 32), (uint32_t)key); + 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); @@ -978,12 +963,18 @@ 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) { - 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(!mf_classic_authenticate_skip_activate( + &tx_rx, block_num, key, MfClassicKeyB, !deactivated, cuid)) { + 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; } } - if(is_key_a_found && is_key_b_found) break; + if(mf_classic_is_key_found(data, i, MfClassicKeyA) && + mf_classic_is_key_found(data, i, MfClassicKeyB)) + break; if(nfc_worker->state != NfcWorkerStateMfClassicDictAttack) break; } else { if(!card_removed_notified) { From cf6706c42eebff3631d702aa51119af6925a5b24 Mon Sep 17 00:00:00 2001 From: erikj95 Date: Wed, 2 Aug 2023 17:24:02 +0200 Subject: [PATCH 3/4] NFC CLI: Fix multiple apdu commands from not working when one of them gives an empty response (#2922) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * NFC CLI: Fix multiple apdu commands from not working when one of them gives an empty response * Make PVS happy Co-authored-by: hedger Co-authored-by: あく --- applications/main/nfc/nfc_cli.c | 2 +- lib/nfc/nfc_worker.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/main/nfc/nfc_cli.c b/applications/main/nfc/nfc_cli.c index 0b7e75475..e96174381 100644 --- a/applications/main/nfc/nfc_cli.c +++ b/applications/main/nfc/nfc_cli.c @@ -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); diff --git a/lib/nfc/nfc_worker.c b/lib/nfc/nfc_worker.c index b2c845f07..36776d804 100644 --- a/lib/nfc/nfc_worker.c +++ b/lib/nfc/nfc_worker.c @@ -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) && From c7648eb932bb8accedfc3a10ca54c953c7476996 Mon Sep 17 00:00:00 2001 From: Lesha Lomalkin Date: Wed, 2 Aug 2023 18:38:51 +0300 Subject: [PATCH 4/4] fbtenv: add additional environ variable to control execution flow (#2938) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fbtenv: add flags FBT_PRESERVE_TAR, FBT_SKIP_CHECK_SOURCED for usage with external tools * fbtenv: beautify, add info to fbtenv_print_config section if FBT_VERBOSE * fbtenv: fixes Co-authored-by: あく --- scripts/toolchain/fbtenv.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/toolchain/fbtenv.sh b/scripts/toolchain/fbtenv.sh index a86b0eced..c5040ed81 100755 --- a/scripts/toolchain/fbtenv.sh +++ b/scripts/toolchain/fbtenv.sh @@ -82,6 +82,9 @@ fbtenv_restore_env() fbtenv_check_sourced() { + if [ -n "${FBT_SKIP_CHECK_SOURCED:-""}" ]; then + return 0; + fi case "${ZSH_EVAL_CONTEXT:-""}" in *:file:*) setopt +o nomatch; # disabling 'no match found' warning in zsh return 0;; @@ -200,7 +203,7 @@ fbtenv_download_toolchain_tar() return 0; } -fbtenv_remove_old_tooclhain() +fbtenv_remove_old_toolchain() { printf "Removing old toolchain.."; rm -rf "${TOOLCHAIN_ARCH_DIR:?}"; @@ -231,12 +234,14 @@ fbtenv_unpack_toolchain() fbtenv_cleanup() { - printf "Cleaning up.."; if [ -n "${FBT_TOOLCHAIN_PATH:-""}" ]; then - rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.tar.gz; + printf "Cleaning up.."; rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.part; + if [ -z "${FBT_PRESERVE_TAR:-""}" ]; then + rm -rf "${FBT_TOOLCHAIN_PATH:?}/toolchain/"*.tar.gz; + fi + echo "done"; fi - echo "done"; trap - 2; return 0; } @@ -289,16 +294,22 @@ fbtenv_download_toolchain() fbtenv_curl_wget_check || return 1; fbtenv_download_toolchain_tar || return 1; fi - fbtenv_remove_old_tooclhain; + fbtenv_remove_old_toolchain; fbtenv_unpack_toolchain || return 1; fbtenv_cleanup; return 0; } -fbtenv_print_version() +fbtenv_print_config() { - if [ -n "$FBT_VERBOSE" ]; then + if [ -n "${FBT_VERBOSE:-""}" ]; then echo "FBT: using toolchain version $(cat "$TOOLCHAIN_ARCH_DIR/VERSION")"; + if [ -n "${FBT_SKIP_CHECK_SOURCED:-""}" ]; then + echo "FBT: fbtenv will not check if it is sourced or not"; + fi + if [ -n "${FBT_PRESERVE_TAR:-""}" ]; then + echo "FBT: toolchain archives will be saved"; + fi fi } @@ -316,7 +327,7 @@ fbtenv_main() fbtenv_check_env_vars || return 1; fbtenv_check_download_toolchain || return 1; fbtenv_set_shell_prompt; - fbtenv_print_version; + fbtenv_print_config; PATH="$TOOLCHAIN_ARCH_DIR/python/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/protobuf/bin:$PATH";