Created
October 20, 2019 06:56
-
-
Save n4o847/4054b204d11ac44d9a2e2687f6d829d7 to your computer and use it in GitHub Desktop.
SECCON 2019 QUALS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Cipher import AES | |
import base64 | |
def encrypt(text): | |
key = "SECCON" | |
s = '' | |
for i in range(len(text)): | |
s += chr((((ord(text[i]) - 0x20) + (ord(key[i % len(key)]) - 0x20)) % (0x7e - 0x20 + 1)) + 0x20) | |
return s | |
key2 = "seccon2019" | |
cipher = AES.new(key2 + chr(0x00) * (16 - (len(key2) % 16)), AES.MODE_ECB) | |
ctext = "FyRyZNBO2MG6ncd3hEkC/yeYKUseI/CxYoZiIeV2fe/Jmtwx+WbWmU1gtMX9m905" | |
dec1 = base64.b64decode(ctext) | |
dec2 = cipher.decrypt(dec1).decode("ascii") | |
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_{}" | |
def search(memo): | |
for c in chars: | |
enc = encrypt(memo + c) | |
if enc in dec2: | |
print(memo + c) | |
search(memo + c) | |
search("SECCON{") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment