Skip to content

Instantly share code, notes, and snippets.

@JohnHammond
Created September 2, 2018 02:04
Show Gist options
  • Save JohnHammond/00967a1f630f058d021a102da1f7e4c4 to your computer and use it in GitHub Desktop.
Save JohnHammond/00967a1f630f058d021a102da1f7e4c4 to your computer and use it in GitHub Desktop.
Codefest CTF 2018 "Polyglot" get_flag Script
#!/usr/bin/env python
import re
h = open('secret.c')
lines = [ x[:-1] for x in h.readlines() ] # remove newline char
h.close()
flag = []
for line in lines:
num =''.join(re.findall(r'\s+', line)).replace('\t','1').replace(' ','0')
if num:
try:
flag.append(chr(int(num,2)))
except:
pass
print re.findall(r'CodefestCTF{.*}', ''.join(flag)[::-1])[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment