#pragma once #include "subbrute_device_i.h" #include #include #include #include #define SUBBRUTE_TEXT_STORE_SIZE 256 #define SUBBRUTE_MAX_LEN_NAME 64 #define SUBBRUTE_PATH EXT_PATH("subghz") #define SUBBRUTE_FILE_EXT ".sub" #define SUBBRUTE_PAYLOAD_SIZE 16 typedef enum { SubBruteAttackCAME12bit303, SubBruteAttackCAME12bit307, SubBruteAttackCAME12bit433, SubBruteAttackCAME12bit868, SubBruteAttackNICE12bit433, SubBruteAttackNICE12bit868, SubBruteAttackChamberlain9bit300, SubBruteAttackChamberlain9bit315, SubBruteAttackChamberlain9bit390, SubBruteAttackLinear10bit300, SubBruteAttackLinear10bit310, SubBruteAttackLoadFile, SubBruteAttackTotalCount, } SubBruteAttacks; typedef enum { SubBruteFileResultUnknown, SubBruteFileResultOk, SubBruteFileResultErrorOpenFile, SubBruteFileResultMissingOrIncorrectHeader, SubBruteFileResultFrequencyNotAllowed, SubBruteFileResultMissingOrIncorrectFrequency, SubBruteFileResultPresetInvalid, SubBruteFileResultMissingProtocol, SubBruteFileResultProtocolNotSupported, SubBruteFileResultDynamicProtocolNotValid, SubBruteFileResultProtocolNotFound, SubBruteFileResultMissingOrIncorrectBit, SubBruteFileResultMissingOrIncorrectKey, SubBruteFileResultMissingOrIncorrectTe, SubBruteFileResultBigBitSize, } SubBruteFileResult; typedef enum { SubBruteDeviceStateIDLE, SubBruteDeviceStateReady, SubBruteDeviceStateTx, SubBruteDeviceStateFinished, } SubBruteDeviceState; typedef struct { SubBruteDeviceState state; SubBruteProtocol* protocol_info; volatile bool worker_running; // Current step uint64_t key_index; // Index of group to bruteforce in loaded file uint8_t load_index; // SubGhz FuriThread* thread; SubGhzReceiver* receiver; SubGhzProtocolDecoderBase* decoder_result; SubGhzEnvironment* environment; SubGhzTransmitter* transmitter; // Attack state SubBruteAttacks attack; char file_template[SUBBRUTE_TEXT_STORE_SIZE]; uint64_t max_value; // Loaded info for attack type char current_key[SUBBRUTE_PAYLOAD_SIZE]; char file_key[SUBBRUTE_MAX_LEN_NAME]; // 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); void subbrute_device_attack_set_default_values( SubBruteDevice* context, 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);