Last active
June 11, 2017 16:05
-
-
Save elliptic-shiho/e2bf5ae0793f7a77c619470edfc9984a to your computer and use it in GitHub Desktop.
SHA2017 CTF Teaser: Crypto Engine Solver
This file contains hidden or 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 PIL import Image | |
| im = Image.open('flag.png') | |
| pix = im.load() | |
| t = [] | |
| for i in xrange(im.size[0] / 40): | |
| t += pix[i*40 + 5, 5] | |
| t += [0x2e, 0x29] | |
| k = [0x32, 0x30, 0x31, 0x37] | |
| s = '' | |
| for i, x in enumerate(t): | |
| s += chr(x ^ k[i % 4]) | |
| print repr(s) | |
| prev = '' | |
| res = s[:4] | |
| for i in xrange(0, len(s), 4): | |
| if prev != '': | |
| res += ''.join(map(lambda x: chr(ord(x[0]) ^ ord(x[1])), zip(s[i:i+4], prev))) | |
| prev = s[i:i+4] | |
| print res |
This file contains hidden or 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
| Mon Jun 12 01:01:34 JST 2017 ~/ctf/2017/sha2017-ctf 100% Full | |
| > python solve.py | |
| 'flag\x1d\x08\x04\x06{1<5\x1eS\x0f\x01{g74\x18\x02\x0eP*ch6\x1a\x02\r\x02.d57\x1c\x19' | |
| flag{deaf983eb34e485ce9d2aff0ae44f852} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment