mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-18 00:33:09 +00:00
fix send with dump file
This commit is contained in:
parent
eed8cd1824
commit
b65a2e9c94
6 changed files with 111 additions and 110 deletions
|
@ -225,11 +225,11 @@ bool subbrute_worker_transmit_current_key(SubBruteWorker* instance, uint64_t ste
|
||||||
FlipperFormat* flipper_format = flipper_format_string_alloc();
|
FlipperFormat* flipper_format = flipper_format_string_alloc();
|
||||||
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
||||||
|
|
||||||
FuriString* payload = NULL;
|
|
||||||
stream_clean(stream);
|
stream_clean(stream);
|
||||||
|
|
||||||
if(instance->attack == SubBruteAttackLoadFile) {
|
if(instance->attack == SubBruteAttackLoadFile) {
|
||||||
payload = subbrute_protocol_file_payload(
|
subbrute_protocol_file_payload(
|
||||||
|
stream,
|
||||||
step,
|
step,
|
||||||
instance->bits,
|
instance->bits,
|
||||||
instance->te,
|
instance->te,
|
||||||
|
@ -237,25 +237,25 @@ bool subbrute_worker_transmit_current_key(SubBruteWorker* instance, uint64_t ste
|
||||||
instance->load_index,
|
instance->load_index,
|
||||||
instance->file_key);
|
instance->file_key);
|
||||||
} else {
|
} else {
|
||||||
payload = subbrute_protocol_default_payload(
|
subbrute_protocol_default_payload(
|
||||||
step, instance->bits, instance->te, instance->repeat);
|
stream, step, instance->bits, instance->te, instance->repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t written = stream_write_string(stream, payload);
|
// size_t written = stream_write_string(stream, payload);
|
||||||
if(written <= 0) {
|
// if(written <= 0) {
|
||||||
FURI_LOG_W(TAG, "Error creating packet! EXIT");
|
// FURI_LOG_W(TAG, "Error creating packet! EXIT");
|
||||||
result = false;
|
// result = false;
|
||||||
} else {
|
// } else {
|
||||||
subbrute_worker_subghz_transmit(instance, flipper_format);
|
subbrute_worker_subghz_transmit(instance, flipper_format);
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
#if FURI_DEBUG
|
#if FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "Manual transmit done");
|
FURI_LOG_D(TAG, "Manual transmit done");
|
||||||
#endif
|
#endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
flipper_format_free(flipper_format);
|
flipper_format_free(flipper_format);
|
||||||
furi_string_free(payload);
|
// furi_string_free(payload);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -353,11 +353,10 @@ int32_t subbrute_worker_thread(void* context) {
|
||||||
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
||||||
|
|
||||||
while(instance->worker_running) {
|
while(instance->worker_running) {
|
||||||
FuriString* payload = NULL;
|
|
||||||
stream_clean(stream);
|
stream_clean(stream);
|
||||||
|
|
||||||
if(instance->attack == SubBruteAttackLoadFile) {
|
if(instance->attack == SubBruteAttackLoadFile) {
|
||||||
payload = subbrute_protocol_file_payload(
|
subbrute_protocol_file_payload(
|
||||||
|
stream,
|
||||||
instance->step,
|
instance->step,
|
||||||
instance->bits,
|
instance->bits,
|
||||||
instance->te,
|
instance->te,
|
||||||
|
@ -365,22 +364,22 @@ int32_t subbrute_worker_thread(void* context) {
|
||||||
instance->load_index,
|
instance->load_index,
|
||||||
instance->file_key);
|
instance->file_key);
|
||||||
} else {
|
} else {
|
||||||
payload = subbrute_protocol_default_payload(
|
subbrute_protocol_default_payload(
|
||||||
instance->step, instance->bits, instance->te, instance->repeat);
|
stream, instance->step, instance->bits, instance->te, instance->repeat);
|
||||||
}
|
}
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_I(TAG, "Payload: %s", furi_string_get_cstr(payload));
|
//FURI_LOG_I(TAG, "Payload: %s", furi_string_get_cstr(payload));
|
||||||
furi_delay_ms(SUBBRUTE_MANUAL_TRANSMIT_INTERVAL / 4);
|
//furi_delay_ms(SUBBRUTE_MANUAL_TRANSMIT_INTERVAL / 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t written = stream_write_string(stream, payload);
|
// size_t written = stream_write_stream_write_string(stream, payload);
|
||||||
if(written <= 0) {
|
// if(written <= 0) {
|
||||||
FURI_LOG_W(TAG, "Error creating packet! BREAK");
|
// FURI_LOG_W(TAG, "Error creating packet! BREAK");
|
||||||
instance->worker_running = false;
|
// instance->worker_running = false;
|
||||||
local_state = SubBruteWorkerStateIDLE;
|
// local_state = SubBruteWorkerStateIDLE;
|
||||||
furi_string_free(payload);
|
// furi_string_free(payload);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
subbrute_worker_subghz_transmit(instance, flipper_format);
|
subbrute_worker_subghz_transmit(instance, flipper_format);
|
||||||
|
|
||||||
|
@ -389,12 +388,12 @@ int32_t subbrute_worker_thread(void* context) {
|
||||||
FURI_LOG_I(TAG, "Worker finished to end");
|
FURI_LOG_I(TAG, "Worker finished to end");
|
||||||
#endif
|
#endif
|
||||||
local_state = SubBruteWorkerStateFinished;
|
local_state = SubBruteWorkerStateFinished;
|
||||||
furi_string_free(payload);
|
// furi_string_free(payload);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
instance->step++;
|
instance->step++;
|
||||||
|
|
||||||
furi_string_free(payload);
|
// furi_string_free(payload);
|
||||||
furi_delay_ms(SUBBRUTE_TX_TIMEOUT);
|
furi_delay_ms(SUBBRUTE_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,13 @@ void subbrute_scene_run_attack_on_enter(void* context) {
|
||||||
instance->worker, subbrute_scene_run_attack_device_state_changed, instance);
|
instance->worker, subbrute_scene_run_attack_device_state_changed, instance);
|
||||||
|
|
||||||
if(!subbrute_worker_is_running(instance->worker)) {
|
if(!subbrute_worker_is_running(instance->worker)) {
|
||||||
|
subbrute_worker_set_step(instance->worker, instance->device->key_index);
|
||||||
if(!subbrute_worker_start(instance->worker)) {
|
if(!subbrute_worker_start(instance->worker)) {
|
||||||
view_dispatcher_send_custom_event(
|
view_dispatcher_send_custom_event(
|
||||||
instance->view_dispatcher, SubBruteCustomEventTypeError);
|
instance->view_dispatcher, SubBruteCustomEventTypeError);
|
||||||
|
} else {
|
||||||
|
notification_message(instance->notifications, &sequence_single_vibro);
|
||||||
|
notification_message(instance->notifications, &sequence_blink_start_yellow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,11 +64,14 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
subbrute_attack_view_set_current_step(view, subbrute_worker_get_step(instance->worker));
|
uint64_t step = subbrute_worker_get_step(instance->worker);
|
||||||
|
instance->device->key_index = step;
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
|
|
||||||
if(event.event == SubBruteCustomEventTypeTransmitFinished) {
|
if(event.event == SubBruteCustomEventTypeTransmitFinished) {
|
||||||
notification_message(instance->notifications, &sequence_display_backlight_on);
|
notification_message(instance->notifications, &sequence_display_backlight_on);
|
||||||
notification_message(instance->notifications, &sequence_single_vibro);
|
notification_message(instance->notifications, &sequence_double_vibro);
|
||||||
|
|
||||||
|
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||||
} else if(
|
} else if(
|
||||||
|
@ -84,7 +91,9 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
|
||||||
}
|
}
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.type == SceneManagerEventTypeTick) {
|
} else if(event.type == SceneManagerEventTypeTick) {
|
||||||
subbrute_attack_view_set_current_step(view, subbrute_worker_get_step(instance->worker));
|
uint64_t step = subbrute_worker_get_step(instance->worker);
|
||||||
|
instance->device->key_index = step;
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
|
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,11 @@ SubBruteDevice* subbrute_device_alloc() {
|
||||||
instance->receiver = NULL;
|
instance->receiver = NULL;
|
||||||
instance->environment = subghz_environment_alloc();
|
instance->environment = subghz_environment_alloc();
|
||||||
|
|
||||||
|
#ifdef FURI_DEBUG
|
||||||
|
subbrute_device_attack_set_default_values(instance, SubBruteAttackLoadFile);
|
||||||
|
#else
|
||||||
subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit433);
|
subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit433);
|
||||||
|
#endif
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ uint64_t subbrute_device_add_step(SubBruteDevice* instance, int8_t step) {
|
||||||
} else if(instance->key_index == 0) {
|
} else if(instance->key_index == 0) {
|
||||||
instance->key_index = instance->max_value;
|
instance->key_index = instance->max_value;
|
||||||
} else {
|
} else {
|
||||||
uint64_t value = ((instance->key_index - step) + instance->max_value);
|
uint64_t value = ((instance->key_index + step) + instance->max_value);
|
||||||
if(value == instance->max_value) {
|
if(value == instance->max_value) {
|
||||||
instance->key_index = value;
|
instance->key_index = value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,16 +85,15 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* dev_file_na
|
||||||
|
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||||
FuriString* file_content = furi_string_alloc();
|
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
do {
|
do {
|
||||||
if(!flipper_format_file_open_always(file, dev_file_name)) {
|
if(!flipper_format_file_open_always(file, dev_file_name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Stream* stream = flipper_format_get_raw_stream(file);
|
||||||
if(instance->attack == SubBruteAttackLoadFile) {
|
if(instance->attack == SubBruteAttackLoadFile) {
|
||||||
file_content = subbrute_protocol_file_generate_file(
|
subbrute_protocol_file_generate_file(
|
||||||
|
stream,
|
||||||
instance->file_protocol_info->frequency,
|
instance->file_protocol_info->frequency,
|
||||||
instance->file_protocol_info->preset,
|
instance->file_protocol_info->preset,
|
||||||
instance->file_protocol_info->file,
|
instance->file_protocol_info->file,
|
||||||
|
@ -102,7 +104,8 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* dev_file_na
|
||||||
instance->load_index,
|
instance->load_index,
|
||||||
instance->file_key);
|
instance->file_key);
|
||||||
} else {
|
} else {
|
||||||
file_content = subbrute_protocol_default_generate_file(
|
subbrute_protocol_default_generate_file(
|
||||||
|
stream,
|
||||||
instance->protocol_info->frequency,
|
instance->protocol_info->frequency,
|
||||||
instance->protocol_info->preset,
|
instance->protocol_info->preset,
|
||||||
instance->protocol_info->file,
|
instance->protocol_info->file,
|
||||||
|
@ -112,14 +115,6 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* dev_file_na
|
||||||
instance->protocol_info->repeat);
|
instance->protocol_info->repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream* stream = flipper_format_get_raw_stream(file);
|
|
||||||
stream_clean(stream);
|
|
||||||
size_t written = stream_write_string(stream, file_content);
|
|
||||||
if(written <= 0) {
|
|
||||||
FURI_LOG_E(TAG, "create_packet_parsed failed!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
|
@ -130,7 +125,6 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* dev_file_na
|
||||||
flipper_format_file_close(file);
|
flipper_format_file_close(file);
|
||||||
flipper_format_free(file);
|
flipper_format_free(file);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
furi_string_free(file_content);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +336,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, const char* fil
|
||||||
//result = SubBruteFileResultMissingOrIncorrectTe;
|
//result = SubBruteFileResultMissingOrIncorrectTe;
|
||||||
//break;
|
//break;
|
||||||
} else {
|
} else {
|
||||||
instance->file_protocol_info->te = temp_data32 != 0;
|
instance->file_protocol_info->te = temp_data32 != 0 ? temp_data32 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repeat
|
// Repeat
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "subbrute_protocols.h"
|
#include "subbrute_protocols.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define TAG "SubBruteProtocols"
|
#define TAG "SubBruteProtocols"
|
||||||
|
|
||||||
|
@ -249,8 +250,12 @@ SubBruteFileProtocol subbrute_protocol_file_protocol_name(FuriString* name) {
|
||||||
return RAWFileProtocol;
|
return RAWFileProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriString*
|
void subbrute_protocol_default_payload(
|
||||||
subbrute_protocol_default_payload(uint64_t step, uint8_t bits, uint8_t te, uint8_t repeat) {
|
Stream* stream,
|
||||||
|
uint64_t step,
|
||||||
|
uint8_t bits,
|
||||||
|
uint8_t te,
|
||||||
|
uint8_t repeat) {
|
||||||
FuriString* candidate = furi_string_alloc_set_str(" ");
|
FuriString* candidate = furi_string_alloc_set_str(" ");
|
||||||
|
|
||||||
FuriString* buffer = furi_string_alloc_printf("%16llX", step);
|
FuriString* buffer = furi_string_alloc_printf("%16llX", step);
|
||||||
|
@ -270,25 +275,25 @@ FuriString*
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
//FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
//FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
||||||
#endif
|
#endif
|
||||||
FuriString* result;
|
stream_clean(stream);
|
||||||
|
|
||||||
if(te) {
|
if(te) {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
subbrute_key_small_with_tail, bits, furi_string_get_cstr(candidate), te, repeat);
|
stream,
|
||||||
|
subbrute_key_small_with_tail,
|
||||||
|
bits,
|
||||||
|
furi_string_get_cstr(candidate),
|
||||||
|
te,
|
||||||
|
repeat);
|
||||||
} else {
|
} else {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
subbrute_key_small_no_tail, bits, furi_string_get_cstr(candidate), repeat);
|
stream, subbrute_key_small_no_tail, bits, furi_string_get_cstr(candidate), repeat);
|
||||||
}
|
}
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
//FURI_LOG_D(TAG, "result: %s", furi_string_get_cstr(result));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
furi_string_free(candidate);
|
furi_string_free(candidate);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriString* subbrute_protocol_file_payload(
|
void subbrute_protocol_file_payload(
|
||||||
|
Stream* stream,
|
||||||
uint64_t step,
|
uint64_t step,
|
||||||
uint8_t bits,
|
uint8_t bits,
|
||||||
uint8_t te,
|
uint8_t te,
|
||||||
|
@ -296,9 +301,6 @@ FuriString* subbrute_protocol_file_payload(
|
||||||
uint8_t load_index,
|
uint8_t load_index,
|
||||||
const char* file_key) {
|
const char* file_key) {
|
||||||
FuriString* candidate = furi_string_alloc();
|
FuriString* candidate = furi_string_alloc();
|
||||||
if(step >= sizeof(file_key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char subbrute_payload_byte[4];
|
char subbrute_payload_byte[4];
|
||||||
furi_string_set_str(candidate, file_key);
|
furi_string_set_str(candidate, file_key);
|
||||||
snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)step);
|
snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)step);
|
||||||
|
@ -307,26 +309,26 @@ FuriString* subbrute_protocol_file_payload(
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
//FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
//FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
||||||
#endif
|
#endif
|
||||||
FuriString* result;
|
stream_clean(stream);
|
||||||
|
|
||||||
if(te) {
|
if(te) {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
subbrute_key_small_with_tail, bits, furi_string_get_cstr(candidate), te, repeat);
|
stream,
|
||||||
|
subbrute_key_small_with_tail,
|
||||||
|
bits,
|
||||||
|
furi_string_get_cstr(candidate),
|
||||||
|
te,
|
||||||
|
repeat);
|
||||||
} else {
|
} else {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
subbrute_key_small_no_tail, bits, furi_string_get_cstr(candidate), repeat);
|
stream, subbrute_key_small_no_tail, bits, furi_string_get_cstr(candidate), repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
//FURI_LOG_D(TAG, "result: %s", furi_string_get_cstr(result));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
furi_string_free(candidate);
|
furi_string_free(candidate);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriString* subbrute_protocol_default_generate_file(
|
void subbrute_protocol_default_generate_file(
|
||||||
|
Stream* stream,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
FuriHalSubGhzPreset preset,
|
FuriHalSubGhzPreset preset,
|
||||||
SubBruteFileProtocol file,
|
SubBruteFileProtocol file,
|
||||||
|
@ -353,10 +355,11 @@ FuriString* subbrute_protocol_default_generate_file(
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
||||||
#endif
|
#endif
|
||||||
FuriString* result;
|
stream_clean(stream);
|
||||||
|
|
||||||
if(te) {
|
if(te) {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
|
stream,
|
||||||
subbrute_key_file_start_with_tail,
|
subbrute_key_file_start_with_tail,
|
||||||
frequency,
|
frequency,
|
||||||
preset,
|
preset,
|
||||||
|
@ -366,7 +369,8 @@ FuriString* subbrute_protocol_default_generate_file(
|
||||||
te,
|
te,
|
||||||
repeat);
|
repeat);
|
||||||
} else {
|
} else {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
|
stream,
|
||||||
subbrute_key_file_start_no_tail,
|
subbrute_key_file_start_no_tail,
|
||||||
frequency,
|
frequency,
|
||||||
preset,
|
preset,
|
||||||
|
@ -375,16 +379,12 @@ FuriString* subbrute_protocol_default_generate_file(
|
||||||
furi_string_get_cstr(candidate),
|
furi_string_get_cstr(candidate),
|
||||||
repeat);
|
repeat);
|
||||||
}
|
}
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "result: %s", furi_string_get_cstr(result));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
furi_string_free(candidate);
|
furi_string_free(candidate);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriString* subbrute_protocol_file_generate_file(
|
void subbrute_protocol_file_generate_file(
|
||||||
|
Stream* stream,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
FuriHalSubGhzPreset preset,
|
FuriHalSubGhzPreset preset,
|
||||||
SubBruteFileProtocol file,
|
SubBruteFileProtocol file,
|
||||||
|
@ -395,9 +395,6 @@ FuriString* subbrute_protocol_file_generate_file(
|
||||||
uint8_t load_index,
|
uint8_t load_index,
|
||||||
const char* file_key) {
|
const char* file_key) {
|
||||||
FuriString* candidate = furi_string_alloc();
|
FuriString* candidate = furi_string_alloc();
|
||||||
if(step >= sizeof(file_key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char subbrute_payload_byte[4];
|
char subbrute_payload_byte[4];
|
||||||
furi_string_set_str(candidate, file_key);
|
furi_string_set_str(candidate, file_key);
|
||||||
snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)step);
|
snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)step);
|
||||||
|
@ -406,10 +403,10 @@ FuriString* subbrute_protocol_file_generate_file(
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
FURI_LOG_D(TAG, "candidate: %s, step: %lld", furi_string_get_cstr(candidate), step);
|
||||||
#endif
|
#endif
|
||||||
FuriString* result;
|
stream_clean(stream);
|
||||||
|
|
||||||
if(te) {
|
if(te) {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
|
stream,
|
||||||
subbrute_key_file_start_with_tail,
|
subbrute_key_file_start_with_tail,
|
||||||
frequency,
|
frequency,
|
||||||
preset,
|
preset,
|
||||||
|
@ -419,7 +416,8 @@ FuriString* subbrute_protocol_file_generate_file(
|
||||||
te,
|
te,
|
||||||
repeat);
|
repeat);
|
||||||
} else {
|
} else {
|
||||||
result = furi_string_alloc_printf(
|
stream_write_format(
|
||||||
|
stream,
|
||||||
subbrute_key_file_start_no_tail,
|
subbrute_key_file_start_no_tail,
|
||||||
frequency,
|
frequency,
|
||||||
preset,
|
preset,
|
||||||
|
@ -429,13 +427,7 @@ FuriString* subbrute_protocol_file_generate_file(
|
||||||
repeat);
|
repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "result: %s", furi_string_get_cstr(result));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
furi_string_free(candidate);
|
furi_string_free(candidate);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t subbrute_protocol_calc_max_value(SubBruteAttacks attack_type, uint8_t bits) {
|
uint64_t subbrute_protocol_calc_max_value(SubBruteAttacks attack_type, uint8_t bits) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <furi_hal_subghz.h>
|
#include <furi_hal_subghz.h>
|
||||||
#include <core/string.h>
|
#include <core/string.h>
|
||||||
|
#include <toolbox/stream/stream.h>
|
||||||
//typedef enum {
|
//typedef enum {
|
||||||
// FrequencyProtocolField,
|
// FrequencyProtocolField,
|
||||||
// BitsProtocolField,
|
// BitsProtocolField,
|
||||||
|
@ -56,16 +56,22 @@ FuriHalSubGhzPreset subbrute_protocol_convert_preset(FuriString* preset_name);
|
||||||
SubBruteFileProtocol subbrute_protocol_file_protocol_name(FuriString* name);
|
SubBruteFileProtocol subbrute_protocol_file_protocol_name(FuriString* name);
|
||||||
const char* subbrute_protocol_name(SubBruteAttacks index);
|
const char* subbrute_protocol_name(SubBruteAttacks index);
|
||||||
|
|
||||||
FuriString*
|
void subbrute_protocol_default_payload(
|
||||||
subbrute_protocol_default_payload(uint64_t step, uint8_t bits, uint8_t te, uint8_t repeat);
|
Stream* stream,
|
||||||
FuriString* subbrute_protocol_file_payload(
|
uint64_t step,
|
||||||
|
uint8_t bits,
|
||||||
|
uint8_t te,
|
||||||
|
uint8_t repeat);
|
||||||
|
void subbrute_protocol_file_payload(
|
||||||
|
Stream* stream,
|
||||||
uint64_t step,
|
uint64_t step,
|
||||||
uint8_t bits,
|
uint8_t bits,
|
||||||
uint8_t te,
|
uint8_t te,
|
||||||
uint8_t repeat,
|
uint8_t repeat,
|
||||||
uint8_t load_index,
|
uint8_t load_index,
|
||||||
const char* file_key);
|
const char* file_key);
|
||||||
FuriString* subbrute_protocol_default_generate_file(
|
void subbrute_protocol_default_generate_file(
|
||||||
|
Stream* stream,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
FuriHalSubGhzPreset preset,
|
FuriHalSubGhzPreset preset,
|
||||||
SubBruteFileProtocol file,
|
SubBruteFileProtocol file,
|
||||||
|
@ -73,7 +79,8 @@ FuriString* subbrute_protocol_default_generate_file(
|
||||||
uint8_t bits,
|
uint8_t bits,
|
||||||
uint8_t te,
|
uint8_t te,
|
||||||
uint8_t repeat);
|
uint8_t repeat);
|
||||||
FuriString* subbrute_protocol_file_generate_file(
|
void subbrute_protocol_file_generate_file(
|
||||||
|
Stream* stream,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
FuriHalSubGhzPreset preset,
|
FuriHalSubGhzPreset preset,
|
||||||
SubBruteFileProtocol file,
|
SubBruteFileProtocol file,
|
||||||
|
|
|
@ -91,7 +91,7 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
|
||||||
|
|
||||||
if(m->is_select_byte) {
|
if(m->is_select_byte) {
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "key_field: %s", m->key_field);
|
//FURI_LOG_D(TAG, "key_field: %s", m->key_field);
|
||||||
#endif
|
#endif
|
||||||
char msg_index[18];
|
char msg_index[18];
|
||||||
snprintf(msg_index, sizeof(msg_index), "Field index : %d", m->index);
|
snprintf(msg_index, sizeof(msg_index), "Field index : %d", m->index);
|
||||||
|
@ -118,7 +118,7 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
|
||||||
const uint8_t item_height = 16;
|
const uint8_t item_height = 16;
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "window_position: %d, index: %d", model->window_position, m->index);
|
//FURI_LOG_D(TAG, "window_position: %d, index: %d", model->window_position, m->index);
|
||||||
#endif
|
#endif
|
||||||
for(uint8_t position = 0; position < SubBruteAttackTotalCount; ++position) {
|
for(uint8_t position = 0; position < SubBruteAttackTotalCount; ++position) {
|
||||||
uint8_t item_position = position - model->window_position;
|
uint8_t item_position = position - model->window_position;
|
||||||
|
|
Loading…
Reference in a new issue