Fuzzer App: BFCustomerID attack, some fix

This commit is contained in:
gid9798
2023-06-05 21:19:32 +03:00
parent 6a9f396663
commit b346487e76
5 changed files with 53 additions and 19 deletions

View File

@@ -228,10 +228,18 @@ const FuzzerProtocol fuzzer_proto_items[] = {
};
#endif
const char* fuzzer_attack_names[] = {
[FuzzerMainMenuIndexDefaultValues] = "Default Values",
[FuzzerMainMenuIndexLoadFile] = "Load File",
[FuzzerMainMenuIndexLoadFileCustomUids] = "Load UIDs from file",
typedef struct {
const char* menu_label;
FuzzerAttackId attack_id;
} FuzzerMenuItems;
const FuzzerMenuItems fuzzer_menu_items[] = {
{"Default Values", FuzzerAttackIdDefaultValues},
#ifdef RFID_125_PROTOCOL
{"BF Customer ID", FuzzerAttackIdBFCustomerID},
#endif
{"Load File", FuzzerAttackIdLoadFile},
{"Load UIDs from file", FuzzerAttackIdLoadFileCustomUids},
};
const char* fuzzer_proto_get_name(FuzzerProtocolsID index) {
@@ -246,10 +254,14 @@ uint8_t fuzzer_proto_get_max_data_size() {
return MAX_PAYLOAD_SIZE;
}
const char* fuzzer_proto_get_menu_label(FuzzerMainMenuIndex index) {
return fuzzer_attack_names[index];
const char* fuzzer_proto_get_menu_label(uint8_t index) {
return fuzzer_menu_items[index].menu_label;
}
FuzzerAttackId fuzzer_proto_get_attack_id_by_index(uint8_t index) {
return fuzzer_menu_items[index].attack_id;
}
uint8_t fuzzer_proto_get_count_of_menu_items() {
return COUNT_OF(fuzzer_attack_names);
return COUNT_OF(fuzzer_menu_items);
}

View File

@@ -20,10 +20,11 @@ typedef enum {
} FuzzerProtocolsID;
typedef enum {
FuzzerMainMenuIndexDefaultValues = 0,
FuzzerMainMenuIndexLoadFile,
FuzzerMainMenuIndexLoadFileCustomUids,
} FuzzerMainMenuIndex;
FuzzerAttackIdDefaultValues = 0,
FuzzerAttackIdLoadFile,
FuzzerAttackIdLoadFileCustomUids,
FuzzerAttackIdBFCustomerID,
} FuzzerAttackId;
struct FuzzerPayload {
uint8_t* data;
@@ -54,7 +55,14 @@ uint8_t fuzzer_proto_get_count_of_protocols();
* @param index menu index
* @return pointer to a string containing the menu label
*/
const char* fuzzer_proto_get_menu_label(FuzzerMainMenuIndex index);
const char* fuzzer_proto_get_menu_label(uint8_t index);
/**
* Get FuzzerAttackId based on its index
* @param index menu index
* @return FuzzerAttackId
*/
FuzzerAttackId fuzzer_proto_get_attack_id_by_index(uint8_t index);
/**
* Get number of menu items

View File

@@ -77,9 +77,11 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
// TODO error logic
bool loading_ok = false;
uint8_t d_size = fuzzer_proto_get_max_data_size();
uint8_t* uid;
switch(app->fuzzer_state.menu_index) {
case FuzzerMainMenuIndexDefaultValues:
switch(fuzzer_proto_get_attack_id_by_index(app->fuzzer_state.menu_index)) {
case FuzzerAttackIdDefaultValues:
loading_ok =
fuzzer_worker_init_attack_dict(app->worker, app->fuzzer_state.proto_index);
@@ -88,8 +90,20 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
// error
}
break;
case FuzzerAttackIdBFCustomerID:
uid = malloc(d_size);
memset(uid, 0x00, d_size);
case FuzzerMainMenuIndexLoadFile:
loading_ok = fuzzer_worker_init_attack_bf_byte(
app->worker, app->fuzzer_state.proto_index, uid, 0);
free(uid);
if(!loading_ok) {
// error
}
break;
case FuzzerAttackIdLoadFile:
if(!fuzzer_scene_main_load_key(app)) {
break;
} else {
@@ -105,7 +119,7 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) {
}
break;
case FuzzerMainMenuIndexLoadFileCustomUids:
case FuzzerAttackIdLoadFileCustomUids:
if(!fuzzer_scene_main_load_custom_dict(app)) {
break;
} else {

View File

@@ -13,7 +13,7 @@
#### App functionality
- [ ] Add `BFCustomerID` attack
- [x] Add `BFCustomerID` attack
- [ ] Save key logic
## Code Improvement

View File

@@ -75,7 +75,7 @@ void fuzzer_view_main_draw(Canvas* canvas, FuzzerViewMainModel* model) {
canvas_draw_str_aligned(
canvas, 64, 36, AlignCenter, AlignTop, fuzzer_proto_get_menu_label(model->menu_index));
if(model->menu_index < model->menu_max) {
if(model->menu_index < (model->menu_max - 1)) {
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
canvas,