mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
Fuzzer App: fix time_delay
This commit is contained in:
1
applications/external/pacs_fuzzer/fuzzer_i.h
vendored
1
applications/external/pacs_fuzzer/fuzzer_i.h
vendored
@@ -22,7 +22,6 @@
|
|||||||
#include <flipper_format/flipper_format_i.h>
|
#include <flipper_format/flipper_format_i.h>
|
||||||
#include "fuzzer_icons.h"
|
#include "fuzzer_icons.h"
|
||||||
|
|
||||||
#define FUZZ_TIME_DELAY_MIN (5)
|
|
||||||
#define FUZZ_TIME_DELAY_MAX (80)
|
#define FUZZ_TIME_DELAY_MAX (80)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <toolbox/stream/buffered_file_stream.h>
|
#include <toolbox/stream/buffered_file_stream.h>
|
||||||
|
|
||||||
#define TAG "Fuzzer worker"
|
#define TAG "Fuzzer worker"
|
||||||
#define FUZZ_TIME_DELAY_DEFAULT (10)
|
|
||||||
|
|
||||||
#if defined(RFID_125_PROTOCOL)
|
#if defined(RFID_125_PROTOCOL)
|
||||||
|
|
||||||
@@ -39,7 +38,8 @@ struct FuzzerWorker {
|
|||||||
|
|
||||||
const FuzzerProtocol* protocol;
|
const FuzzerProtocol* protocol;
|
||||||
FuzzerWorkerAttackType attack_type;
|
FuzzerWorkerAttackType attack_type;
|
||||||
uint8_t timeer_delay;
|
uint8_t timer_idle_delay;
|
||||||
|
uint8_t timer_emu_delay;
|
||||||
|
|
||||||
uint8_t payload[MAX_PAYLOAD_SIZE];
|
uint8_t payload[MAX_PAYLOAD_SIZE];
|
||||||
Stream* uids_stream;
|
Stream* uids_stream;
|
||||||
@@ -47,6 +47,7 @@ struct FuzzerWorker {
|
|||||||
uint8_t chusen_byte;
|
uint8_t chusen_byte;
|
||||||
|
|
||||||
bool treead_running;
|
bool treead_running;
|
||||||
|
bool in_emu_phase;
|
||||||
FuriTimer* timer;
|
FuriTimer* timer;
|
||||||
|
|
||||||
FuzzerWorkerUidChagedCallback tick_callback;
|
FuzzerWorkerUidChagedCallback tick_callback;
|
||||||
@@ -147,6 +148,7 @@ static void fuzzer_worker_on_tick_callback(void* context) {
|
|||||||
|
|
||||||
FuzzerWorker* instance = context;
|
FuzzerWorker* instance = context;
|
||||||
|
|
||||||
|
if(instance->in_emu_phase) {
|
||||||
if(instance->treead_running) {
|
if(instance->treead_running) {
|
||||||
#if defined(RFID_125_PROTOCOL)
|
#if defined(RFID_125_PROTOCOL)
|
||||||
lfrfid_worker_stop(instance->proto_worker);
|
lfrfid_worker_stop(instance->proto_worker);
|
||||||
@@ -154,7 +156,9 @@ static void fuzzer_worker_on_tick_callback(void* context) {
|
|||||||
ibutton_worker_stop(instance->proto_worker);
|
ibutton_worker_stop(instance->proto_worker);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
instance->in_emu_phase = false;
|
||||||
|
furi_timer_start(instance->timer, furi_ms_to_ticks(instance->timer_idle_delay * 100));
|
||||||
|
} else {
|
||||||
if(!fuzzer_worker_load_key(instance, true)) {
|
if(!fuzzer_worker_load_key(instance, true)) {
|
||||||
fuzzer_worker_pause(instance); // XXX
|
fuzzer_worker_pause(instance); // XXX
|
||||||
if(instance->end_callback) {
|
if(instance->end_callback) {
|
||||||
@@ -168,10 +172,13 @@ static void fuzzer_worker_on_tick_callback(void* context) {
|
|||||||
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
instance->in_emu_phase = true;
|
||||||
|
furi_timer_start(instance->timer, furi_ms_to_ticks(instance->timer_emu_delay * 100));
|
||||||
if(instance->tick_callback) {
|
if(instance->tick_callback) {
|
||||||
instance->tick_callback(instance->tick_context);
|
instance->tick_callback(instance->tick_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fuzzer_worker_get_current_key(FuzzerWorker* instance, FuzzerPayload* output_key) {
|
void fuzzer_worker_get_current_key(FuzzerWorker* instance, FuzzerPayload* output_key) {
|
||||||
@@ -338,13 +345,15 @@ FuzzerWorker* fuzzer_worker_alloc() {
|
|||||||
instance->attack_type = FuzzerWorkerAttackTypeMax;
|
instance->attack_type = FuzzerWorkerAttackTypeMax;
|
||||||
instance->index = 0;
|
instance->index = 0;
|
||||||
instance->treead_running = false;
|
instance->treead_running = false;
|
||||||
|
instance->in_emu_phase = false;
|
||||||
|
|
||||||
memset(instance->payload, 0x00, sizeof(instance->payload));
|
memset(instance->payload, 0x00, sizeof(instance->payload));
|
||||||
|
|
||||||
instance->timeer_delay = FUZZ_TIME_DELAY_DEFAULT;
|
instance->timer_idle_delay = PROTOCOL_MIN_IDLE_DELAY;
|
||||||
|
instance->timer_emu_delay = PROTOCOL_MIN_IDLE_DELAY;
|
||||||
|
|
||||||
instance->timer =
|
instance->timer =
|
||||||
furi_timer_alloc(fuzzer_worker_on_tick_callback, FuriTimerTypePeriodic, instance);
|
furi_timer_alloc(fuzzer_worker_on_tick_callback, FuriTimerTypeOnce, instance);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@@ -374,9 +383,15 @@ bool fuzzer_worker_start(FuzzerWorker* instance, uint8_t timer_dellay) {
|
|||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
if(instance->attack_type < FuzzerWorkerAttackTypeMax) {
|
if(instance->attack_type < FuzzerWorkerAttackTypeMax) {
|
||||||
instance->timeer_delay = timer_dellay;
|
uint8_t temp = timer_dellay / 2;
|
||||||
|
instance->timer_emu_delay = temp;
|
||||||
|
instance->timer_idle_delay = temp + timer_dellay % 2;
|
||||||
|
|
||||||
furi_timer_start(instance->timer, furi_ms_to_ticks(timer_dellay * 100));
|
FURI_LOG_D(
|
||||||
|
TAG,
|
||||||
|
"Emu_delay %u Idle_delay %u",
|
||||||
|
instance->timer_emu_delay,
|
||||||
|
instance->timer_idle_delay);
|
||||||
|
|
||||||
if(!instance->treead_running) {
|
if(!instance->treead_running) {
|
||||||
#if defined(RFID_125_PROTOCOL)
|
#if defined(RFID_125_PROTOCOL)
|
||||||
@@ -397,6 +412,8 @@ bool fuzzer_worker_start(FuzzerWorker* instance, uint8_t timer_dellay) {
|
|||||||
// ibutton_worker_start_thread(instance->proto_worker);
|
// ibutton_worker_start_thread(instance->proto_worker);
|
||||||
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
||||||
#endif
|
#endif
|
||||||
|
instance->in_emu_phase = true;
|
||||||
|
furi_timer_start(instance->timer, furi_ms_to_ticks(instance->timer_emu_delay * 100));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -254,6 +254,10 @@ uint8_t fuzzer_proto_get_max_data_size() {
|
|||||||
return MAX_PAYLOAD_SIZE;
|
return MAX_PAYLOAD_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t fuzzer_proto_get_min_delay() {
|
||||||
|
return PROTOCOL_TIME_DELAY_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
const char* fuzzer_proto_get_menu_label(uint8_t index) {
|
const char* fuzzer_proto_get_menu_label(uint8_t index) {
|
||||||
return fuzzer_menu_items[index].menu_label;
|
return fuzzer_menu_items[index].menu_label;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ struct FuzzerPayload {
|
|||||||
*/
|
*/
|
||||||
uint8_t fuzzer_proto_get_max_data_size();
|
uint8_t fuzzer_proto_get_max_data_size();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get minimum time delay for protocols
|
||||||
|
* @return Minimum time delay
|
||||||
|
*/
|
||||||
|
uint8_t fuzzer_proto_get_min_delay();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get protocol name based on its index
|
* Get protocol name based on its index
|
||||||
* @param index protocol index
|
* @param index protocol index
|
||||||
|
|||||||
@@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
#if defined(RFID_125_PROTOCOL)
|
#if defined(RFID_125_PROTOCOL)
|
||||||
#define MAX_PAYLOAD_SIZE (6)
|
#define MAX_PAYLOAD_SIZE (6)
|
||||||
|
#define PROTOCOL_MIN_IDLE_DELAY (5)
|
||||||
|
#define PROTOCOL_TIME_DELAY_MIN PROTOCOL_MIN_IDLE_DELAY + 4
|
||||||
#else
|
#else
|
||||||
#define MAX_PAYLOAD_SIZE (8)
|
#define MAX_PAYLOAD_SIZE (8)
|
||||||
|
#define PROTOCOL_MIN_IDLE_DELAY (2)
|
||||||
|
#define PROTOCOL_TIME_DELAY_MIN PROTOCOL_MIN_IDLE_DELAY + 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ProtoDict ProtoDict;
|
typedef struct ProtoDict ProtoDict;
|
||||||
|
|||||||
10
applications/external/pacs_fuzzer/views/attack.c
vendored
10
applications/external/pacs_fuzzer/views/attack.c
vendored
@@ -15,6 +15,7 @@ struct FuzzerViewAttack {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t time_delay;
|
uint8_t time_delay;
|
||||||
|
uint8_t time_delay_min;
|
||||||
const char* attack_name;
|
const char* attack_name;
|
||||||
const char* protocol_name;
|
const char* protocol_name;
|
||||||
FuzzerAttackState attack_state;
|
FuzzerAttackState attack_state;
|
||||||
@@ -157,14 +158,14 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
|||||||
if(model->attack_state == FuzzerAttackStateIdle) {
|
if(model->attack_state == FuzzerAttackStateIdle) {
|
||||||
// TimeDelay
|
// TimeDelay
|
||||||
if(event->type == InputTypeShort) {
|
if(event->type == InputTypeShort) {
|
||||||
if(model->time_delay > FUZZ_TIME_DELAY_MIN) {
|
if(model->time_delay > model->time_delay_min) {
|
||||||
model->time_delay--;
|
model->time_delay--;
|
||||||
}
|
}
|
||||||
} else if(event->type == InputTypeLong) {
|
} else if(event->type == InputTypeLong) {
|
||||||
if((model->time_delay - 10) >= FUZZ_TIME_DELAY_MIN) {
|
if((model->time_delay - 10) >= model->time_delay_min) {
|
||||||
model->time_delay -= 10;
|
model->time_delay -= 10;
|
||||||
} else {
|
} else {
|
||||||
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
model->time_delay = model->time_delay_min;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(
|
} else if(
|
||||||
@@ -232,7 +233,8 @@ FuzzerViewAttack* fuzzer_view_attack_alloc() {
|
|||||||
view_attack->view,
|
view_attack->view,
|
||||||
FuzzerViewAttackModel * model,
|
FuzzerViewAttackModel * model,
|
||||||
{
|
{
|
||||||
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
model->time_delay_min = fuzzer_proto_get_min_delay();
|
||||||
|
model->time_delay = model->time_delay_min;
|
||||||
model->uid_str = furi_string_alloc_set_str("Not_set");
|
model->uid_str = furi_string_alloc_set_str("Not_set");
|
||||||
// malloc(ATTACK_SCENE_MAX_UID_LENGTH + 1);
|
// malloc(ATTACK_SCENE_MAX_UID_LENGTH + 1);
|
||||||
model->attack_state = FuzzerAttackStateOff;
|
model->attack_state = FuzzerAttackStateOff;
|
||||||
|
|||||||
Reference in New Issue
Block a user