본문 바로가기

드림핵

[드림핵 워게임] random-test

<문제>

 

<풀이>

문제 사이트에 접속하면 처음으로 보이는 페이지이다.

 

알파벳 소문자와 숫자로 이루어진 4자리 문자열을 사물함 번호에 입력하고

100 이상 200 이하의 정수를 자물쇠 비밀번호에 입력해보았다.

 

Wrong! 이라는 결과가 뜬다.

 

이제 코드를 살펴본다.

@app.route("/", methods = ["GET", "POST"])
def index():
    if request.method == "GET":
        return render_template("index.html")
    else:
        locker_num = request.form.get("locker_num", "")
        password = request.form.get("password", "")

        if locker_num != "" and rand_str[0:len(locker_num)] == locker_num:
            if locker_num == rand_str and password == str(rand_num):
                return render_template("index.html", result = "FLAG:" + FLAG)
            return render_template("index.html", result = "Good")
        else: 
            return render_template("index.html", result = "Wrong!")

입력한 사물함 번호를 locker_num으로 받고 비밀번호를 password를 받는다.

입력한 locker_num의 길이만큼 rand_str과 비교한다.

그리고 locker_num과 rand_str이 일치하고, password와 rand_num이 일치하면,

즉 사물함 번호와 비밀번호를 정확하게 맞추면 FLAG를 출력한다.

 

locker_num의 길이만큼 rand_str과 비교하는 코드가 있기 때문에

쉽게 브루트포싱으로 rand_str을 알아낼 수 있다.

 

Burp Suite를 이용해 locker_num과 password를 전송하는 패킷을 잡고 Intruder로 보낸다.

위와 같이 locker_num 파라미터의 값에 payload position을 잡는다.

 

payloads 탭으로 이동해서 payload type을 Brute forcer 로 설정하고

payload settings를 위와 같이 한다.

Start attack을 클릭한다.

 

Length가 다른 한 payload가 찾고자 하는 값이다.

 

해당 값을 추가한 뒤 4번 더 같은 방식으로 Brute Force를 반복한다.

 

이런 방법으로 locker_num을 찾았으면 비슷한 방법으로 password를 찾는다.

 

비밀번호는 100~200의 정수이므로 Payload type을 Numbers로 설정한다.

 

비밀번호도 찾았다.

 

찾은 locker_num과 password를 입력한다.

 

FLAG가 출력되었다.

 

 

'드림핵' 카테고리의 다른 글

[드림핵 워게임] Apache htaccess  (0) 2023.09.01
[드림핵 워게임] baby-sqlite  (0) 2023.08.30
[드림핵 워게임] web-deserialize-python  (0) 2023.08.29
[드림핵 워게임] file-csp-1  (0) 2023.08.27
[드림핵 워게임] mongoboard  (0) 2023.08.22