Skip to content

Instantly share code, notes, and snippets.

@n4o847
Created October 20, 2019 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n4o847/4054b204d11ac44d9a2e2687f6d829d7 to your computer and use it in GitHub Desktop.
Save n4o847/4054b204d11ac44d9a2e2687f6d829d7 to your computer and use it in GitHub Desktop.
SECCON 2019 QUALS
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