-
Notifications
You must be signed in to change notification settings - Fork 7
/
RFCatRXTXDECODE.py
63 lines (51 loc) · 1.63 KB
/
RFCatRXTXDECODE.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
from rflib import *
import sys
import bitstring
import time
def init(device):
device.setFreq(433911000) #433.911MHz
device.setMdmModulation(MOD_2FSK) #2FSK modulation
device.setMdmDeviatn(37500) #39.5kHz deviation, now 37.5
device.setMdmDRate(4111) #4k baud
device.setMdmChanBW(125000) #125k channel bandwidth
device.setMdmChanSpc(200000)
#device.setPktPQT(0) #Disable preamble quality threshold
device.setMdmNumPreamble(255) #Number of preamble symbols, 255 max, regularly 112
"""ENABLE THIS TO FILTER"""
device.setMdmSyncMode(1) #What is this?
#device.setMdmSyncMode(0)
#device.setMdmSyncWord(0xaaaa)
device.setMdmSyncWord(0xcccc) #Sync word
#device.setMdmNumPreamble(0)
device.setMaxPower()
device.makePktFLEN(100) #400 binary symbols, ref. inspectrum
#device.lowball(0) #More garbage
codes = []
def rx(device):
print d.reprRadioConfig()
while not keystop():
try:
pkt, ts = device.RFrecv()
hxval = pkt.encode('hex')
print "Received: %s" % hxval
codes.append(hxval)
except ChipconUsbTimeoutException:
pass
sys.stdin.read(1)
def replay(device):
for code in codes:
codeb = bitstring.BitArray(hex=code).tobytes()
print str(codeb)
device.RFxmit(codeb)
time.sleep(1)
def mreplay(device, data):
device.RFxmit(data)
"""CREDITS: http://labs.inguardians.com/radio-communication-analysis-using-rfcat/"""
def str2hex(data):
tmp = ""
for e in range(0,len(data),2):
tmp += data[e:e+2].decode('hex_codec')
print tmp
return tmp
def cls():
codes = []