DerSkythe 3 лет назад
Родитель
Сommit
d8406e1b69
4 измененных файлов с 56 добавлено и 96 удалено
  1. 0 95
      subbrute_device.c
  2. 0 1
      subbrute_device.h
  3. 52 0
      subbrute_protocols.c
  4. 4 0
      subbrute_protocols.h

+ 0 - 95
subbrute_device.c

@@ -320,25 +320,6 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, const char* fil
         FURI_LOG_D(TAG, "Bit: %d", instance->file_protocol_info->bits);
         FURI_LOG_D(TAG, "Bit: %d", instance->file_protocol_info->bits);
 #endif
 #endif
 
 
-        // TODO: Delete this
-        // Key
-        //         if(!flipper_format_read_string(fff_data_file, "Key", temp_str)) {
-        //             FURI_LOG_E(TAG, "Missing or incorrect Key");
-        //             result = SubBruteFileResultMissingOrIncorrectKey;
-        //             break;
-        //         } else {
-        //             snprintf(
-        //                 instance->current_key_from_file,
-        //                 sizeof(instance->current_key_from_file),
-        //                 "%s",
-        //                 furi_string_get_cstr(temp_str));
-        // #ifdef FURI_DEBUG
-        //             FURI_LOG_D(TAG, "Key: %s", instance->current_key_from_file);
-        // #endif
-        //         }
-        //
-        //         flipper_format_rewind(fff_data_file);
-
         uint8_t key_data[sizeof(uint64_t)] = {0};
         uint8_t key_data[sizeof(uint64_t)] = {0};
         if(!flipper_format_read_hex(fff_data_file, "Key", key_data, sizeof(uint64_t))) {
         if(!flipper_format_read_hex(fff_data_file, "Key", key_data, sizeof(uint64_t))) {
             FURI_LOG_E(TAG, "Missing Key");
             FURI_LOG_E(TAG, "Missing Key");
@@ -354,81 +335,6 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, const char* fil
 #endif
 #endif
         instance->key_from_file = data;
         instance->key_from_file = data;
 
 
-        //         uint16_t add_value = 0x0001;
-        //         uint8_t bit_index = 7;
-        //         bool two_bytes = true;
-        //         uint8_t p[8];
-        //         for(int i = 0; i < 8; i++) {
-        //             p[i] = (uint8_t)(instance->key_from_file >> 8 * (7 - i)) & 0xFF;
-        //         }
-        //         uint16_t num = two_bytes ? (p[bit_index - 1] << 8) | p[bit_index] : p[bit_index];
-        //         FURI_LOG_D(TAG, "num: 0x%04X", num);
-        //         num += add_value;
-        //         FURI_LOG_D(TAG, "num added: 0x%04X", num);
-        //         uint8_t low_byte = num & (0xff);
-        //         uint8_t high_byte = (num >> 8) & 0xff;
-
-        //         data = 0;
-        //         for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
-        //             if(i == bit_index - 1 && two_bytes) {
-        //                 data = (data << 8) | high_byte;
-        //                 data = (data << 8) | low_byte;
-        //                 i++;
-        //             } else if(i == bit_index) {
-        //                 data = (data << 8) | low_byte;
-        //             } else {
-        //                 data = (data << 8) | p[i];
-        //             }
-        //         }
-        // #if FURI_DEBUG
-        //         furi_string_printf(temp_str, "Key: %lX", (uint32_t)(data & 0xFFFFFFFF));
-        //         FURI_LOG_D(
-        //             TAG, "H: 0x%02X, L: 0x%02X, %s", high_byte, low_byte, furi_string_get_cstr(temp_str));
-        // #endif
-        // uint8_t key_data[sizeof(uint64_t)] = {0};
-        // if(!flipper_format_read_hex(fff_data_file, "Key", key_data, sizeof(uint64_t))) {
-        //     FURI_LOG_E(TAG, "Missing Key");
-        //     result = SubBruteFileResultMissingOrIncorrectKey;
-        //     break;
-        // }
-        // uint64_t data = 0;
-        // for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
-        //     data = (data << 8) | key_data[i];
-        // }
-        // instance->key_from_file = data;
-
-        // uint16_t add_value = 0x0001;
-        // uint8_t bit_index = 7;
-        // bool two_bytes = true;
-
-        // uint8_t p[8];
-        // for(int i = 0; i < 8; i++) {
-        //     p[i] = (uint8_t)(instance->key_from_file >> 8 * (7 - i)) & 0xFF;
-        // }
-        // uint16_t num = two_bytes ? (p[bit_index - 1] << 8) | p[bit_index] : p[bit_index];
-        // FURI_LOG_D(TAG, "num: 0x%04X", num);
-        // num += add_value;
-        // FURI_LOG_D(TAG, "num added: 0x%04X", num);
-        // uint8_t low_byte = num & (0xff);
-        // uint8_t high_byte = (num >> 8) & 0xff;
-
-        // data = 0;
-        // for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
-        //     if(i == bit_index - 1 && two_bytes) {
-        //         data = (data << 8) | high_byte;
-        //         data = (data << 8) | low_byte;
-        //         i++;
-        //     } else if(i == bit_index) {
-        //         data = (data << 8) | low_byte;
-        //     } else {
-        //         data = (data << 8) | p[i];
-        //     }
-        // }
-
-        // furi_string_printf(temp_str, "Key: %lX", (uint32_t)(data & 0xFFFFFFFF));
-        // FURI_LOG_D(
-        //     TAG, "H: 0x%02X, L: 0x%02X, %s", high_byte, low_byte, furi_string_get_cstr(temp_str));
-
         // TE
         // TE
         if(!flipper_format_read_uint32(fff_data_file, "TE", &temp_data32, 1)) {
         if(!flipper_format_read_uint32(fff_data_file, "TE", &temp_data32, 1)) {
             FURI_LOG_E(TAG, "Missing or incorrect TE");
             FURI_LOG_E(TAG, "Missing or incorrect TE");
@@ -487,7 +393,6 @@ void subbrute_device_attack_set_default_values(
     instance->bit_index = 0x00;
     instance->bit_index = 0x00;
     instance->extra_repeats = 0;
     instance->extra_repeats = 0;
     instance->two_bytes = false;
     instance->two_bytes = false;
-    memset(instance->current_key, 0, sizeof(instance->current_key));
 
 
     if(default_attack != SubBruteAttackLoadFile) {
     if(default_attack != SubBruteAttackLoadFile) {
         instance->max_value = subbrute_protocol_calc_max_value(
         instance->max_value = subbrute_protocol_calc_max_value(

+ 0 - 1
subbrute_device.h

@@ -49,7 +49,6 @@ typedef struct {
     uint8_t extra_repeats;
     uint8_t extra_repeats;
 
 
     // Loaded info for attack type
     // Loaded info for attack type
-    char current_key[SUBBRUTE_PAYLOAD_SIZE];
     uint64_t key_from_file;
     uint64_t key_from_file;
     uint64_t current_key_from_file;
     uint64_t current_key_from_file;
     bool two_bytes;
     bool two_bytes;

+ 52 - 0
subbrute_protocols.c

@@ -289,6 +289,50 @@ const SubBruteProtocol subbrute_protocol_smc5326_24bit_433 = {
     .preset = FuriHalSubGhzPresetOok650Async,
     .preset = FuriHalSubGhzPresetOok650Async,
     .file = RAWFileProtocol};
     .file = RAWFileProtocol};
 
 
+/**
+ * PT2260 (Princeton) 24bit 315MHz
+ */
+const SubBruteProtocol subbrute_protocol_pt2260_24bit_315 = {
+    .frequency = 315000000,
+    .bits = 24,
+    .te = 0,
+    .repeat = 5,
+    .preset = FuriHalSubGhzPresetOok650Async,
+    .file = PrincetonFileProtocol};
+
+/**
+ * PT2260 (Princeton) 24bit 330MHz
+ */
+const SubBruteProtocol subbrute_protocol_pt2260_24bit_330 = {
+    .frequency = 330000000,
+    .bits = 24,
+    .te = 0,
+    .repeat = 5,
+    .preset = FuriHalSubGhzPresetOok650Async,
+    .file = PrincetonFileProtocol};
+
+/**
+ * PT2260 (Princeton) 24bit 390MHz
+ */
+const SubBruteProtocol subbrute_protocol_pt2260_24bit_390 = {
+    .frequency = 390000000,
+    .bits = 24,
+    .te = 0,
+    .repeat = 5,
+    .preset = FuriHalSubGhzPresetOok650Async,
+    .file = PrincetonFileProtocol};
+
+/**
+ * PT2260 (Princeton) 24bit 433MHz
+ */
+const SubBruteProtocol subbrute_protocol_pt2260_24bit_433 = {
+    .frequency = 433920000,
+    .bits = 24,
+    .te = 0,
+    .repeat = 5,
+    .preset = FuriHalSubGhzPresetOok650Async,
+    .file = PrincetonFileProtocol};
+
 /**
 /**
  * BF existing dump
  * BF existing dump
  */
  */
@@ -322,6 +366,10 @@ static const char* subbrute_protocol_names[] = {
     [SubBruteAttackUNILARM24bit433] = "UNILARM 24bit 433MHz",
     [SubBruteAttackUNILARM24bit433] = "UNILARM 24bit 433MHz",
     [SubBruteAttackSMC532624bit330] = "SMC5326 24bit 330MHz",
     [SubBruteAttackSMC532624bit330] = "SMC5326 24bit 330MHz",
     [SubBruteAttackSMC532624bit433] = "SMC5326 24bit 433MHz",
     [SubBruteAttackSMC532624bit433] = "SMC5326 24bit 433MHz",
+    [SubBruteAttackPT226024bit315] = "PT2260 24bit 315MHz",
+    [SubBruteAttackPT226024bit330] = "PT2260 24bit 330MHz",
+    [SubBruteAttackPT226024bit390] = "PT2260 24bit 390MHz",
+    [SubBruteAttackPT226024bit433] = "PT2260 24bit 433MHz",
     [SubBruteAttackLoadFile] = "BF existing dump",
     [SubBruteAttackLoadFile] = "BF existing dump",
     [SubBruteAttackTotalCount] = "Total Count",
     [SubBruteAttackTotalCount] = "Total Count",
 };
 };
@@ -363,6 +411,10 @@ const SubBruteProtocol* subbrute_protocol_registry[] = {
     [SubBruteAttackUNILARM24bit433] = &subbrute_protocol_unilarm_24bit_433,
     [SubBruteAttackUNILARM24bit433] = &subbrute_protocol_unilarm_24bit_433,
     [SubBruteAttackSMC532624bit330] = &subbrute_protocol_smc5326_24bit_330,
     [SubBruteAttackSMC532624bit330] = &subbrute_protocol_smc5326_24bit_330,
     [SubBruteAttackSMC532624bit433] = &subbrute_protocol_smc5326_24bit_433,
     [SubBruteAttackSMC532624bit433] = &subbrute_protocol_smc5326_24bit_433,
+    [SubBruteAttackPT226024bit315] = &subbrute_protocol_pt2260_24bit_315,
+    [SubBruteAttackPT226024bit330] = &subbrute_protocol_pt2260_24bit_330,
+    [SubBruteAttackPT226024bit390] = &subbrute_protocol_pt2260_24bit_390,
+    [SubBruteAttackPT226024bit433] = &subbrute_protocol_pt2260_24bit_433,
     [SubBruteAttackLoadFile] = &subbrute_protocol_load_file};
     [SubBruteAttackLoadFile] = &subbrute_protocol_load_file};
 
 
 static const char* subbrute_protocol_file_types[] = {
 static const char* subbrute_protocol_file_types[] = {

+ 4 - 0
subbrute_protocols.h

@@ -50,6 +50,10 @@ typedef enum {
     SubBruteAttackUNILARM24bit433,
     SubBruteAttackUNILARM24bit433,
     SubBruteAttackSMC532624bit330,
     SubBruteAttackSMC532624bit330,
     SubBruteAttackSMC532624bit433,
     SubBruteAttackSMC532624bit433,
+    SubBruteAttackPT226024bit315,
+    SubBruteAttackPT226024bit330,
+    SubBruteAttackPT226024bit390,
+    SubBruteAttackPT226024bit433,
     SubBruteAttackLoadFile,
     SubBruteAttackLoadFile,
     SubBruteAttackTotalCount,
     SubBruteAttackTotalCount,
 } SubBruteAttacks;
 } SubBruteAttacks;