From a540e695115951042914ebd1e54976e3a21e21d4 Mon Sep 17 00:00:00 2001 From: Vladimir Kondenko Date: Fri, 29 Sep 2023 02:14:35 +0400 Subject: [PATCH] Blink the LED while emulating cards --- apps_source_code/mifare_fuzzer/mifare_fuzzer.c | 7 +++++++ apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h | 2 ++ .../scenes/mifare_fuzzer_scene_emulator.c | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/apps_source_code/mifare_fuzzer/mifare_fuzzer.c b/apps_source_code/mifare_fuzzer/mifare_fuzzer.c index a431d428f77..be85abe034f 100644 --- a/apps_source_code/mifare_fuzzer/mifare_fuzzer.c +++ b/apps_source_code/mifare_fuzzer/mifare_fuzzer.c @@ -49,6 +49,9 @@ MifareFuzzerApp* mifare_fuzzer_alloc() { app->gui = furi_record_open(RECORD_GUI); view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); + // Open Notifications record + app->notifications = furi_record_open(RECORD_NOTIFICATION); + // view: select card type app->submenu_card = submenu_alloc(); view_dispatcher_add_view( @@ -116,6 +119,10 @@ void mifare_fuzzer_free(MifareFuzzerApp* app) { furi_record_close(RECORD_GUI); app->gui = NULL; + // Notifications + furi_record_close(RECORD_NOTIFICATION); + app->notifications = NULL; + // Worker //FURI_LOG_D(TAG, "mifare_fuzzer_free() :: Worker"); mifare_fuzzer_worker_free(app->worker); diff --git a/apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h b/apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h index c1b476ea3f8..0db554e2b85 100644 --- a/apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h +++ b/apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -54,6 +55,7 @@ typedef enum { struct MifareFuzzerApp { Gui* gui; + NotificationApp* notifications; ViewDispatcher* view_dispatcher; diff --git a/apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c b/apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c index 17628dde5c3..eab2f52ec98 100644 --- a/apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c +++ b/apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c @@ -1,4 +1,6 @@ #include "../mifare_fuzzer_i.h" +#include +#include uint8_t tick_counter = 0; uint8_t attack_step = 0; @@ -77,10 +79,12 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even if(event.event == MifareFuzzerEventStartAttack) { NfcDevice* nfc_device = NULL; const MfClassicData* mf_classic_data = NULL; + bool nfc_device_parsed = false; if(app->card_file_path) { nfc_device = app->worker->nfc_device; const char* path = furi_string_get_cstr(app->card_file_path); if(nfc_device_load(nfc_device, path)) { + nfc_device_parsed = true; mf_classic_data = nfc_device_get_data(nfc_device, NfcProtocolMfClassic); if(mf_classic_data->type == MfClassicType1k) { app->card = MifareCardClassic1k; @@ -203,10 +207,15 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even // Start worker mifare_fuzzer_worker_start(app->worker); + + if(nfc_device_parsed) { + notification_message(app->notifications, &sequence_blink_start_magenta); + } } else if(event.event == MifareFuzzerEventStopAttack) { //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStopAttack"); // Stop worker mifare_fuzzer_worker_stop(app->worker); + notification_message(app->notifications, &sequence_blink_stop); } else if(event.event == MifareFuzzerEventIncrementTicks) { if(!emulator->is_attacking) { if(emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) { @@ -257,6 +266,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even void mifare_fuzzer_scene_emulator_on_exit(void* context) { //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_exit()"); MifareFuzzerApp* app = context; + notification_message(app->notifications, &sequence_blink_stop); mifare_fuzzer_worker_stop(app->worker); if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {