mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
Fuzzer App: Some Improvement
This commit is contained in:
37
applications/external/pacs_fuzzer/views/attack.c
vendored
37
applications/external/pacs_fuzzer/views/attack.c
vendored
@@ -5,6 +5,7 @@
|
||||
#include <gui/elements.h>
|
||||
|
||||
#define ATTACK_SCENE_MAX_UID_LENGTH 25
|
||||
#define UID_MAX_DISPLAYED_LEN (8U)
|
||||
|
||||
struct FuzzerViewAttack {
|
||||
View* view;
|
||||
@@ -18,14 +19,12 @@ typedef struct {
|
||||
const char* protocol_name;
|
||||
bool attack_enabled;
|
||||
char* uid;
|
||||
uint8_t uid_size;
|
||||
} FuzzerViewAttackModel;
|
||||
|
||||
void fuzzer_view_attack_reset_data(
|
||||
FuzzerViewAttack* view,
|
||||
const char* attack_name,
|
||||
const char* protocol_name,
|
||||
uint8_t uid_size) {
|
||||
const char* protocol_name) {
|
||||
furi_assert(view);
|
||||
|
||||
with_view_model(
|
||||
@@ -35,32 +34,38 @@ void fuzzer_view_attack_reset_data(
|
||||
model->attack_name = attack_name;
|
||||
model->protocol_name = protocol_name;
|
||||
model->attack_enabled = false;
|
||||
model->uid_size = uid_size;
|
||||
strcpy(model->uid, "Not_set");
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const uint8_t* uid) {
|
||||
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const FuzzerPayload uid) {
|
||||
furi_assert(view);
|
||||
|
||||
// TODO fix it
|
||||
uint8_t* data = malloc(uid.data_size);
|
||||
memcpy(data, uid.data, uid.data_size);
|
||||
|
||||
with_view_model(
|
||||
view->view,
|
||||
FuzzerViewAttackModel * model,
|
||||
{
|
||||
snprintf(
|
||||
model->uid,
|
||||
model->uid_size * 3,
|
||||
uid.data_size * 3,
|
||||
"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
uid[0],
|
||||
uid[1],
|
||||
uid[2],
|
||||
uid[3],
|
||||
uid[4],
|
||||
uid[5],
|
||||
uid[6],
|
||||
uid[7]);
|
||||
data[0],
|
||||
data[1],
|
||||
data[2],
|
||||
data[3],
|
||||
data[4],
|
||||
data[5],
|
||||
data[6],
|
||||
data[7]);
|
||||
},
|
||||
true);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void fuzzer_view_attack_set_attack(FuzzerViewAttack* view, bool attack) {
|
||||
@@ -175,6 +180,10 @@ void fuzzer_view_attack_exit(void* context) {
|
||||
}
|
||||
|
||||
FuzzerViewAttack* fuzzer_view_attack_alloc() {
|
||||
if(fuzzer_proto_get_max_data_size() > UID_MAX_DISPLAYED_LEN) {
|
||||
furi_crash("Maximum of displayed bytes exceeded");
|
||||
}
|
||||
|
||||
FuzzerViewAttack* view_attack = malloc(sizeof(FuzzerViewAttack));
|
||||
|
||||
// View allocation and configuration
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <gui/view.h>
|
||||
#include "../helpers/fuzzer_custom_event.h"
|
||||
#include "../lib/worker/protocol.h"
|
||||
|
||||
typedef struct FuzzerViewAttack FuzzerViewAttack;
|
||||
|
||||
@@ -21,10 +22,9 @@ View* fuzzer_view_attack_get_view(FuzzerViewAttack* view_attack);
|
||||
void fuzzer_view_attack_reset_data(
|
||||
FuzzerViewAttack* view,
|
||||
const char* attack_name,
|
||||
const char* protocol_name,
|
||||
uint8_t uid_size);
|
||||
const char* protocol_name);
|
||||
|
||||
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const uint8_t* uid);
|
||||
void fuzzer_view_attack_set_uid(FuzzerViewAttack* view, const FuzzerPayload uid);
|
||||
|
||||
void fuzzer_view_attack_set_attack(FuzzerViewAttack* view, bool attack);
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#define UID_STR_LENGTH 25
|
||||
#define EDITOR_STRING_Y 50
|
||||
|
||||
#define UID_MAX_SIZE 8 // TODO
|
||||
|
||||
struct FuzzerViewFieldEditor {
|
||||
View* view;
|
||||
FuzzerViewFieldEditorCallback callback;
|
||||
@@ -39,18 +37,17 @@ void fuzzer_view_field_editor_set_callback(
|
||||
|
||||
void fuzzer_view_field_editor_reset_data(
|
||||
FuzzerViewFieldEditor* view_edit,
|
||||
uint8_t* uid,
|
||||
uint8_t uid_size) {
|
||||
const FuzzerPayload new_uid) {
|
||||
furi_assert(view_edit);
|
||||
|
||||
with_view_model(
|
||||
view_edit->view,
|
||||
FuzzerViewFieldEditorModel * model,
|
||||
{
|
||||
memcpy(model->uid, uid, uid_size);
|
||||
memcpy(model->uid, new_uid.data, new_uid.data_size);
|
||||
model->index = 0;
|
||||
model->lo = false;
|
||||
model->uid_size = uid_size;
|
||||
model->uid_size = new_uid.data_size;
|
||||
},
|
||||
true);
|
||||
}
|
||||
@@ -260,8 +257,7 @@ FuzzerViewFieldEditor* fuzzer_view_field_editor_alloc() {
|
||||
FuzzerViewFieldEditorModel * model,
|
||||
{
|
||||
model->uid_str = furi_string_alloc();
|
||||
|
||||
model->uid = malloc(UID_MAX_SIZE);
|
||||
model->uid = malloc(fuzzer_proto_get_max_data_size());
|
||||
},
|
||||
true);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <gui/view.h>
|
||||
#include "../helpers/fuzzer_custom_event.h"
|
||||
#include "../lib/worker/protocol.h"
|
||||
|
||||
typedef struct FuzzerViewFieldEditor FuzzerViewFieldEditor;
|
||||
|
||||
@@ -20,9 +21,9 @@ View* fuzzer_view_field_editor_get_view(FuzzerViewFieldEditor* view_attack);
|
||||
|
||||
void fuzzer_view_field_editor_reset_data(
|
||||
FuzzerViewFieldEditor* view_edit,
|
||||
uint8_t* uid,
|
||||
uint8_t uid_size);
|
||||
const FuzzerPayload new_uid);
|
||||
|
||||
// TODO
|
||||
const uint8_t* fuzzer_view_field_editor_get_uid(FuzzerViewFieldEditor* view_edit);
|
||||
|
||||
uint8_t fuzzer_view_field_editor_get_index(FuzzerViewFieldEditor* view_edit);
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <input/input.h>
|
||||
|
||||
#include "../helpers/gui_const.h"
|
||||
#include "../lib/worker/protocol.h"
|
||||
|
||||
struct FuzzerViewMain {
|
||||
View* view;
|
||||
@@ -15,6 +15,8 @@ struct FuzzerViewMain {
|
||||
typedef struct {
|
||||
uint8_t proto_index;
|
||||
uint8_t menu_index;
|
||||
uint8_t proto_max;
|
||||
uint8_t menu_max;
|
||||
} FuzzerViewMainModel;
|
||||
|
||||
void fuzzer_view_main_update_data(FuzzerViewMain* view, FuzzerState state) {
|
||||
@@ -58,23 +60,33 @@ void fuzzer_view_main_draw(Canvas* canvas, FuzzerViewMainModel* model) {
|
||||
if(model->menu_index > 0) {
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 24, AlignCenter, AlignTop, fuzzer_attack_names[model->menu_index - 1]);
|
||||
canvas,
|
||||
64,
|
||||
24,
|
||||
AlignCenter,
|
||||
AlignTop,
|
||||
fuzzer_proto_get_menu_label(model->menu_index - 1));
|
||||
}
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 36, AlignCenter, AlignTop, fuzzer_attack_names[model->menu_index]);
|
||||
canvas, 64, 36, AlignCenter, AlignTop, fuzzer_proto_get_menu_label(model->menu_index));
|
||||
|
||||
if(model->menu_index < FuzzerMainMenuIndexMax) {
|
||||
if(model->menu_index < model->menu_max) {
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 48, AlignCenter, AlignTop, fuzzer_attack_names[model->menu_index + 1]);
|
||||
canvas,
|
||||
64,
|
||||
48,
|
||||
AlignCenter,
|
||||
AlignTop,
|
||||
fuzzer_proto_get_menu_label(model->menu_index + 1));
|
||||
}
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 27, 4, AlignCenter, AlignTop, "<");
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 4, AlignCenter, AlignTop, fuzzer_proto_items[model->proto_index].name);
|
||||
canvas, 64, 4, AlignCenter, AlignTop, fuzzer_proto_get_name(model->proto_index));
|
||||
canvas_draw_str_aligned(canvas, 101, 4, AlignCenter, AlignTop, ">");
|
||||
}
|
||||
|
||||
@@ -94,7 +106,7 @@ bool fuzzer_view_main_input(InputEvent* event, void* context) {
|
||||
view->view,
|
||||
FuzzerViewMainModel * model,
|
||||
{
|
||||
if(model->menu_index < (FuzzerMainMenuIndexMax - 1)) {
|
||||
if(model->menu_index < (model->menu_max - 1)) {
|
||||
model->menu_index++;
|
||||
}
|
||||
},
|
||||
@@ -119,7 +131,7 @@ bool fuzzer_view_main_input(InputEvent* event, void* context) {
|
||||
if(model->proto_index != 0) {
|
||||
model->proto_index--;
|
||||
} else {
|
||||
model->proto_index = (FuzzerProtoMax - 1);
|
||||
model->proto_index = (model->proto_max - 1);
|
||||
}
|
||||
},
|
||||
true);
|
||||
@@ -129,7 +141,7 @@ bool fuzzer_view_main_input(InputEvent* event, void* context) {
|
||||
view->view,
|
||||
FuzzerViewMainModel * model,
|
||||
{
|
||||
if(model->proto_index == (FuzzerProtoMax - 1)) {
|
||||
if(model->proto_index == (model->proto_max - 1)) {
|
||||
model->proto_index = 0;
|
||||
} else {
|
||||
model->proto_index++;
|
||||
@@ -167,7 +179,9 @@ FuzzerViewMain* fuzzer_view_main_alloc() {
|
||||
FuzzerViewMainModel * model,
|
||||
{
|
||||
model->proto_index = 0;
|
||||
model->proto_max = fuzzer_proto_get_count_of_protocols();
|
||||
model->menu_index = 0;
|
||||
model->menu_max = fuzzer_proto_get_count_of_menu_items();
|
||||
},
|
||||
true);
|
||||
return view;
|
||||
|
||||
Reference in New Issue
Block a user