Revert "some fixes, trying to speed up bruteforce(unsuccessful)"

This reverts commit 61fee8e269.
This commit is contained in:
MX 2022-09-26 06:24:47 +03:00
parent 60242cd7c4
commit 069dd29f08
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
6 changed files with 36 additions and 41 deletions

View file

@ -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 1
#define SUBBRUTE_TX_TIMEOUT 50
#define SUBBRUTE_SEND_DELAY 260
/**
@ -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));
@ -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
@ -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");
@ -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);
@ -190,10 +190,9 @@ bool subbrute_worker_is_running(SubBruteWorker* instance) {
}
bool subbrute_worker_can_transmit(SubBruteWorker* instance) {
UNUSED(instance);
return true;
//furi_assert(instance);
//return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
furi_assert(instance);
return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
}
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) {
@ -277,7 +276,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));
@ -311,8 +310,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;
}

View file

@ -39,8 +39,6 @@ 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) {
@ -59,13 +57,12 @@ 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++;
@ -76,6 +73,7 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
}
// Stop
notification_message(instance->notifications, &sequence_blink_stop);
}
consumed = true;

View file

@ -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) {
// +50
uint64_t value = instance->device->key_index + 50;
// +100
uint64_t value = instance->device->key_index + 100;
if(value == instance->device->max_value) {
instance->device->key_index += value;
} else {
@ -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) {
// -50
uint64_t value = ((instance->device->key_index - 50) + instance->device->max_value);
// -100
uint64_t value = ((instance->device->key_index - 100) + instance->device->max_value);
if(value == instance->device->max_value) {
instance->device->key_index = value;
} else {
@ -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_magenta_10);
notification_message(instance->notifications, &sequence_blink_green_100);
// if(!subbrute_attack_view_is_worker_running(view)) {
// subbrute_attack_view_start_worker(

View file

@ -142,6 +142,12 @@ SubBruteState* subbrute_alloc() {
void subbrute_free(SubBruteState* instance) {
furi_assert(instance);
// SubBruteDevice
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free SubBruteDevice");
#endif
subbrute_device_free(instance->device);
// SubBruteWorker
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free SubBruteDevice");
@ -149,12 +155,6 @@ void subbrute_free(SubBruteState* instance) {
subbrute_worker_stop(instance->worker);
subbrute_worker_free(instance->worker);
// SubBruteDevice
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free SubBruteDevice");
#endif
subbrute_device_free(instance->device);
// Notifications
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "free Notifications");

View file

@ -60,8 +60,6 @@ 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;
@ -339,7 +337,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();
@ -361,10 +359,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;
@ -428,7 +426,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();
@ -563,12 +561,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

View file

@ -127,9 +127,9 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
if(m->index == position) {
canvas_draw_str_aligned(
canvas,
4,
64,
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
AlignLeft,
AlignCenter,
AlignCenter,
str);
elements_frame(
@ -137,9 +137,9 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
} else {
canvas_draw_str_aligned(
canvas,
4,
64,
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
AlignLeft,
AlignCenter,
AlignCenter,
str);
}