10
2
Fork 0
has-writeup/payload/leakycrypto/gen.py

29 lines
853 B
Python

guesses = {
7: [52, 54, 53, 43],
8: [149, 151, 150, 148],
9: [173, 174, 175, 172],
10: [83, 80, 81, 82],
13: [186, 184, 185, 187],
14: [2, 1, 0, 3],
15: [151, 149, 150, 148]
}
known_keybytes = bytes.fromhex("64c7072487f2")
candidates = [list(known_keybytes)]
for i in range(len(known_keybytes), 16):
new_candidates = []
if i in guesses.keys():
for guess in guesses[i]:
for candidate in candidates:
new_candidates.append([c for c in candidate] + [guess])
else:
for candidate in candidates:
new_candidates.append([c for c in candidate] + [-1])
candidates = new_candidates
print("Generated %d candidates" % len(candidates))
for candidate in candidates:
rep = ''.join([hex(c)[2:].zfill(2) if c != -1 else '??' for c in candidate])
print(rep)