Skip to content

Instantly share code, notes, and snippets.

@tjmtmmnk
Created October 20, 2019 08:52
Show Gist options
  • Save tjmtmmnk/ac252ae18e4a47b2a34e1c1042ce2e58 to your computer and use it in GitHub Desktop.
Save tjmtmmnk/ac252ae18e4a47b2a34e1c1042ce2e58 to your computer and use it in GitHub Desktop.
import sys
from Crypto.Cipher import AES
import base64
def decrypt(key, et):
text = ''
for i in range(len(et)):
for t in range(0x7e):
if (chr((((t - 0x20) + (ord(key[i % len(key)]) - 0x20)) % (0x7e - 0x20 + 1)) + 0x20) == et[i]):
text += chr(t)
return text
def solve(cipher_text):
encode_key = "SECCON"
aes_symmetric_key = "seccon2019"
cipher = AES.new(aes_symmetric_key + chr(0x00) *
(16 - (len(aes_symmetric_key) % 16)), AES.MODE_ECB)
b64_decode = base64.b64decode(cipher_text)
et = cipher.decrypt(b64_decode)
print(decrypt(encode_key, et.decode('ascii')))
text = sys.argv[1]
solve(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment