-
Notifications
You must be signed in to change notification settings - Fork 49
/
subbrute_protocols.h
368 lines (351 loc) · 14.7 KB
/
subbrute_protocols.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#pragma once
#include <furi.h>
#include <furi_hal_subghz.h>
#include <core/string.h>
#include <toolbox/stream/stream.h>
#define SUBBRUTE_PROTOCOL_MAX_REPEATS 9
/**
* @enum SubBruteFileProtocol
* @brief Enum defining various file protocols used in a system
*
* This enum defines different file protocols that can be used in the system.
* Each file protocol is identified by its name.
*
* The possible values for this enum are:
* - CAMEFileProtocol: CAME file protocol
* - NICEFileProtocol: NICE file protocol
* - ChamberlainFileProtocol: Chamberlain file protocol
* - LinearFileProtocol: Linear file protocol
* - LinearDeltaFileProtocol: Linear Delta file protocol
* - PrincetonFileProtocol: Princeton file protocol
* - RAWFileProtocol: RAW file protocol
* - BETTFileProtocol: BETT file protocol
* - ClemsaFileProtocol: Clemsa file protocol
* - DoitrandFileProtocol: Doitrand file protocol
* - GateTXFileProtocol: GateTX file protocol
* - MagellanFileProtocol: Magellan file protocol
* - IntertechnoV3FileProtocol: Intertechno V3 file protocol
* - AnsonicFileProtocol: Ansonic file protocol
* - SMC5326FileProtocol: SMC5326 file protocol
* - UNILARMFileProtocol: UNILARM file protocol
* - PT2260FileProtocol: PT2260 file protocol
* - HoneywellFileProtocol: Honeywell file protocol
* - HoltekFileProtocol: Holtek file protocol
* - UnknownFileProtocol: Unknown file protocol
* - TotalFileProtocol: Total file protocol
*/
typedef enum {
CAMEFileProtocol,
NICEFileProtocol,
ChamberlainFileProtocol,
LinearFileProtocol,
LinearDeltaFileProtocol,
PrincetonFileProtocol,
RAWFileProtocol,
BETTFileProtocol,
ClemsaFileProtocol,
DoitrandFileProtocol,
GateTXFileProtocol,
MagellanFileProtocol,
IntertechnoV3FileProtocol,
AnsonicFileProtocol,
SMC5326FileProtocol,
UNILARMFileProtocol,
PT2260FileProtocol,
HoneywellFileProtocol,
HoltekFileProtocol,
LegrandFileProtocol,
HollarmileProtocol,
GangQiFileProtocol,
Marantec24FileProtocol,
UnknownFileProtocol,
TotalFileProtocol,
} SubBruteFileProtocol;
/**
* @enum SubBruteAttacks
*
* Enumeration of all supported sub-brute attacks.
*
* The `SubBruteAttacks` represents the different types of sub-brute attacks
* that can be performed. Each attack has a unique identifier, which can be used
* to specify the attack when calling functions that handle sub-brute attacks.
*
* The possible values of `SubBruteAttacks` are as follows:
*
* - `SubBruteAttackCAME12bit303`: CAME 12-bit 303 MHz sub-brute attack.
* - `SubBruteAttackCAME12bit307`: CAME 12-bit 307 MHz sub-brute attack.
* - `SubBruteAttackCAME12bit315`: CAME 12-bit 315 MHz sub-brute attack.
* - `SubBruteAttackCAME12bit315`: CAME 12-bit 330 MHz sub-brute attack.
* - `SubBruteAttackCAME12bit433`: CAME 12-bit 433 MHz sub-brute attack.
* - `SubBruteAttackCAME12bit868`: CAME 12-bit 868 MHz sub-brute attack.
* - `SubBruteAttackNICE12bit433`: NICE 12-bit 433 MHz sub-brute attack.
* - `SubBruteAttackNICE12bit868`: NICE 12-bit 868 MHz sub-brute attack.
* - `SubBruteAttackAnsonic12bit433075`: Ansonic 12-bit 433.075 MHz sub-brute attack.
* - `SubBruteAttackAnsonic12bit433`: Ansonic 12-bit 433 MHz sub-brute attack.
* - `SubBruteAttackAnsonic12bit434`: Ansonic 12-bit 434 MHz sub-brute attack.
* - `SubBruteAttackHoltek12bitFM433`: Holtek 12-bit FM 433 MHz sub-brute attack.
* - `SubBruteAttackHoltek12bitAM433`: Holtek 12-bit AM 433 MHz sub-brute attack.
* - `SubBruteAttackHoltek12bitAM315`: Holtek 12-bit AM 315 MHz sub-brute attack.
* - `SubBruteAttackHoltek12bitAM868`: Holtek 12-bit AM 868 MHz sub-brute attack.
* - `SubBruteAttackHoltek12bitAM915`: Holtek 12-bit AM 915 MHz sub-brute attack.
* - `SubBruteAttackChamberlain9bit300`: Chamberlain 9-bit 300 MHz sub-brute attack.
* - `SubBruteAttackChamberlain9bit315`: Chamberlain 9-bit 315 MHz sub-brute attack.
* - `SubBruteAttackChamberlain9bit318`: Chamberlain 9-bit 318 MHz sub-brute attack.
* - `SubBruteAttackChamberlain9bit390`: Chamberlain 9-bit 390 MHz sub-brute attack.
* - `SubBruteAttackChamberlain9bit433`: Chamberlain 9-bit 433 MHz sub-brute attack.
* - `SubBruteAttackChamberlain8bit300`: Chamberlain 8-bit 300 MHz sub-brute attack.
* - `SubBruteAttackChamberlain8bit315`: Chamberlain 8-bit 315 MHz sub-brute attack.
* - `SubBruteAttackChamberlain8bit390`: Chamberlain 8-bit 390 MHz sub-brute attack.
* - `SubBruteAttackChamberlain7bit300`: Chamberlain 7-bit 300 MHz sub-brute attack.
* - `SubBruteAttackChamberlain7bit315`: Chamberlain 7-bit 315 MHz sub-brute attack.
* - `SubBruteAttackChamberlain7bit390`: Chamberlain 7-bit 390 MHz sub-brute attack.
* - `SubBruteAttackLinear10bit300`: Linear 10-bit 300 MHz sub-brute attack.
* - `SubBruteAttackLinear10bit310`: Linear 10-bit 310 MHz sub-brute attack.
* - `SubBruteAttackLinearDelta8bit310`: Linear Delta 8-bit 310 MHz sub-brute attack.
* - `SubBruteAttackUNILARM24bit330`: UNILARM 24-bit 330 MHz sub-brute attack.
* - `SubBruteAttackUNILARM24bit433`: UNILARM 24-bit 433 MHz sub-brute attack.
* - `SubBruteAttackSMC532624bit330`: SMC5326 24-bit 330 MHz sub-brute attack.
* - `SubBruteAttackSMC532624bit433`: SMC5326 6-bit 433 MHz sub-brute attack.
* - `SubBruteAttackPT226024bit315`: PT2260 24-bit 315 MHz sub-brute attack.
* - `SubBruteAttackPT226024bit330`: PT2260 24-bit 330 MHz sub-brute attack.
* - `SubBruteAttackPT226024bit390`: PT2260 24-bit 390 MHz sub-brute attack.
* - `SubBruteAttackPT226024bit433`: PT2260 24-bit 433 MHz sub-brute attack.
* - `SubBruteAttackLoadFile`: Sub-brute attack using values loaded from a file.
* - `SubBruteAttackTotalCount`: Total number of sub-brute attacks.
*/
typedef enum {
SubBruteAttackCAME12bit303,
SubBruteAttackCAME12bit307,
SubBruteAttackCAME12bit315,
SubBruteAttackCAME12bit330,
SubBruteAttackCAME12bit433,
SubBruteAttackCAME12bit868,
SubBruteAttackNICE12bit433,
SubBruteAttackNICE12bit868,
SubBruteAttackAnsonic12bit433075,
SubBruteAttackAnsonic12bit433,
SubBruteAttackAnsonic12bit434,
SubBruteAttackHoltek12bitFM433,
SubBruteAttackHoltek12bitAM433,
SubBruteAttackHoltek12bitAM315,
SubBruteAttackHoltek12bitAM868,
SubBruteAttackHoltek12bitAM915,
SubBruteAttackChamberlain9bit300,
SubBruteAttackChamberlain9bit315,
SubBruteAttackChamberlain9bit318,
SubBruteAttackChamberlain9bit390,
SubBruteAttackChamberlain9bit433,
SubBruteAttackChamberlain8bit300,
SubBruteAttackChamberlain8bit315,
SubBruteAttackChamberlain8bit390,
SubBruteAttackChamberlain7bit300,
SubBruteAttackChamberlain7bit315,
SubBruteAttackChamberlain7bit390,
SubBruteAttackLinear10bit300,
SubBruteAttackLinear10bit310,
SubBruteAttackLinearDelta8bit310,
SubBruteAttackUNILARM24bit330,
SubBruteAttackUNILARM24bit433,
SubBruteAttackSMC532624bit330,
SubBruteAttackSMC532624bit433,
SubBruteAttackPT226024bit315,
SubBruteAttackPT226024bit330,
SubBruteAttackPT226024bit390,
SubBruteAttackPT226024bit433,
SubBruteAttackLoadFile,
SubBruteAttackTotalCount,
} SubBruteAttacks;
/**
* @struct SubBruteProtocol
* @brief Structure representing the SubBrute protocol.
*
* The SubBruteProtocol struct contains information about the protocol parameters such as frequency,
* bits, transmission time (te), repeat count, preset type, and file details using SubBruteFileProtocol.
*/
typedef struct {
uint32_t frequency;
uint8_t bits;
uint32_t te;
uint8_t repeat;
FuriHalSubGhzPreset preset;
SubBruteFileProtocol file;
} SubBruteProtocol;
/**
* @brief Get the SubBruteProtocol object based on the given index
*
* This function returns the SubBruteProtocol object based on the provided index.
*
* @param index The index of the SubBruteProtocol
* @return const SubBruteProtocol* The pointer to the SubBruteProtocol object
*/
const SubBruteProtocol* subbrute_protocol(SubBruteAttacks index);
/**
* @brief Retrieves a sub-GHz protocol preset for brute force attack.
*
* Given a FuriHalSubGhzPreset value, this function retrieves a sub-GHz protocol
* preset suitable for performing a brute force attack. The protocol preset is
* returned as a null-terminated string.
*
* @param preset The FuriHalSubGhzPreset value representing the desired sub-GHz
* protocol preset.
* @return A null-terminated string representing the protocol preset.
*/
const char* subbrute_protocol_preset(FuriHalSubGhzPreset preset);
/**
* @brief Determines the file protocol used by SubBrute
*
* This function takes a SubBruteFileProtocol and returns the corresponding file protocol used by SubBrute.
*
* @param protocol The SubBruteFileProtocol to retrieve the file protocol for
*
* @returns The file protocol as a C string
*/
const char* subbrute_protocol_file(SubBruteFileProtocol protocol);
/**
* @brief Convert a preset name to a FuriHalSubGhzPreset.
*
* This function takes a preset name as a FuriString pointer and converts it to a corresponding FuriHalSubGhzPreset value.
* The converted preset is returned as a FuriHalSubGhzPreset value. If the preset name is not recognized, the behavior is undefined.
*
* @param preset_name The preset name to be converted.
*
* @return The converted FuriHalSubGhzPreset value.
*/
FuriHalSubGhzPreset subbrute_protocol_convert_preset(FuriString* preset_name);
/**
* @brief Creates a SubBruteFileProtocol with the given name.
*
* @param name The name of the protocol.
* @return The created SubBruteFileProtocol.
*/
SubBruteFileProtocol subbrute_protocol_file_protocol_name(FuriString* name);
/**
* @brief Get the number of protocol repeats for a specific SubBrute attack.
*
* This function returns the number of protocol repeats for a specific SubBrute attack, identified by its index.
*
* @param index The index of the SubBrute attack.
* @return The number of protocol repeats for the specified SubBrute attack.
*/
uint8_t subbrute_protocol_repeats_count(SubBruteAttacks index);
/**
* @brief Retrieves the protocol name for a given SubBrute attack.
*
* This function returns the protocol name associated with the specified SubBrute attack.
*
* @param index The index of the SubBrute attack.
* @return The protocol name as a constant character pointer.
*/
const char* subbrute_protocol_name(SubBruteAttacks index);
/**
* @brief Executes a sub-brute force attack with default payload.
*
* This function performs a sub-brute force attack using the default payload on the specified stream and file protocol.
* It continues the attack in steps, with each step increasing the payload by a specified number of bits.
*
* @param stream The stream to perform the attack on.
* @param file The file protocol to use for the attack.
* @param step The number of bits to increase the payload with in each step.
* @param bits The initial number of bits in the payload.
* @param te The timeout value in milliseconds.
* @param repeat The number of times to repeat the attack.
*
* @note The function does not return any value.
*/
void subbrute_protocol_default_payload(
Stream* stream,
SubBruteFileProtocol file,
uint64_t step,
uint8_t bits,
uint32_t te,
uint8_t repeat);
/**
* @brief Performs a sub-brute force protocol operation with file payload.
*
* This function takes in a stream, step, bits, te, repeat, bit_index,
* file_key, and two_bytes as input parameters and performs a sub-brute
* force protocol operation with a file payload.
*
* @param stream The Stream object to operate on.
* @param step The step value to use during the operation.
* @param bits The number of bits to use.
* @param te The te value to use during the operation.
* @param repeat The number of times to repeat the operation.
* @param bit_index The bit index to use during the operation.
* @param file_key The file key to use during the operation.
* @param two_bytes A boolean indicating whether to use two bytes in the operation.
*
* @return None
*/
void subbrute_protocol_file_payload(
Stream* stream,
uint64_t step,
uint8_t bits,
uint32_t te,
uint8_t repeat,
uint8_t bit_index,
uint64_t file_key,
bool two_bytes);
/**
* @brief Generates a file using the SubBrute protocol with default settings.
*
* This function generates a file using the SubBrute protocol with default settings.
*
* @param stream The stream used for writing the file.
* @param frequency The frequency of the SubBrute protocol.
* @param preset The SubGhzPreset used for transmission.
* @param file The SubBruteFileProtocol used for generating the file.
* @param step The step size used for generating the file.
* @param bits The number of bits to generate for each interval.
* @param te The duration of each transmission interval in milliseconds.
*/
void subbrute_protocol_default_generate_file(
Stream* stream,
uint32_t frequency,
FuriHalSubGhzPreset preset,
SubBruteFileProtocol file,
uint64_t step,
uint8_t bits,
uint32_t te);
/**
* @brief Generates a file for the SubBrute protocol with the given parameters.
*
* This function generates a file for the SubBrute protocol using the provided parameters.
* The generated file can be used for various purposes, such as testing or data analysis.
*
* @param stream The Stream to output the generated file to.
* @param frequency The frequency to use for the SubBrute protocol.
* @param preset The SubGhzPreset to use for the SubBrute protocol.
* @param file The SubBruteFileProtocol to generate.
* @param step The step value to use for the SubBrute protocol.
* @param bits The number of bits to use for each transmission in the SubBrute protocol.
* @param te The TE value to use for the SubBrute protocol.
* @param bit_index The starting bit index for the SubBrute protocol.
* @param file_key The file key to use for generating the SubBrute file.
* @param two_bytes Indicates whether two bytes should be used for each transmission (true) or not (false).
*/
void subbrute_protocol_file_generate_file(
Stream* stream,
uint32_t frequency,
FuriHalSubGhzPreset preset,
SubBruteFileProtocol file,
uint64_t step,
uint8_t bits,
uint32_t te,
uint8_t bit_index,
uint64_t file_key,
bool two_bytes);
/**
* @brief Calculates the maximum value based on the attack type, number of bits, and whether two bytes are used.
*
* This function calculates the maximum value that can be generated based on the specified attack type,
* number of bits, and whether two bytes are used. The result is returned as a 64-bit unsigned integer.
*
* @param attack_type The type of attack to be performed (SubBruteAttacks).
* @param bits The number of bits used for the attack (uint8_t).
* @param two_bytes Whether two bytes are used for the attack (bool).
*
* @return The maximum value that can be generated based on the attack parameters (uint64_t).
*/
uint64_t
subbrute_protocol_calc_max_value(SubBruteAttacks attack_type, uint8_t bits, bool two_bytes);