mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-24 05:34:45 -07:00
Fuzzer App: notifications
This commit is contained in:
15
applications/external/pacs_fuzzer/fuzzer.c
vendored
15
applications/external/pacs_fuzzer/fuzzer.c
vendored
@@ -35,9 +35,16 @@ PacsFuzzerApp* fuzzer_app_alloc() {
|
||||
// Dialog
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
||||
// Open Notification record
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
// View Dispatcher
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
|
||||
// Popup
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, FuzzerViewIDPopup, popup_get_view(app->popup));
|
||||
|
||||
// Main view
|
||||
app->main_view = fuzzer_view_main_alloc();
|
||||
view_dispatcher_add_view(
|
||||
@@ -88,6 +95,10 @@ void fuzzer_app_free(PacsFuzzerApp* app) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FuzzerViewIDFieldEditor);
|
||||
fuzzer_view_field_editor_free(app->field_editor_view);
|
||||
|
||||
// Popup
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FuzzerViewIDPopup);
|
||||
popup_free(app->popup);
|
||||
|
||||
scene_manager_free(app->scene_manager);
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -97,6 +108,10 @@ void fuzzer_app_free(PacsFuzzerApp* app) {
|
||||
// Close records
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
// Notifications
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
app->notifications = NULL;
|
||||
|
||||
furi_string_free(app->file_path);
|
||||
|
||||
fuzzer_worker_free(app->worker);
|
||||
|
||||
7
applications/external/pacs_fuzzer/fuzzer_i.h
vendored
7
applications/external/pacs_fuzzer/fuzzer_i.h
vendored
@@ -3,11 +3,13 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/popup.h>
|
||||
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#include "scenes/fuzzer_scene.h"
|
||||
#include "views/main_menu.h"
|
||||
@@ -33,9 +35,12 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
Gui* gui;
|
||||
NotificationApp* notifications;
|
||||
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
|
||||
Popup* popup;
|
||||
DialogsApp* dialogs;
|
||||
FuzzerViewMain* main_view;
|
||||
FuzzerViewAttack* attack_view;
|
||||
|
||||
@@ -5,10 +5,11 @@ typedef enum {
|
||||
// FuzzerCustomEvent
|
||||
FuzzerCustomEventViewMainBack = 100,
|
||||
FuzzerCustomEventViewMainOk,
|
||||
FuzzerCustomEventViewMainPopupErr,
|
||||
|
||||
FuzzerCustomEventViewAttackBack,
|
||||
FuzzerCustomEventViewAttackOk,
|
||||
FuzzerCustomEventViewAttackTick,
|
||||
// FuzzerCustomEventViewAttackTick, // now not use
|
||||
FuzzerCustomEventViewAttackEnd,
|
||||
|
||||
FuzzerCustomEventViewFieldEditorBack,
|
||||
|
||||
@@ -16,6 +16,8 @@ typedef enum {
|
||||
} FuzzerAttackState;
|
||||
|
||||
typedef enum {
|
||||
FuzzerViewIDPopup,
|
||||
|
||||
FuzzerViewIDMain,
|
||||
FuzzerViewIDAttack,
|
||||
FuzzerViewIDFieldEditor,
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
|
||||
// TODO simlify callbacks and attack state
|
||||
|
||||
void fuzzer_scene_attack_worker_tick_callback(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, FuzzerCustomEventViewAttackTick);
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_worker_end_callback(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, FuzzerCustomEventViewAttackEnd);
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_callback(FuzzerCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
const NotificationSequence sequence_one_green_50_on_blink_blue = {
|
||||
&message_red_255,
|
||||
&message_delay_50,
|
||||
&message_red_0,
|
||||
&message_blink_start_10,
|
||||
&message_blink_set_color_blue,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void fuzzer_scene_attack_update_uid(PacsFuzzerApp* app) {
|
||||
furi_assert(app);
|
||||
@@ -34,6 +26,56 @@ static void fuzzer_scene_attack_update_uid(PacsFuzzerApp* app) {
|
||||
free(uid.data);
|
||||
}
|
||||
|
||||
static void fuzzer_scene_attack_set_state(PacsFuzzerApp* app, FuzzerAttackState state) {
|
||||
furi_assert(app);
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, state);
|
||||
switch(state) {
|
||||
case FuzzerAttackStateIdle:
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
fuzzer_view_attack_pause(app->attack_view);
|
||||
break;
|
||||
|
||||
case FuzzerAttackStateRunning:
|
||||
notification_message(app->notifications, &sequence_blink_start_blue);
|
||||
fuzzer_view_attack_start(app->attack_view);
|
||||
break;
|
||||
|
||||
case FuzzerAttackStateEnd:
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
notification_message(app->notifications, &sequence_single_vibro);
|
||||
fuzzer_view_attack_end(app->attack_view);
|
||||
break;
|
||||
|
||||
case FuzzerAttackStateOff:
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
fuzzer_view_attack_stop(app->attack_view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_worker_tick_callback(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
|
||||
notification_message(app->notifications, &sequence_one_green_50_on_blink_blue);
|
||||
fuzzer_scene_attack_update_uid(app);
|
||||
|
||||
// view_dispatcher_send_custom_event(app->view_dispatcher, FuzzerCustomEventViewAttackTick);
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_worker_end_callback(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, FuzzerCustomEventViewAttackEnd);
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_callback(FuzzerCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void fuzzer_scene_attack_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
@@ -68,15 +110,13 @@ bool fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
|
||||
FuzzerAttackStateRunning) {
|
||||
// Pause if attack running
|
||||
fuzzer_worker_pause(app->worker);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateIdle);
|
||||
fuzzer_view_attack_pause(app->attack_view);
|
||||
|
||||
fuzzer_scene_attack_set_state(app, FuzzerAttackStateIdle);
|
||||
} else {
|
||||
// Exit
|
||||
fuzzer_worker_stop(app->worker);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateOff);
|
||||
fuzzer_view_attack_stop(app->attack_view);
|
||||
|
||||
fuzzer_scene_attack_set_state(app, FuzzerAttackStateOff);
|
||||
if(!scene_manager_previous_scene(app->scene_manager)) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
@@ -89,28 +129,23 @@ bool fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
|
||||
// Start or Continue Attack
|
||||
if(fuzzer_worker_start(
|
||||
app->worker, fuzzer_view_attack_get_time_delay(app->attack_view))) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateRunning);
|
||||
fuzzer_view_attack_start(app->attack_view);
|
||||
fuzzer_scene_attack_set_state(app, FuzzerAttackStateRunning);
|
||||
} else {
|
||||
// Error?
|
||||
}
|
||||
} else if(
|
||||
scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack) ==
|
||||
FuzzerAttackStateRunning) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateIdle);
|
||||
fuzzer_view_attack_pause(app->attack_view);
|
||||
// Pause if attack running
|
||||
fuzzer_worker_pause(app->worker); // XXX
|
||||
|
||||
fuzzer_scene_attack_set_state(app, FuzzerAttackStateIdle);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.event == FuzzerCustomEventViewAttackTick) {
|
||||
fuzzer_scene_attack_update_uid(app);
|
||||
consumed = true;
|
||||
// } else if(event.event == FuzzerCustomEventViewAttackTick) {
|
||||
// consumed = true;
|
||||
} else if(event.event == FuzzerCustomEventViewAttackEnd) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateEnd);
|
||||
fuzzer_view_attack_end(app->attack_view);
|
||||
fuzzer_scene_attack_set_state(app, FuzzerAttackStateEnd);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
@@ -122,6 +157,8 @@ void fuzzer_scene_attack_on_exit(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
|
||||
// fuzzer_worker_stop(); // XXX
|
||||
|
||||
fuzzer_worker_set_uid_chaged_callback(app->worker, NULL, NULL);
|
||||
fuzzer_worker_set_end_callback(app->worker, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ void fuzzer_scene_main_callback(FuzzerCustomEvent event, void* context) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void fuzzer_scene_main_error_popup_callback(void* context) {
|
||||
PacsFuzzerApp* app = context;
|
||||
notification_message(app->notifications, &sequence_reset_rgb);
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, FuzzerCustomEventViewMainPopupErr);
|
||||
}
|
||||
|
||||
static bool fuzzer_scene_main_load_custom_dict(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
@@ -49,6 +55,15 @@ static bool fuzzer_scene_main_load_key(void* context) {
|
||||
return res;
|
||||
}
|
||||
|
||||
static void fuzzer_scene_main_show_error(void* context, const char* erre_str) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
popup_set_header(app->popup, erre_str, 64, 20, AlignCenter, AlignTop);
|
||||
notification_message(app->notifications, &sequence_set_red_255);
|
||||
notification_message(app->notifications, &sequence_double_vibro);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDPopup);
|
||||
}
|
||||
|
||||
void fuzzer_scene_main_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
PacsFuzzerApp* app = context;
|
||||
@@ -57,6 +72,14 @@ void fuzzer_scene_main_on_enter(void* context) {
|
||||
|
||||
fuzzer_view_main_update_data(app->main_view, app->fuzzer_state);
|
||||
|
||||
// Setup view
|
||||
Popup* popup = app->popup;
|
||||
// popup_set_icon(popup, 72, 17, &I_DolphinCommon_56x48);
|
||||
popup_set_timeout(popup, 2500);
|
||||
popup_set_context(popup, app);
|
||||
popup_set_callback(popup, fuzzer_scene_main_error_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDMain);
|
||||
}
|
||||
|
||||
@@ -72,6 +95,9 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.event == FuzzerCustomEventViewMainPopupErr) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDMain);
|
||||
consumed = true;
|
||||
} else if(event.event == FuzzerCustomEventViewMainOk) {
|
||||
fuzzer_view_main_get_state(app->main_view, &app->fuzzer_state);
|
||||
|
||||
@@ -88,9 +114,11 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(!loading_ok) {
|
||||
// error
|
||||
fuzzer_scene_main_show_error(app, "Default dictionary\nis empty");
|
||||
}
|
||||
break;
|
||||
case FuzzerAttackIdBFCustomerID:
|
||||
// TODO
|
||||
uid = malloc(d_size);
|
||||
memset(uid, 0x00, d_size);
|
||||
|
||||
@@ -114,6 +142,7 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(app->scene_manager, FuzzerSceneFieldEditor);
|
||||
FURI_LOG_I("Scene", "Load ok");
|
||||
} else {
|
||||
fuzzer_scene_main_show_error(app, "Unsupported protocol\nor broken file");
|
||||
FURI_LOG_W("Scene", "Load err");
|
||||
}
|
||||
}
|
||||
@@ -125,6 +154,10 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
} else {
|
||||
loading_ok = fuzzer_worker_init_attack_file_dict(
|
||||
app->worker, app->fuzzer_state.proto_index, app->file_path);
|
||||
if(!loading_ok) {
|
||||
fuzzer_scene_main_show_error(app, "Incorrect key format\nor length");
|
||||
// error
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
16
applications/external/pacs_fuzzer/todo.md
vendored
16
applications/external/pacs_fuzzer/todo.md
vendored
@@ -5,10 +5,13 @@
|
||||
- [ ] Make the "Load File" independent of the current protocol
|
||||
- [x] Add pause
|
||||
- [ ] Switching UIDs if possible
|
||||
- [ ] Led and sound Notification
|
||||
- [ ] Error Notification
|
||||
- [ ] Custom UIDs dict loading
|
||||
- [ ] Key file loading
|
||||
- [x] Led and sound Notification
|
||||
- [x] Led
|
||||
- [x] Vibro
|
||||
- [ ] Sound?
|
||||
- [x] Error Notification
|
||||
- [x] Custom UIDs dict loading
|
||||
- [x] Key file loading
|
||||
- [ ] Anything else
|
||||
|
||||
#### App functionality
|
||||
@@ -20,7 +23,6 @@
|
||||
|
||||
- [ ] GUI
|
||||
- [x] Rewrite `gui_const` logic
|
||||
- [ ] Separate protocol name from `fuzzer_proto_items`
|
||||
- [x] Icon in dialog
|
||||
- [x] Description and buttons in `field_editor` view
|
||||
- [ ] Protocol carousel in `main_menu`
|
||||
@@ -30,4 +32,6 @@
|
||||
- [x] `UID_MAX_SIZE`
|
||||
- [x] Add pause
|
||||
- [x] Fix `Custom dict` attack when ended
|
||||
- [x] this can be simplified `fuzzer_proto_items`
|
||||
- [ ] Worker
|
||||
- [ ] Use `prtocol_id` instead of protocol name
|
||||
- [x] this can be simplified `fuzzer_proto_items`
|
||||
Reference in New Issue
Block a user