Skip to content

Instantly share code, notes, and snippets.

@st98
Last active June 11, 2017 20:54
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 st98/453cfbaec05cc0df6b471ad2b7837eb8 to your computer and use it in GitHub Desktop.
Save st98/453cfbaec05cc0df6b471ad2b7837eb8 to your computer and use it in GitHub Desktop.
SHA2017 CTF Teaser round - [Crypto 200] Crypto Engine
import io
import requests
from PIL import Image
def get_image(s):
r = requests.get('https://cryptoengine.stillhackinganyway.nl/encrypt?text=' + s)
return Image.open(io.BytesIO(r.content))
def get_color(im, i):
return im.getpixel((1 + 40 * i, 1))
flag = Image.open('flag')
res = ''
for i in range(12):
im = get_image(res + 'aaa')
c1 = [x ^ ord('a') for x in get_color(im, i)]
c2 = get_color(flag, i)
res += ''.join(chr(x ^ y) for x, y in zip(c1, c2))
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment