Skip to content

Commit c3c0117

Browse files
committed
update latest code
1 parent ad35ef3 commit c3c0117

File tree

3 files changed

+163
-403
lines changed

3 files changed

+163
-403
lines changed

analysis/analysis.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def packets_to_pandas(packets):
2727
# This expresses our theory about which bits are message hash, and which bits
2828
# are included in message hash calculation. Takes a full message and splits it
2929
# into (message,hash)
30-
def parts(data):
30+
def message_hash_split(data):
3131
# Everything except ID1, byte 4 (sequence & flags), packet crc, and 16bit chksum
3232
msg = data[5:-3]
3333
chksum = data[-3:-1]
@@ -36,15 +36,14 @@ def parts(data):
3636
# Builds a dictionary that maps bitwise observed changes in messages to
3737
# bitwise changes in message hash
3838
def build_bitdiff_dictionary(packets):
39-
data = [parts(p.tx_data()) for p in packets]
39+
unique_packet_data = set([p.tx_data() for p in packets])
40+
data = [message_hash_split(d) for d in unique_packet_data]
4041

4142
cracked_bits_dict = {}
4243
for c in itertools.combinations(data, 2):
4344
d = DiffMessage(c)
4445
if d.diff_bits_count == 0:
4546
continue
46-
if d.diff_bits_key in cracked_bits_dict:
47-
cracked_bits_dict[d.diff_bits_key].update_observation(d)
48-
else:
49-
cracked_bits_dict[d.diff_bits_key] = d
47+
if d.diff_bits_key not in cracked_bits_dict:
48+
cracked_bits_dict[d.diff_bits_key] = d.dc
5049
return cracked_bits_dict

0 commit comments

Comments
 (0)