-
Notifications
You must be signed in to change notification settings - Fork 2
/
somfyRX.py
111 lines (78 loc) · 2.53 KB
/
somfyRX.py
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
#!/usr/bin/python3
import os
import sys
from rflib import *
#f0f0f0f0f0ff00 works with y
#f0f0f0f0f0fe00 works with z
#OG f0f0ff0
#capture = "f0f0ff33333532b52b4b4d5532b4cb32b280"
def decode(pre, de):
byt=[]
for i in range(0, len(de), 8):
byt.append(int(de[i:i+8], 2))
for n in range(6,0,-1):
byt[n] = byt[n] ^ byt[n-1]
for i in range(len(byt)):
byt[i] = bin(byt[i])[2:].zfill(8)
#print('Pre: ' + pre)
print('Seed: ' + hex(int(byt[0], 2))[2:])
print('Control: ' + hex(int(byt[1][0:4], 2))[2:])
print('Counter: ' + str(int(byt[2]+byt[3], 2)))
print('Address: ' + hex(int(byt[4] + byt[5] + byt[6], 2))[2:] + "\n")
def process(bits):
de = ""
for i in range(0, len(bits), 2):
if bits[i:i+2] == "01":
de+= "1"
if bits[i:i+2] == "10":
de+= "0"
return de
def main():
os.system('clear')
freq = 43342*10000
#setup rfcat
d = RfCat()
d.setModeRX()
d.setFreq(freq)
d.setMdmModulation(MOD_ASK_OOK)
d.setMdmDRate(1600)
d.setMaxPower()
d.lowball(1)
print("Press ENTER to stop")
while not keystop():
try:
pkt, y = d.RFrecv()
capture = bin(int.from_bytes(pkt))[2:]
bits = str(capture)
y = bits.find("1111000011110000111100001111000011110000111111110")
z = bits.find("1111000011110000111100001111000011110000111111100")
x = bits.find("1111000011110000111111110")
if y != -1:
#retransmission
pre = "f0f0f0f0f0ff00"
bits = bits[y+49:]
de = process(bits)
if len(de) >= 56:
byt = decode(pre, de)
elif z != -1:
#alt
pre ="f0f0f0f0f0fe00"
bits = bits[z+49:]
de = process(bits)
if len(de) >= 56:
byt = decode(pre, de)
elif x != -1:
#first full tx
pre= "f0f0ff0"
bits = bits[x+25:]
de = process(bits)
if len(de) >= 56:
byt = decode(pre, de)
else:
capture = None
except ChipconUsbTimeoutException:
pass
d.setModeIDLE()
d = None
if __name__ == '__main__':
main()