Skip to content

Commit

Permalink
some fixes, trying to speed up bruteforce(unsuccessful)
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Sep 26, 2022
1 parent 5e30b14 commit 61fee8e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
27 changes: 14 additions & 13 deletions applications/plugins/subbrute/helpers/subbrute_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct SubBruteWorker {
#define SUBBRUTE_TXRX_WORKER_BUF_SIZE 2048
#define SUBBRUTE_TXRX_WORKER_MAX_TXRX_SIZE 60
#define SUBBRUTE_TXRX_WORKER_TIMEOUT_READ_WRITE_BUF 40
#define SUBBRUTE_TX_TIMEOUT 50
#define SUBBRUTE_TX_TIMEOUT 1
#define SUBBRUTE_SEND_DELAY 260

/**
Expand All @@ -52,7 +52,7 @@ int32_t subbrute_worker_thread(void* context) {
FURI_LOG_I(TAG, "Worker start");
#endif

instance->environment = subghz_environment_alloc();
//instance->environment = subghz_environment_alloc();
instance->transmitter = subghz_transmitter_alloc_init(
instance->environment, string_get_cstr(instance->protocol_name));

Expand All @@ -64,7 +64,7 @@ int32_t subbrute_worker_thread(void* context) {
furi_hal_gpio_write(&gpio_cc1101_g0, true);

// Set ready to transmit value
instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY;
//instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY;

while(instance->worker_running) {
// Transmit
Expand All @@ -80,8 +80,8 @@ int32_t subbrute_worker_thread(void* context) {

subghz_transmitter_free(instance->transmitter);
instance->transmitter = NULL;
subghz_environment_free(instance->environment);
instance->environment = NULL;
/*subghz_environment_free(instance->environment);
instance->environment = NULL;*/

#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Worker stop");
Expand Down Expand Up @@ -117,10 +117,10 @@ void subbrute_worker_free(SubBruteWorker* instance) {
instance->transmitter = NULL;
}

if(instance->environment != NULL) {
/*if(instance->environment != NULL) {
subghz_environment_free(instance->environment);
instance->environment = NULL;
}
}*/

furi_thread_free(instance->thread);
flipper_format_free(instance->flipper_format);
Expand Down Expand Up @@ -190,9 +190,10 @@ bool subbrute_worker_is_running(SubBruteWorker* instance) {
}

bool subbrute_worker_can_transmit(SubBruteWorker* instance) {
furi_assert(instance);

return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
UNUSED(instance);
return true;
//furi_assert(instance);
//return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
}

bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) {
Expand Down Expand Up @@ -276,7 +277,7 @@ bool subbrute_worker_init_manual_transmit(
FURI_LOG_I(TAG, "Frequency: %d", frequency);
#endif

instance->environment = subghz_environment_alloc();
//instance->environment = subghz_environment_alloc();
instance->transmitter = subghz_transmitter_alloc_init(
instance->environment, string_get_cstr(instance->protocol_name));

Expand Down Expand Up @@ -310,8 +311,8 @@ void subbrute_worker_manual_transmit_stop(SubBruteWorker* instance) {
subghz_transmitter_free(instance->transmitter);
instance->transmitter = NULL;
}
subghz_environment_free(instance->environment);
instance->environment = NULL;
/*subghz_environment_free(instance->environment);
instance->environment = NULL;*/

instance->is_manual_init = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void subbrute_scene_run_attack_on_enter(void* context) {
instance->device->frequency,
instance->device->preset,
string_get_cstr(instance->device->protocol_name));

notification_message(instance->notifications, &sequence_blink_start_magenta);
}

bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -57,12 +59,13 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
} else if(event.type == SceneManagerEventTypeTick) {
if(subbrute_worker_can_transmit(instance->worker)) {
// Blink
notification_message(instance->notifications, &sequence_blink_yellow_100);

if(subbrute_worker_manual_transmit(instance->worker, instance->device->payload)) {
// Make payload for new iteration or exit
if(instance->device->key_index + 1 > instance->device->max_value) {
// End of list
notification_message(instance->notifications, &sequence_single_vibro);
notification_message(instance->notifications, &sequence_blink_stop);
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
} else {
instance->device->key_index++;
Expand All @@ -73,7 +76,6 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
}

// Stop
notification_message(instance->notifications, &sequence_blink_stop);
}

consumed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
}
subbrute_attack_view_set_current_step(view, instance->device->key_index);
} else if(event.event == SubBruteCustomEventTypeChangeStepUpMore) {
// +100
uint64_t value = instance->device->key_index + 100;
// +50
uint64_t value = instance->device->key_index + 50;
if(value == instance->device->max_value) {
instance->device->key_index += value;
} else {
Expand All @@ -118,8 +118,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
}
subbrute_attack_view_set_current_step(view, instance->device->key_index);
} else if(event.event == SubBruteCustomEventTypeChangeStepDownMore) {
// -100
uint64_t value = ((instance->device->key_index - 100) + instance->device->max_value);
// -50
uint64_t value = ((instance->device->key_index - 50) + instance->device->max_value);
if(value == instance->device->max_value) {
instance->device->key_index = value;
} else {
Expand All @@ -129,7 +129,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
} else if(event.event == SubBruteCustomEventTypeTransmitCustom) {
if(subbrute_worker_can_transmit(instance->worker)) {
// Blink
notification_message(instance->notifications, &sequence_blink_green_100);
notification_message(instance->notifications, &sequence_blink_magenta_10);

// if(!subbrute_attack_view_is_worker_running(view)) {
// subbrute_attack_view_start_worker(
Expand Down
10 changes: 5 additions & 5 deletions applications/plugins/subbrute/subbrute.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ SubBruteState* subbrute_alloc() {
void subbrute_free(SubBruteState* instance) {
furi_assert(instance);

// SubBruteDevice
// SubBruteWorker
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free SubBruteDevice");
#endif
subbrute_device_free(instance->device);
subbrute_worker_stop(instance->worker);
subbrute_worker_free(instance->worker);

// SubBruteWorker
// SubBruteDevice
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free SubBruteDevice");
#endif
subbrute_worker_stop(instance->worker);
subbrute_worker_free(instance->worker);
subbrute_device_free(instance->device);

// Notifications
#ifdef FURI_DEBUG
Expand Down
14 changes: 8 additions & 6 deletions applications/plugins/subbrute/subbrute_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ SubBruteDevice* subbrute_device_alloc() {
instance->receiver = NULL;
instance->environment = NULL;

instance->environment = subghz_environment_alloc();

subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit307);

return instance;
Expand Down Expand Up @@ -337,7 +339,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
}

// For non-file types we didn't set SubGhzProtocolDecoderBase
instance->environment = subghz_environment_alloc();
//instance->environment = subghz_environment_alloc();
instance->receiver = subghz_receiver_alloc_init(instance->environment);
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
furi_hal_subghz_reset();
Expand All @@ -359,10 +361,10 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
protocol_check_result = SubBruteFileResultOk;
}

subghz_environment_free(instance->environment);
//subghz_environment_free(instance->environment);
subghz_receiver_free(instance->receiver);
instance->receiver = NULL;
instance->environment = NULL;
//instance->environment = NULL;

if(protocol_check_result != SubBruteFileResultOk) {
return SubBruteFileResultProtocolNotFound;
Expand Down Expand Up @@ -426,7 +428,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
string_init(temp_str);
uint32_t temp_data32;

instance->environment = subghz_environment_alloc();
//instance->environment = subghz_environment_alloc();
instance->receiver = subghz_receiver_alloc_init(instance->environment);
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
furi_hal_subghz_reset();
Expand Down Expand Up @@ -561,12 +563,12 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);

subghz_environment_free(instance->environment);
//subghz_environment_free(instance->environment);
subghz_receiver_free(instance->receiver);

instance->decoder_result = NULL;
instance->receiver = NULL;
instance->environment = NULL;
//instance->environment = NULL;

if(result == SubBruteFileResultOk) {
#ifdef FURI_DEBUG
Expand Down
8 changes: 4 additions & 4 deletions applications/plugins/subbrute/views/subbrute_main_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
if(m->index == position) {
canvas_draw_str_aligned(
canvas,
64,
4,
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
AlignCenter,
AlignLeft,
AlignCenter,
str);
elements_frame(
canvas, 1, 1 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, 124, 15);
} else {
canvas_draw_str_aligned(
canvas,
64,
4,
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
AlignCenter,
AlignLeft,
AlignCenter,
str);
}
Expand Down

0 comments on commit 61fee8e

Please sign in to comment.