Skip to content

Commit d8406e1

Browse files
committedDec 11, 2022
Add PT2260 Princeton
1 parent 6e20e9b commit d8406e1

4 files changed

+56
-96
lines changed
 

‎subbrute_device.c

-95
Original file line numberDiff line numberDiff line change
@@ -320,25 +320,6 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, const char* fil
320320
FURI_LOG_D(TAG, "Bit: %d", instance->file_protocol_info->bits);
321321
#endif
322322

323-
// TODO: Delete this
324-
// Key
325-
// if(!flipper_format_read_string(fff_data_file, "Key", temp_str)) {
326-
// FURI_LOG_E(TAG, "Missing or incorrect Key");
327-
// result = SubBruteFileResultMissingOrIncorrectKey;
328-
// break;
329-
// } else {
330-
// snprintf(
331-
// instance->current_key_from_file,
332-
// sizeof(instance->current_key_from_file),
333-
// "%s",
334-
// furi_string_get_cstr(temp_str));
335-
// #ifdef FURI_DEBUG
336-
// FURI_LOG_D(TAG, "Key: %s", instance->current_key_from_file);
337-
// #endif
338-
// }
339-
//
340-
// flipper_format_rewind(fff_data_file);
341-
342323
uint8_t key_data[sizeof(uint64_t)] = {0};
343324
if(!flipper_format_read_hex(fff_data_file, "Key", key_data, sizeof(uint64_t))) {
344325
FURI_LOG_E(TAG, "Missing Key");
@@ -354,81 +335,6 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, const char* fil
354335
#endif
355336
instance->key_from_file = data;
356337

357-
// uint16_t add_value = 0x0001;
358-
// uint8_t bit_index = 7;
359-
// bool two_bytes = true;
360-
// uint8_t p[8];
361-
// for(int i = 0; i < 8; i++) {
362-
// p[i] = (uint8_t)(instance->key_from_file >> 8 * (7 - i)) & 0xFF;
363-
// }
364-
// uint16_t num = two_bytes ? (p[bit_index - 1] << 8) | p[bit_index] : p[bit_index];
365-
// FURI_LOG_D(TAG, "num: 0x%04X", num);
366-
// num += add_value;
367-
// FURI_LOG_D(TAG, "num added: 0x%04X", num);
368-
// uint8_t low_byte = num & (0xff);
369-
// uint8_t high_byte = (num >> 8) & 0xff;
370-
371-
// data = 0;
372-
// for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
373-
// if(i == bit_index - 1 && two_bytes) {
374-
// data = (data << 8) | high_byte;
375-
// data = (data << 8) | low_byte;
376-
// i++;
377-
// } else if(i == bit_index) {
378-
// data = (data << 8) | low_byte;
379-
// } else {
380-
// data = (data << 8) | p[i];
381-
// }
382-
// }
383-
// #if FURI_DEBUG
384-
// furi_string_printf(temp_str, "Key: %lX", (uint32_t)(data & 0xFFFFFFFF));
385-
// FURI_LOG_D(
386-
// TAG, "H: 0x%02X, L: 0x%02X, %s", high_byte, low_byte, furi_string_get_cstr(temp_str));
387-
// #endif
388-
// uint8_t key_data[sizeof(uint64_t)] = {0};
389-
// if(!flipper_format_read_hex(fff_data_file, "Key", key_data, sizeof(uint64_t))) {
390-
// FURI_LOG_E(TAG, "Missing Key");
391-
// result = SubBruteFileResultMissingOrIncorrectKey;
392-
// break;
393-
// }
394-
// uint64_t data = 0;
395-
// for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
396-
// data = (data << 8) | key_data[i];
397-
// }
398-
// instance->key_from_file = data;
399-
400-
// uint16_t add_value = 0x0001;
401-
// uint8_t bit_index = 7;
402-
// bool two_bytes = true;
403-
404-
// uint8_t p[8];
405-
// for(int i = 0; i < 8; i++) {
406-
// p[i] = (uint8_t)(instance->key_from_file >> 8 * (7 - i)) & 0xFF;
407-
// }
408-
// uint16_t num = two_bytes ? (p[bit_index - 1] << 8) | p[bit_index] : p[bit_index];
409-
// FURI_LOG_D(TAG, "num: 0x%04X", num);
410-
// num += add_value;
411-
// FURI_LOG_D(TAG, "num added: 0x%04X", num);
412-
// uint8_t low_byte = num & (0xff);
413-
// uint8_t high_byte = (num >> 8) & 0xff;
414-
415-
// data = 0;
416-
// for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
417-
// if(i == bit_index - 1 && two_bytes) {
418-
// data = (data << 8) | high_byte;
419-
// data = (data << 8) | low_byte;
420-
// i++;
421-
// } else if(i == bit_index) {
422-
// data = (data << 8) | low_byte;
423-
// } else {
424-
// data = (data << 8) | p[i];
425-
// }
426-
// }
427-
428-
// furi_string_printf(temp_str, "Key: %lX", (uint32_t)(data & 0xFFFFFFFF));
429-
// FURI_LOG_D(
430-
// TAG, "H: 0x%02X, L: 0x%02X, %s", high_byte, low_byte, furi_string_get_cstr(temp_str));
431-
432338
// TE
433339
if(!flipper_format_read_uint32(fff_data_file, "TE", &temp_data32, 1)) {
434340
FURI_LOG_E(TAG, "Missing or incorrect TE");
@@ -487,7 +393,6 @@ void subbrute_device_attack_set_default_values(
487393
instance->bit_index = 0x00;
488394
instance->extra_repeats = 0;
489395
instance->two_bytes = false;
490-
memset(instance->current_key, 0, sizeof(instance->current_key));
491396

492397
if(default_attack != SubBruteAttackLoadFile) {
493398
instance->max_value = subbrute_protocol_calc_max_value(

‎subbrute_device.h

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ typedef struct {
4949
uint8_t extra_repeats;
5050

5151
// Loaded info for attack type
52-
char current_key[SUBBRUTE_PAYLOAD_SIZE];
5352
uint64_t key_from_file;
5453
uint64_t current_key_from_file;
5554
bool two_bytes;

‎subbrute_protocols.c

+52
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,50 @@ const SubBruteProtocol subbrute_protocol_smc5326_24bit_433 = {
289289
.preset = FuriHalSubGhzPresetOok650Async,
290290
.file = RAWFileProtocol};
291291

292+
/**
293+
* PT2260 (Princeton) 24bit 315MHz
294+
*/
295+
const SubBruteProtocol subbrute_protocol_pt2260_24bit_315 = {
296+
.frequency = 315000000,
297+
.bits = 24,
298+
.te = 0,
299+
.repeat = 5,
300+
.preset = FuriHalSubGhzPresetOok650Async,
301+
.file = PrincetonFileProtocol};
302+
303+
/**
304+
* PT2260 (Princeton) 24bit 330MHz
305+
*/
306+
const SubBruteProtocol subbrute_protocol_pt2260_24bit_330 = {
307+
.frequency = 330000000,
308+
.bits = 24,
309+
.te = 0,
310+
.repeat = 5,
311+
.preset = FuriHalSubGhzPresetOok650Async,
312+
.file = PrincetonFileProtocol};
313+
314+
/**
315+
* PT2260 (Princeton) 24bit 390MHz
316+
*/
317+
const SubBruteProtocol subbrute_protocol_pt2260_24bit_390 = {
318+
.frequency = 390000000,
319+
.bits = 24,
320+
.te = 0,
321+
.repeat = 5,
322+
.preset = FuriHalSubGhzPresetOok650Async,
323+
.file = PrincetonFileProtocol};
324+
325+
/**
326+
* PT2260 (Princeton) 24bit 433MHz
327+
*/
328+
const SubBruteProtocol subbrute_protocol_pt2260_24bit_433 = {
329+
.frequency = 433920000,
330+
.bits = 24,
331+
.te = 0,
332+
.repeat = 5,
333+
.preset = FuriHalSubGhzPresetOok650Async,
334+
.file = PrincetonFileProtocol};
335+
292336
/**
293337
* BF existing dump
294338
*/
@@ -322,6 +366,10 @@ static const char* subbrute_protocol_names[] = {
322366
[SubBruteAttackUNILARM24bit433] = "UNILARM 24bit 433MHz",
323367
[SubBruteAttackSMC532624bit330] = "SMC5326 24bit 330MHz",
324368
[SubBruteAttackSMC532624bit433] = "SMC5326 24bit 433MHz",
369+
[SubBruteAttackPT226024bit315] = "PT2260 24bit 315MHz",
370+
[SubBruteAttackPT226024bit330] = "PT2260 24bit 330MHz",
371+
[SubBruteAttackPT226024bit390] = "PT2260 24bit 390MHz",
372+
[SubBruteAttackPT226024bit433] = "PT2260 24bit 433MHz",
325373
[SubBruteAttackLoadFile] = "BF existing dump",
326374
[SubBruteAttackTotalCount] = "Total Count",
327375
};
@@ -363,6 +411,10 @@ const SubBruteProtocol* subbrute_protocol_registry[] = {
363411
[SubBruteAttackUNILARM24bit433] = &subbrute_protocol_unilarm_24bit_433,
364412
[SubBruteAttackSMC532624bit330] = &subbrute_protocol_smc5326_24bit_330,
365413
[SubBruteAttackSMC532624bit433] = &subbrute_protocol_smc5326_24bit_433,
414+
[SubBruteAttackPT226024bit315] = &subbrute_protocol_pt2260_24bit_315,
415+
[SubBruteAttackPT226024bit330] = &subbrute_protocol_pt2260_24bit_330,
416+
[SubBruteAttackPT226024bit390] = &subbrute_protocol_pt2260_24bit_390,
417+
[SubBruteAttackPT226024bit433] = &subbrute_protocol_pt2260_24bit_433,
366418
[SubBruteAttackLoadFile] = &subbrute_protocol_load_file};
367419

368420
static const char* subbrute_protocol_file_types[] = {

‎subbrute_protocols.h

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ typedef enum {
5050
SubBruteAttackUNILARM24bit433,
5151
SubBruteAttackSMC532624bit330,
5252
SubBruteAttackSMC532624bit433,
53+
SubBruteAttackPT226024bit315,
54+
SubBruteAttackPT226024bit330,
55+
SubBruteAttackPT226024bit390,
56+
SubBruteAttackPT226024bit433,
5357
SubBruteAttackLoadFile,
5458
SubBruteAttackTotalCount,
5559
} SubBruteAttacks;

0 commit comments

Comments
 (0)
Please sign in to comment.