mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-19 03:11:52 +03:00
Fuzzer App: fix time_delay
This commit is contained in:
parent
a063858842
commit
d2b0aa8513
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 "fuzzer_icons.h"
|
||||
|
||||
#define FUZZ_TIME_DELAY_MIN (5)
|
||||
#define FUZZ_TIME_DELAY_MAX (80)
|
||||
|
||||
typedef struct {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <toolbox/stream/buffered_file_stream.h>
|
||||
|
||||
#define TAG "Fuzzer worker"
|
||||
#define FUZZ_TIME_DELAY_DEFAULT (10)
|
||||
|
||||
#if defined(RFID_125_PROTOCOL)
|
||||
|
||||
@ -39,7 +38,8 @@ struct FuzzerWorker {
|
||||
|
||||
const FuzzerProtocol* protocol;
|
||||
FuzzerWorkerAttackType attack_type;
|
||||
uint8_t timeer_delay;
|
||||
uint8_t timer_idle_delay;
|
||||
uint8_t timer_emu_delay;
|
||||
|
||||
uint8_t payload[MAX_PAYLOAD_SIZE];
|
||||
Stream* uids_stream;
|
||||
@ -47,6 +47,7 @@ struct FuzzerWorker {
|
||||
uint8_t chusen_byte;
|
||||
|
||||
bool treead_running;
|
||||
bool in_emu_phase;
|
||||
FuriTimer* timer;
|
||||
|
||||
FuzzerWorkerUidChagedCallback tick_callback;
|
||||
@ -147,29 +148,35 @@ static void fuzzer_worker_on_tick_callback(void* context) {
|
||||
|
||||
FuzzerWorker* instance = context;
|
||||
|
||||
if(instance->treead_running) {
|
||||
#if defined(RFID_125_PROTOCOL)
|
||||
lfrfid_worker_stop(instance->proto_worker);
|
||||
#else
|
||||
ibutton_worker_stop(instance->proto_worker);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(!fuzzer_worker_load_key(instance, true)) {
|
||||
fuzzer_worker_pause(instance); // XXX
|
||||
if(instance->end_callback) {
|
||||
instance->end_callback(instance->end_context);
|
||||
}
|
||||
} else {
|
||||
if(instance->in_emu_phase) {
|
||||
if(instance->treead_running) {
|
||||
#if defined(RFID_125_PROTOCOL)
|
||||
lfrfid_worker_emulate_start(instance->proto_worker, instance->protocol_id);
|
||||
lfrfid_worker_stop(instance->proto_worker);
|
||||
#else
|
||||
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
||||
ibutton_worker_stop(instance->proto_worker);
|
||||
#endif
|
||||
}
|
||||
if(instance->tick_callback) {
|
||||
instance->tick_callback(instance->tick_context);
|
||||
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)) {
|
||||
fuzzer_worker_pause(instance); // XXX
|
||||
if(instance->end_callback) {
|
||||
instance->end_callback(instance->end_context);
|
||||
}
|
||||
} else {
|
||||
if(instance->treead_running) {
|
||||
#if defined(RFID_125_PROTOCOL)
|
||||
lfrfid_worker_emulate_start(instance->proto_worker, instance->protocol_id);
|
||||
#else
|
||||
ibutton_worker_emulate_start(instance->proto_worker, instance->key);
|
||||
#endif
|
||||
}
|
||||
instance->in_emu_phase = true;
|
||||
furi_timer_start(instance->timer, furi_ms_to_ticks(instance->timer_emu_delay * 100));
|
||||
if(instance->tick_callback) {
|
||||
instance->tick_callback(instance->tick_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,13 +345,15 @@ FuzzerWorker* fuzzer_worker_alloc() {
|
||||
instance->attack_type = FuzzerWorkerAttackTypeMax;
|
||||
instance->index = 0;
|
||||
instance->treead_running = false;
|
||||
instance->in_emu_phase = false;
|
||||
|
||||
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 =
|
||||
furi_timer_alloc(fuzzer_worker_on_tick_callback, FuriTimerTypePeriodic, instance);
|
||||
furi_timer_alloc(fuzzer_worker_on_tick_callback, FuriTimerTypeOnce, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
@ -374,9 +383,15 @@ bool fuzzer_worker_start(FuzzerWorker* instance, uint8_t timer_dellay) {
|
||||
furi_assert(instance);
|
||||
|
||||
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 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_emulate_start(instance->proto_worker, instance->key);
|
||||
#endif
|
||||
instance->in_emu_phase = true;
|
||||
furi_timer_start(instance->timer, furi_ms_to_ticks(instance->timer_emu_delay * 100));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -254,6 +254,10 @@ uint8_t fuzzer_proto_get_max_data_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) {
|
||||
return fuzzer_menu_items[index].menu_label;
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ struct FuzzerPayload {
|
||||
*/
|
||||
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
|
||||
* @param index protocol index
|
||||
|
@ -4,8 +4,12 @@
|
||||
|
||||
#if defined(RFID_125_PROTOCOL)
|
||||
#define MAX_PAYLOAD_SIZE (6)
|
||||
#define PROTOCOL_MIN_IDLE_DELAY (5)
|
||||
#define PROTOCOL_TIME_DELAY_MIN PROTOCOL_MIN_IDLE_DELAY + 4
|
||||
#else
|
||||
#define MAX_PAYLOAD_SIZE (8)
|
||||
#define PROTOCOL_MIN_IDLE_DELAY (2)
|
||||
#define PROTOCOL_TIME_DELAY_MIN PROTOCOL_MIN_IDLE_DELAY + 2
|
||||
#endif
|
||||
|
||||
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 {
|
||||
uint8_t time_delay;
|
||||
uint8_t time_delay_min;
|
||||
const char* attack_name;
|
||||
const char* protocol_name;
|
||||
FuzzerAttackState attack_state;
|
||||
@ -157,14 +158,14 @@ bool fuzzer_view_attack_input(InputEvent* event, void* context) {
|
||||
if(model->attack_state == FuzzerAttackStateIdle) {
|
||||
// TimeDelay
|
||||
if(event->type == InputTypeShort) {
|
||||
if(model->time_delay > FUZZ_TIME_DELAY_MIN) {
|
||||
if(model->time_delay > model->time_delay_min) {
|
||||
model->time_delay--;
|
||||
}
|
||||
} 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;
|
||||
} else {
|
||||
model->time_delay = FUZZ_TIME_DELAY_MIN;
|
||||
model->time_delay = model->time_delay_min;
|
||||
}
|
||||
}
|
||||
} else if(
|
||||
@ -232,7 +233,8 @@ FuzzerViewAttack* fuzzer_view_attack_alloc() {
|
||||
view_attack->view,
|
||||
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");
|
||||
// malloc(ATTACK_SCENE_MAX_UID_LENGTH + 1);
|
||||
model->attack_state = FuzzerAttackStateOff;
|
||||
|
Loading…
Reference in New Issue
Block a user