1 | | - | import pandas as pd |
2 | | - | split = 1000 # split files according to the keys count (each 1000 in one file) |
3 | | - | case = 0 |
| 1 | + | # Script settings: |
| 2 | + | split = 1000 # number of keys per file |
| 3 | + | file_header = """ |
| 4 | + | Filetype: Flipper SubGhz RAW File |
| 5 | + | Version: 1 |
| 6 | + | Frequency: 433920000 |
| 7 | + | Preset: FuriHalSubGhzPresetOok650Async |
| 8 | + | Protocol: RAW |
| 9 | + | """ |
4 | 10 | | |
5 | | - | for x in range(0, 4096): # 12bit = 4096 possibilities |
6 | | - | binary = "{0:012b}".format(x) # with leading zeros |
7 | | - | cmd = ['-15078 ', '321 '] |
8 | | - | for char in binary: |
9 | | - | if char == "0": |
10 | | - | cmd.append('-334 ') |
11 | | - | cmd.append('667 ') |
12 | | - | if char == "1": |
13 | | - | cmd.append('-664 ') |
14 | | - | cmd.append('343 ') |
15 | | - | joined = "".join(cmd) |
16 | | - | Multijoined = joined * 5 # number of repetition |
17 | | - | command = 'RAW_Data: ' + Multijoined |
18 | | - | padding = "RAW_Data: -50000 50000 " |
| 11 | + | # Protocol settings: https://phreakerclub.com/447 |
| 12 | + | n_bits = 12 |
| 13 | + | combos = range(0, pow(2, n_bits)) |
| 14 | + | repetition = 3 |
| 15 | + | transposition_table = { |
| 16 | + | "0": "-320 640 ", |
| 17 | + | "1": "-640 320 ", |
| 18 | + | } |
| 19 | + | pilot_period = "-11520 320 " |
19 | 20 | | |
20 | | - | # split files according to the keys count (each 1000 in one file) |
| 21 | + | for key_dec in combos: |
| 22 | + | key_bin = f"{key_dec:012b}" # format as 12 digits bin |
| 23 | + | key_str = pilot_period |
| 24 | + | for bit in key_bin: |
| 25 | + | key_str += transposition_table[bit] |
| 26 | + | joined = "".join(key_str) |
| 27 | + | key_str = key_str * repetition |
21 | 28 | | |
22 | | - | if (x % split) == 0: |
23 | | - | case += 1 |
24 | | - | filecase = f'output{case}.sub' |
25 | | - | with open(filecase, 'w') as f: |
26 | | - | f.write("Filetype: Flipper SubGhz RAW File\nVersion: 1\nFrequency: 433920000\nPreset: FuriHalSubGhzPresetOok650Async\nProtocol: RAW\n") |
| 29 | + | if (key_dec % split) == 0: |
| 30 | + | filename = f"CAME_bruteforce_{split}_{int(key_dec / split)}.sub" |
| 31 | + | with open(filename, "w") as f: |
| 32 | + | f.write(file_header) |
27 | 33 | | |
28 | | - | # write keys to sub file |
29 | | - | def writing(raw, filename, pad): |
30 | | - | with open(filename, 'a') as f: |
31 | | - | f.write(raw) |
32 | | - | f.write('\n') |
33 | | - | f.write(pad) |
34 | | - | f.write('\n') |
35 | | - | |
36 | | - | writing(command, filecase, padding) |
| 34 | + | with open(filename, "a") as f: |
| 35 | + | f.write("RAW_Data: " + key_str + "\n") |
37 | 36 | | |