Hackvent_2023/Day 12/decrypt.py

27 lines
733 B
Python
Raw Permalink Normal View History

2023-12-19 16:28:13 +01:00
from hackingscripts import util
from mersenne import BreakerPy
from Crypto.Util.number import long_to_bytes
files = {}
def read_file(path):
with open(path, "rb") as f:
data = f.read()
files[path] = data
if __name__ == "__main__":
for file in ["memes/a.jpg", "memes/b.jpeg", "memes/c.jpg", "backup/a.jpg"]:
read_file(file)
key = util.xor(files["backup/a.jpg"], files["memes/a.jpg"])
key = [int.from_bytes(key[i:i+4], "big") for i in range(0, len(key), 4)]
key = key[0:624]
breaker = BreakerPy()
seed_arr = breaker.get_seeds_python_fast(key)
seed = breaker.array_to_int(seed_arr)
print("[+] Recovered Seed:", seed)
print("[+] Flag:", long_to_bytes(seed).decode())