Skip to content

Instantly share code, notes, and snippets.

Last active February 17, 2019 19:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Somewhat contrived CTF problem
import hashlib
import random
from Crypto.Cipher import AES
#Find These At
pwds = [pwd.strip() for pwd in f]
#format ninja{...}
thispassword = random.choice(pwds), AES.MODE_ECB)
ct = cipher.encrypt(flag).encode('hex')
assert(cipher.decrypt(ct.decode('hex')) == flag)
def stretch(password, salt, iterations):
for r in range(iterations):
final = hashlib.sha256(final + password+salt).digest()
return final.encode('hex')
print "Stored in our database:", stretch(thispassword, "saltysalty", 5)
print "Encrypted Flag:",ct
Stored in our database: 22f2474bd416be6face5483ba5f4df44c5e22c9e8776bd3cdf109b12d5c9a699
Encrypted Flag: e82f6c5702f4c9c549cbee3fc6fbfb9ab9c27364b4471d22cb0feb628284cb30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment