Hackvent_2018/Day 15/decode.py

29 lines
537 B
Python
Raw Normal View History

2018-12-16 18:10:42 +01:00
#!/usr/bin/python
import base64
from Crypto import Random
from Crypto.Cipher import AES
key = list("uQA\\-nM@=1wl\x1EbN!")
b64 = "xQ34V+MHmhC8V88KyU66q0DE4QeOxAbp1EGy9tlpkLw="
key[0] = chr(120)
offset = 1
while True:
key[offset] = chr(ord(key[offset]) + 3)
offset += 1
if len(key) <= offset:
break
key = "".join(key)
def decrypt(key, encrypted):
aes = AES.new(key, AES.MODE_ECB)
return aes.decrypt(base64.b64decode(b64))
decrypted = decrypt(key.encode("utf-8"), b64)
print(decrypted.decode("utf-8"))