forked from revers3everything/AutoRFKiller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbruteforceblock.py
More file actions
67 lines (53 loc) · 2.43 KB
/
bruteforceblock.py
File metadata and controls
67 lines (53 loc) · 2.43 KB
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
import numpy as np
from gnuradio import gr
import time
class bruteforceblock(gr.sync_block):
def __init__(self,number_start,number_finish,dictionary,time):
gr.sync_block.__init__(self,
name="custom_source_20bit",
in_sig=None,
out_sig=[np.complex64])
self.current_combination = number_start # Start at the desired range, works with 360590...no less
self.max_combinations = number_finish
self.complete = False
self.call_count = 0 # Contador de llamadas a work
self.nbits = dictionary["n"]
self.dictionary = dictionary["encoding"]
self.time = time
def work(self, input_items, output_items):
if self.complete:
return 0
out = output_items[0]
nbin = '0'+str(self.nbits)+'b'
bits_pre = list(map(int, format(self.current_combination, nbin)))#20 bits
#20 bits codification
print(f"Trying decimal code------------------------------------------->: {self.current_combination}")
self.current_combination += 1 # Increment the combination counter
print(bits_pre)
encoded_result = []
encoding = {key: self.dictionary[key] for key in list(self.dictionary)[:2]}
preamble = {key: self.dictionary[key] for key in list(self.dictionary)[2:]}
for bit in bits_pre:
encoded_result.extend([int(char) for char in encoding[bit]])
#Preambule&mode codification
preamble = preamble['preamble']
mode = [0,0,1,0] # unlock'
mode_result = []
for bit in mode:
mode_result.extend([int(char) for char in encoding[bit]])
bits = [int(char) for char in preamble] + encoded_result + mode_result
bits = bits*2
#signal = np.array([complex(bit) for bit in bits], dtype=np.complex64)
signal = [complex(bit) for bit in bits]
# Ensure output buffer length matches the signal length
noutput_items = min(len(out), len(signal))
out[:noutput_items] = signal[:noutput_items]
if self.current_combination > self.max_combinations:
self.complete = True
print("Task completed, exiting...")
exit()
time.sleep(self.time/1000)#Transform from miliseconds to seconds
return noutput_items
def stop(self):
# Puede ser necesario implementar acciones de limpieza si las hay
exit()