Fuzzer App: worker

This commit is contained in:
gid9798
2023-06-03 00:32:32 +03:00
parent e31a0c4d6d
commit 70edcf3f6a
10 changed files with 336 additions and 11 deletions

View File

@@ -1,9 +1,22 @@
#include "../fuzzer_i.h"
#include "../helpers/fuzzer_custom_event.h"
#include "../helpers/protocol.h"
#include "../helpers/gui_const.h"
// 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;
@@ -23,7 +36,20 @@ void fuzzer_scene_attack_on_enter(void* context) {
fuzzer_attack_names[app->fuzzer_state.menu_index],
proto.name,
proto.data_size);
fuzzer_view_attack_set_uid(app->attack_view, &proto.dict.val[0], false);
fuzzer_worker_set_uid_chaged_callback(
app->worker, fuzzer_scene_attack_worker_tick_callback, app);
fuzzer_worker_set_end_callback(app->worker, fuzzer_scene_attack_worker_end_callback, app);
uint8_t temp_uid[MAX_PAYLOAD_SIZE];
fuzzer_worker_get_current_key(app->worker, temp_uid);
fuzzer_view_attack_set_attack(app->attack_view, false);
fuzzer_view_attack_set_uid(app->attack_view, (uint8_t*)&temp_uid);
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDAttack);
}
@@ -35,11 +61,40 @@ bool fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == FuzzerCustomEventViewAttackBack) {
if(!scene_manager_previous_scene(app->scene_manager)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
if(!scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack)) {
if(!scene_manager_previous_scene(app->scene_manager)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
} else {
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
fuzzer_view_attack_set_attack(app->attack_view, false);
fuzzer_worker_stop(app->worker);
}
consumed = true;
} else if(event.event == FuzzerCustomEventViewAttackOk) {
if(!scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack)) {
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, true);
fuzzer_view_attack_set_attack(app->attack_view, true);
fuzzer_worker_start(
app->worker, fuzzer_view_attack_get_time_delay(app->attack_view));
} else {
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
fuzzer_view_attack_set_attack(app->attack_view, false);
fuzzer_worker_stop(app->worker);
}
consumed = true;
} else if(event.event == FuzzerCustomEventViewAttackTick) {
uint8_t temp_uid[MAX_PAYLOAD_SIZE];
fuzzer_worker_get_current_key(app->worker, temp_uid);
fuzzer_view_attack_set_uid(app->attack_view, (uint8_t*)&temp_uid);
consumed = true;
} else if(event.event == FuzzerCustomEventViewAttackEnd) {
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
fuzzer_view_attack_set_attack(app->attack_view, false);
consumed = true;
}
}
@@ -47,7 +102,9 @@ bool fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
}
void fuzzer_scene_attack_on_exit(void* context) {
// furi_assert(context);
// PacsFuzzerApp* app = context;
UNUSED(context);
furi_assert(context);
PacsFuzzerApp* app = context;
fuzzer_worker_set_uid_chaged_callback(app->worker, NULL, NULL);
fuzzer_worker_set_end_callback(app->worker, NULL, NULL);
}

View File

@@ -1,6 +1,9 @@
#include "../fuzzer_i.h"
#include "../helpers/fuzzer_custom_event.h"
#include "../helpers/protocol.h"
#include "../helpers/gui_const.h"
void fuzzer_scene_main_callback(FuzzerCustomEvent event, void* context) {
furi_assert(context);
PacsFuzzerApp* app = context;
@@ -32,6 +35,16 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
consumed = true;
} else if(event.event == FuzzerCustomEventViewMainOk) {
fuzzer_view_main_get_state(app->main_view, &app->fuzzer_state);
switch(app->fuzzer_state.menu_index) {
case FuzzerMainMenuIndexDefaultValues:
fuzzer_worker_attack_dict(app->worker, app->fuzzer_state.proto_index);
break;
default:
break;
}
scene_manager_next_scene(app->scene_manager, FuzzerSceneAttack);
consumed = true;
}