2022-09-24 17:47:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-30 14:36:56 +00:00
|
|
|
#include "subbrute_device_i.h"
|
2022-09-24 17:47:21 +00:00
|
|
|
#include <lib/subghz/protocols/base.h>
|
|
|
|
#include <lib/subghz/transmitter.h>
|
|
|
|
#include <lib/subghz/receiver.h>
|
|
|
|
#include <lib/subghz/environment.h>
|
|
|
|
|
2022-09-25 19:12:31 +00:00
|
|
|
#define SUBBRUTE_TEXT_STORE_SIZE 256
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
#define SUBBRUTE_MAX_LEN_NAME 64
|
|
|
|
#define SUBBRUTE_PATH EXT_PATH("subghz")
|
|
|
|
#define SUBBRUTE_FILE_EXT ".sub"
|
|
|
|
|
2022-09-25 13:05:52 +00:00
|
|
|
#define SUBBRUTE_PAYLOAD_SIZE 16
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2022-10-05 13:45:45 +00:00
|
|
|
SubBruteAttackCAME12bit303,
|
2022-09-24 17:47:21 +00:00
|
|
|
SubBruteAttackCAME12bit307,
|
|
|
|
SubBruteAttackCAME12bit433,
|
|
|
|
SubBruteAttackCAME12bit868,
|
2022-09-28 04:50:09 +00:00
|
|
|
SubBruteAttackNICE12bit433,
|
|
|
|
SubBruteAttackNICE12bit868,
|
2022-09-27 01:31:52 +00:00
|
|
|
SubBruteAttackChamberlain9bit300,
|
2022-09-24 17:47:21 +00:00
|
|
|
SubBruteAttackChamberlain9bit315,
|
|
|
|
SubBruteAttackChamberlain9bit390,
|
|
|
|
SubBruteAttackLinear10bit300,
|
|
|
|
SubBruteAttackLinear10bit310,
|
|
|
|
SubBruteAttackLoadFile,
|
|
|
|
SubBruteAttackTotalCount,
|
|
|
|
} SubBruteAttacks;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubBruteFileResultUnknown,
|
|
|
|
SubBruteFileResultOk,
|
|
|
|
SubBruteFileResultErrorOpenFile,
|
|
|
|
SubBruteFileResultMissingOrIncorrectHeader,
|
|
|
|
SubBruteFileResultFrequencyNotAllowed,
|
|
|
|
SubBruteFileResultMissingOrIncorrectFrequency,
|
|
|
|
SubBruteFileResultPresetInvalid,
|
|
|
|
SubBruteFileResultMissingProtocol,
|
|
|
|
SubBruteFileResultProtocolNotSupported,
|
|
|
|
SubBruteFileResultDynamicProtocolNotValid,
|
|
|
|
SubBruteFileResultProtocolNotFound,
|
|
|
|
SubBruteFileResultMissingOrIncorrectBit,
|
|
|
|
SubBruteFileResultMissingOrIncorrectKey,
|
|
|
|
SubBruteFileResultMissingOrIncorrectTe,
|
2022-10-06 00:09:20 +00:00
|
|
|
SubBruteFileResultBigBitSize,
|
2022-09-24 17:47:21 +00:00
|
|
|
} SubBruteFileResult;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubBruteDeviceStateIDLE,
|
|
|
|
SubBruteDeviceStateReady,
|
|
|
|
SubBruteDeviceStateTx,
|
|
|
|
SubBruteDeviceStateFinished,
|
|
|
|
} SubBruteDeviceState;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
SubBruteDeviceState state;
|
2022-09-30 14:36:56 +00:00
|
|
|
SubBruteProtocol* protocol_info;
|
|
|
|
volatile bool worker_running;
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
// Current step
|
2022-09-25 13:05:52 +00:00
|
|
|
uint64_t key_index;
|
2022-09-25 19:12:31 +00:00
|
|
|
// Index of group to bruteforce in loaded file
|
|
|
|
uint8_t load_index;
|
2022-09-24 17:47:21 +00:00
|
|
|
|
2022-09-30 14:36:56 +00:00
|
|
|
// SubGhz
|
|
|
|
FuriThread* thread;
|
2022-09-24 17:47:21 +00:00
|
|
|
SubGhzReceiver* receiver;
|
|
|
|
SubGhzProtocolDecoderBase* decoder_result;
|
|
|
|
SubGhzEnvironment* environment;
|
2022-09-30 14:36:56 +00:00
|
|
|
SubGhzTransmitter* transmitter;
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
// Attack state
|
|
|
|
SubBruteAttacks attack;
|
|
|
|
char file_template[SUBBRUTE_TEXT_STORE_SIZE];
|
2022-09-30 14:36:56 +00:00
|
|
|
|
2022-09-25 13:05:52 +00:00
|
|
|
uint64_t max_value;
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
// Loaded info for attack type
|
|
|
|
char current_key[SUBBRUTE_PAYLOAD_SIZE];
|
2022-09-25 19:12:31 +00:00
|
|
|
char file_key[SUBBRUTE_MAX_LEN_NAME];
|
2022-09-24 17:47:21 +00:00
|
|
|
|
2022-09-30 14:36:56 +00:00
|
|
|
// Manual transmit
|
|
|
|
uint32_t last_time_tx_data;
|
|
|
|
|
|
|
|
// Callback for changed states
|
|
|
|
SubBruteDeviceWorkerCallback callback;
|
|
|
|
void* context;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PRIVATE METHODS
|
|
|
|
*/
|
|
|
|
void subbrute_device_free_protocol_info(SubBruteDevice* instance);
|
|
|
|
int32_t subbrute_worker_thread(void* context);
|
2022-09-27 01:31:52 +00:00
|
|
|
void subbrute_device_attack_set_default_values(
|
|
|
|
SubBruteDevice* context,
|
2022-09-30 14:36:56 +00:00
|
|
|
SubBruteAttacks default_attack);
|
|
|
|
bool subbrute_device_create_packet_parsed(
|
|
|
|
SubBruteDevice* instance,
|
|
|
|
FlipperFormat* flipper_format,
|
|
|
|
uint64_t step,
|
|
|
|
bool small);
|
|
|
|
void subbrute_device_send_callback(SubBruteDevice* instance);
|
|
|
|
void subbrute_device_subghz_transmit(SubBruteDevice* instance, FlipperFormat* flipper_format);
|