mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 21:34:35 +03:00
Fuzzer App: Attack state
This commit is contained in:
parent
6eed74c716
commit
d3eb43ce35
@ -7,6 +7,14 @@ typedef struct {
|
|||||||
uint8_t proto_index;
|
uint8_t proto_index;
|
||||||
} FuzzerState;
|
} FuzzerState;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FuzzerAttackStateOff = 0,
|
||||||
|
FuzzerAttackStateIdle,
|
||||||
|
FuzzerAttackStateRunning,
|
||||||
|
FuzzerAttackStateEnd,
|
||||||
|
|
||||||
|
} FuzzerAttackState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FuzzerViewIDMain,
|
FuzzerViewIDMain,
|
||||||
FuzzerViewIDAttack,
|
FuzzerViewIDAttack,
|
||||||
|
@ -156,7 +156,7 @@ static void fuzzer_worker_on_tick_callback(void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!fuzzer_worker_load_key(worker, true)) {
|
if(!fuzzer_worker_load_key(worker, true)) {
|
||||||
fuzzer_worker_stop(worker);
|
fuzzer_worker_pause(worker); // XXX
|
||||||
if(worker->end_callback) {
|
if(worker->end_callback) {
|
||||||
worker->end_callback(worker->end_context);
|
worker->end_callback(worker->end_context);
|
||||||
}
|
}
|
||||||
@ -377,12 +377,23 @@ bool fuzzer_worker_start(FuzzerWorker* worker, uint8_t timer_dellay) {
|
|||||||
|
|
||||||
furi_timer_start(worker->timer, furi_ms_to_ticks(timer_dellay * 100));
|
furi_timer_start(worker->timer, furi_ms_to_ticks(timer_dellay * 100));
|
||||||
|
|
||||||
worker->treead_running = true;
|
if(!worker->treead_running) {
|
||||||
#if defined(RFID_125_PROTOCOL)
|
#if defined(RFID_125_PROTOCOL)
|
||||||
lfrfid_worker_start_thread(worker->proto_worker);
|
lfrfid_worker_start_thread(worker->proto_worker);
|
||||||
lfrfid_worker_emulate_start(worker->proto_worker, worker->protocol_id);
|
|
||||||
#else
|
#else
|
||||||
ibutton_worker_start_thread(worker->proto_worker);
|
ibutton_worker_start_thread(worker->proto_worker);
|
||||||
|
#endif
|
||||||
|
FURI_LOG_D(TAG, "Worker Starting");
|
||||||
|
worker->treead_running = true;
|
||||||
|
} else {
|
||||||
|
FURI_LOG_D(TAG, "Worker UnPaused");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(RFID_125_PROTOCOL)
|
||||||
|
// lfrfid_worker_start_thread(worker->proto_worker);
|
||||||
|
lfrfid_worker_emulate_start(worker->proto_worker, worker->protocol_id);
|
||||||
|
#else
|
||||||
|
// ibutton_worker_start_thread(worker->proto_worker);
|
||||||
ibutton_worker_emulate_start(worker->proto_worker, worker->key);
|
ibutton_worker_emulate_start(worker->proto_worker, worker->key);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@ -390,6 +401,21 @@ bool fuzzer_worker_start(FuzzerWorker* worker, uint8_t timer_dellay) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fuzzer_worker_pause(FuzzerWorker* worker) {
|
||||||
|
furi_assert(worker);
|
||||||
|
|
||||||
|
furi_timer_stop(worker->timer);
|
||||||
|
|
||||||
|
if(worker->treead_running) {
|
||||||
|
#if defined(RFID_125_PROTOCOL)
|
||||||
|
lfrfid_worker_stop(worker->proto_worker);
|
||||||
|
#else
|
||||||
|
ibutton_worker_stop(worker->proto_worker);
|
||||||
|
#endif
|
||||||
|
FURI_LOG_D(TAG, "Worker Paused");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fuzzer_worker_stop(FuzzerWorker* worker) {
|
void fuzzer_worker_stop(FuzzerWorker* worker) {
|
||||||
furi_assert(worker);
|
furi_assert(worker);
|
||||||
|
|
||||||
@ -403,6 +429,7 @@ void fuzzer_worker_stop(FuzzerWorker* worker) {
|
|||||||
ibutton_worker_stop(worker->proto_worker);
|
ibutton_worker_stop(worker->proto_worker);
|
||||||
ibutton_worker_stop_thread(worker->proto_worker);
|
ibutton_worker_stop_thread(worker->proto_worker);
|
||||||
#endif
|
#endif
|
||||||
|
FURI_LOG_D(TAG, "Worker Stopping");
|
||||||
worker->treead_running = false;
|
worker->treead_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ bool fuzzer_worker_start(FuzzerWorker* worker, uint8_t timer_dellay);
|
|||||||
|
|
||||||
void fuzzer_worker_stop(FuzzerWorker* worker);
|
void fuzzer_worker_stop(FuzzerWorker* worker);
|
||||||
|
|
||||||
|
void fuzzer_worker_pause(FuzzerWorker* worker);
|
||||||
|
|
||||||
bool fuzzer_worker_attack_dict(FuzzerWorker* worker, FuzzerProtocolsID protocol_index);
|
bool fuzzer_worker_attack_dict(FuzzerWorker* worker, FuzzerProtocolsID protocol_index);
|
||||||
|
|
||||||
bool fuzzer_worker_attack_bf_byte(
|
bool fuzzer_worker_attack_bf_byte(
|
||||||
|
@ -49,11 +49,10 @@ void fuzzer_scene_attack_on_enter(void* context) {
|
|||||||
app->attack_view,
|
app->attack_view,
|
||||||
fuzzer_proto_get_menu_label(app->fuzzer_state.menu_index),
|
fuzzer_proto_get_menu_label(app->fuzzer_state.menu_index),
|
||||||
fuzzer_proto_get_name(app->fuzzer_state.proto_index));
|
fuzzer_proto_get_name(app->fuzzer_state.proto_index));
|
||||||
fuzzer_view_attack_set_attack(app->attack_view, false);
|
|
||||||
|
|
||||||
fuzzer_scene_attack_update_uid(app);
|
fuzzer_scene_attack_update_uid(app);
|
||||||
|
|
||||||
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
|
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateIdle);
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDAttack);
|
view_dispatcher_switch_to_view(app->view_dispatcher, FuzzerViewIDAttack);
|
||||||
}
|
}
|
||||||
@ -65,35 +64,53 @@ bool fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
|
|||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == FuzzerCustomEventViewAttackBack) {
|
if(event.event == FuzzerCustomEventViewAttackBack) {
|
||||||
if(!scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack)) {
|
if(scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack) ==
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
// Exit
|
||||||
|
fuzzer_worker_stop(app->worker);
|
||||||
|
scene_manager_set_scene_state(
|
||||||
|
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateOff);
|
||||||
|
fuzzer_view_attack_stop(app->attack_view);
|
||||||
if(!scene_manager_previous_scene(app->scene_manager)) {
|
if(!scene_manager_previous_scene(app->scene_manager)) {
|
||||||
scene_manager_stop(app->scene_manager);
|
scene_manager_stop(app->scene_manager);
|
||||||
view_dispatcher_stop(app->view_dispatcher);
|
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;
|
consumed = true;
|
||||||
} else if(event.event == FuzzerCustomEventViewAttackOk) {
|
} else if(event.event == FuzzerCustomEventViewAttackOk) {
|
||||||
if(!scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack) &&
|
if(scene_manager_get_scene_state(app->scene_manager, FuzzerSceneAttack) ==
|
||||||
fuzzer_worker_start(
|
FuzzerAttackStateIdle) {
|
||||||
|
// Start or Continue Attack
|
||||||
|
if(fuzzer_worker_start(
|
||||||
app->worker, fuzzer_view_attack_get_time_delay(app->attack_view))) {
|
app->worker, fuzzer_view_attack_get_time_delay(app->attack_view))) {
|
||||||
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, true);
|
scene_manager_set_scene_state(
|
||||||
fuzzer_view_attack_set_attack(app->attack_view, true);
|
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateRunning);
|
||||||
|
fuzzer_view_attack_start(app->attack_view);
|
||||||
} else {
|
} else {
|
||||||
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
|
// Error?
|
||||||
fuzzer_view_attack_set_attack(app->attack_view, false);
|
}
|
||||||
fuzzer_worker_stop(app->worker);
|
} 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);
|
||||||
|
fuzzer_worker_pause(app->worker); // XXX
|
||||||
}
|
}
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == FuzzerCustomEventViewAttackTick) {
|
} else if(event.event == FuzzerCustomEventViewAttackTick) {
|
||||||
fuzzer_scene_attack_update_uid(app);
|
fuzzer_scene_attack_update_uid(app);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == FuzzerCustomEventViewAttackEnd) {
|
} else if(event.event == FuzzerCustomEventViewAttackEnd) {
|
||||||
scene_manager_set_scene_state(app->scene_manager, FuzzerSceneAttack, false);
|
scene_manager_set_scene_state(
|
||||||
fuzzer_view_attack_set_attack(app->attack_view, false);
|
app->scene_manager, FuzzerSceneAttack, FuzzerAttackStateEnd);
|
||||||
|
fuzzer_view_attack_end(app->attack_view);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
applications/external/pacs_fuzzer/todo.md
vendored
6
applications/external/pacs_fuzzer/todo.md
vendored
@ -3,7 +3,7 @@
|
|||||||
#### Quality of life
|
#### Quality of life
|
||||||
|
|
||||||
- [ ] Make the "Load File" independent of the current protocol
|
- [ ] Make the "Load File" independent of the current protocol
|
||||||
- [ ] Add pause
|
- [x] Add pause
|
||||||
- [ ] Switching UIDs if possible
|
- [ ] Switching UIDs if possible
|
||||||
- [ ] Led and sound Notification
|
- [ ] Led and sound Notification
|
||||||
- [ ] Error Notification
|
- [ ] Error Notification
|
||||||
@ -28,6 +28,6 @@
|
|||||||
- [x] UID
|
- [x] UID
|
||||||
- [x] Simplify the storage and exchange of `uids.data` `uid.data_size` in `views`
|
- [x] Simplify the storage and exchange of `uids.data` `uid.data_size` in `views`
|
||||||
- [x] `UID_MAX_SIZE`
|
- [x] `UID_MAX_SIZE`
|
||||||
- [ ] Add pause
|
- [x] Add pause
|
||||||
- [ ] Fix `Custom dict` attack when ended
|
- [x] Fix `Custom dict` attack when ended
|
||||||
- [x] this can be simplified `fuzzer_proto_items`
|
- [x] this can be simplified `fuzzer_proto_items`
|
||||||
|
63
applications/external/pacs_fuzzer/views/attack.c
vendored
63
applications/external/pacs_fuzzer/views/attack.c
vendored
@ -17,7 +17,7 @@ typedef struct {
|
|||||||
uint8_t time_delay;
|
uint8_t time_delay;
|
||||||
const char* attack_name;
|
const char* attack_name;
|
||||||
const char* protocol_name;
|
const char* protocol_name;
|
||||||
bool attack_enabled;
|
FuzzerAttackState attack_state;
|
||||||
char* uid;
|
char* uid;
|
||||||
} FuzzerViewAttackModel;
|
} FuzzerViewAttackModel;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ void fuzzer_view_attack_reset_data(
|
|||||||
{
|
{
|
||||||
model->attack_name = attack_name;
|
model->attack_name = attack_name;
|
||||||
model->protocol_name = protocol_name;
|
model->protocol_name = protocol_name;
|
||||||
model->attack_enabled = false;
|
model->attack_state = FuzzerAttackStateIdle;
|
||||||
strcpy(model->uid, "Not_set");
|
strcpy(model->uid, "Not_set");
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
@ -68,11 +68,44 @@ void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const FuzzerPayload uid)
|
|||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fuzzer_view_attack_set_attack(FuzzerViewAttack* view, bool attack) {
|
void fuzzer_view_attack_start(FuzzerViewAttack* view) {
|
||||||
furi_assert(view);
|
furi_assert(view);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
view->view, FuzzerViewAttackModel * model, { model->attack_enabled = attack; }, true);
|
view->view,
|
||||||
|
FuzzerViewAttackModel * model,
|
||||||
|
{ model->attack_state = FuzzerAttackStateRunning; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fuzzer_view_attack_stop(FuzzerViewAttack* view) {
|
||||||
|
furi_assert(view);
|
||||||
|
|
||||||
|
with_view_model(
|
||||||
|
view->view,
|
||||||
|
FuzzerViewAttackModel * model,
|
||||||
|
{ model->attack_state = FuzzerAttackStateOff; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fuzzer_view_attack_pause(FuzzerViewAttack* view) {
|
||||||
|
furi_assert(view);
|
||||||
|
|
||||||
|
with_view_model(
|
||||||
|
view->view,
|
||||||
|
FuzzerViewAttackModel * model,
|
||||||
|
{ model->attack_state = FuzzerAttackStateIdle; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fuzzer_view_attack_end(FuzzerViewAttack* view) {
|
||||||
|
furi_assert(view);
|
||||||
|
|
||||||
|
with_view_model(
|
||||||
|
view->view,
|
||||||
|
FuzzerViewAttackModel * model,
|
||||||
|
{ model->attack_state = FuzzerAttackStateEnd; },
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fuzzer_view_attack_set_callback(
|
void fuzzer_view_attack_set_callback(
|
||||||
@ -106,12 +139,15 @@ void fuzzer_view_attack_draw(Canvas* canvas, FuzzerViewAttackModel* model) {
|
|||||||
canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignTop, model->uid);
|
canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignTop, model->uid);
|
||||||
|
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
if(model->attack_enabled) {
|
if(model->attack_state == FuzzerAttackStateRunning) {
|
||||||
elements_button_center(canvas, "Stop");
|
elements_button_center(canvas, "Stop");
|
||||||
} else {
|
} else if(model->attack_state == FuzzerAttackStateIdle) {
|
||||||
elements_button_center(canvas, "Start");
|
elements_button_center(canvas, "Start");
|
||||||
elements_button_left(canvas, "TD -");
|
elements_button_left(canvas, "TD -");
|
||||||
elements_button_right(canvas, "+ TD");
|
elements_button_right(canvas, "+ TD");
|
||||||
|
} else if(model->attack_state == FuzzerAttackStateEnd) {
|
||||||
|
// elements_button_center(canvas, "Restart"); // Reset
|
||||||
|
elements_button_left(canvas, "Exit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +166,8 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
|||||||
view_attack->view,
|
view_attack->view,
|
||||||
FuzzerViewAttackModel * model,
|
FuzzerViewAttackModel * model,
|
||||||
{
|
{
|
||||||
if(!model->attack_enabled) {
|
if(model->attack_state == FuzzerAttackStateIdle) {
|
||||||
|
// TimeDelay
|
||||||
if(event->type == InputTypeShort) {
|
if(event->type == InputTypeShort) {
|
||||||
if(model->time_delay > FUZZ_TIME_DELAY_MIN) {
|
if(model->time_delay > FUZZ_TIME_DELAY_MIN) {
|
||||||
model->time_delay--;
|
model->time_delay--;
|
||||||
@ -142,6 +179,11 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
|||||||
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(
|
||||||
|
(model->attack_state == FuzzerAttackStateEnd) &&
|
||||||
|
(event->type == InputTypeShort)) {
|
||||||
|
// Exit if Ended
|
||||||
|
view_attack->callback(FuzzerCustomEventViewAttackBack, view_attack->context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
@ -151,7 +193,8 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
|||||||
view_attack->view,
|
view_attack->view,
|
||||||
FuzzerViewAttackModel * model,
|
FuzzerViewAttackModel * model,
|
||||||
{
|
{
|
||||||
if(!model->attack_enabled) {
|
if(model->attack_state == FuzzerAttackStateIdle) {
|
||||||
|
// TimeDelay
|
||||||
if(event->type == InputTypeShort) {
|
if(event->type == InputTypeShort) {
|
||||||
if(model->time_delay < FUZZ_TIME_DELAY_MAX) {
|
if(model->time_delay < FUZZ_TIME_DELAY_MAX) {
|
||||||
model->time_delay++;
|
model->time_delay++;
|
||||||
@ -162,6 +205,8 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
|||||||
model->time_delay = FUZZ_TIME_DELAY_MAX;
|
model->time_delay = FUZZ_TIME_DELAY_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Nothing
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
@ -201,7 +246,7 @@ FuzzerViewAttack* fuzzer_view_attack_alloc() {
|
|||||||
{
|
{
|
||||||
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
||||||
model->uid = malloc(ATTACK_SCENE_MAX_UID_LENGTH + 1);
|
model->uid = malloc(ATTACK_SCENE_MAX_UID_LENGTH + 1);
|
||||||
model->attack_enabled = false;
|
model->attack_state = FuzzerAttackStateOff;
|
||||||
|
|
||||||
strcpy(model->uid, "Not_set");
|
strcpy(model->uid, "Not_set");
|
||||||
model->attack_name = "Not_set";
|
model->attack_name = "Not_set";
|
||||||
|
11
applications/external/pacs_fuzzer/views/attack.h
vendored
11
applications/external/pacs_fuzzer/views/attack.h
vendored
@ -1,7 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
|
||||||
#include "../helpers/fuzzer_custom_event.h"
|
#include "../helpers/fuzzer_custom_event.h"
|
||||||
|
#include "../helpers/fuzzer_types.h"
|
||||||
|
|
||||||
#include "../lib/worker/protocol.h"
|
#include "../lib/worker/protocol.h"
|
||||||
|
|
||||||
typedef struct FuzzerViewAttack FuzzerViewAttack;
|
typedef struct FuzzerViewAttack FuzzerViewAttack;
|
||||||
@ -26,6 +29,12 @@ void fuzzer_view_attack_reset_data(
|
|||||||
|
|
||||||
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const FuzzerPayload uid);
|
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const FuzzerPayload uid);
|
||||||
|
|
||||||
void fuzzer_view_attack_set_attack(FuzzerViewAttack* view, bool attack);
|
void fuzzer_view_attack_start(FuzzerViewAttack* view);
|
||||||
|
|
||||||
|
void fuzzer_view_attack_stop(FuzzerViewAttack* view);
|
||||||
|
|
||||||
|
void fuzzer_view_attack_pause(FuzzerViewAttack* view);
|
||||||
|
|
||||||
|
void fuzzer_view_attack_end(FuzzerViewAttack* view);
|
||||||
|
|
||||||
uint8_t fuzzer_view_attack_get_time_delay(FuzzerViewAttack* view);
|
uint8_t fuzzer_view_attack_get_time_delay(FuzzerViewAttack* view);
|
Loading…
Reference in New Issue
Block a user