๐Ÿ”’ Cyber Security/Web Hacking (์›นํ•ดํ‚น)

[DreamHack] ๋“œ๋ฆผํ•ต ์›นํ•ดํ‚น : ๐ŸŒฑ simple-web-request

์„ ๋‹ฌ 2023. 8. 14. 16:42
๋ฐ˜์‘ํ˜•

https://dreamhack.io/wargame/challenges/830

 

๐ŸŒฑ simple-web-request

Description STEP 1~2๋ฅผ ๊ฑฐ์ณ FLAG ํŽ˜์ด์ง€์— ๋„๋‹ฌํ•˜๋ฉด ํ”Œ๋ž˜๊ทธ๊ฐ€ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ๋‹จ๊ณ„๋ฅผ ํ†ต๊ณผํ•˜์—ฌ ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. ํ”Œ๋ž˜๊ทธ๋Š” flag.txt ํŒŒ์ผ๊ณผ FLAG ๋ณ€์ˆ˜์— ์žˆ์Šต๋‹ˆ๋‹ค. ํ”Œ๋ž˜๊ทธ ํ˜•์‹์€ DH{...} ์ž…๋‹ˆ๋‹ค. ๐Ÿ“œ

dreamhack.io

 

๋ฌธ์ œ

STEP 1~2๋ฅผ ๊ฑฐ์ณ FLAG ํŽ˜์ด์ง€์— ๋„๋‹ฌํ•˜๋ฉด ํ”Œ๋ž˜๊ทธ๊ฐ€ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.
๋ชจ๋“  ๋‹จ๊ณ„๋ฅผ ํ†ต๊ณผํ•˜์—ฌ ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. ํ”Œ๋ž˜๊ทธ๋Š” flag.txt ํŒŒ์ผ๊ณผ FLAG ๋ณ€์ˆ˜์— ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”Œ๋ž˜๊ทธ ํ˜•์‹์€ DH{…} ์ž…๋‹ˆ๋‹ค.

 

ํ’€์ด

๋ฌธ์ œ ํŒŒ์ผ์„ ์ฝ์„ ์ˆ˜๋งŒ ์žˆ์œผ๋ฉด ๋ฐ”๋กœ ํ•ด๊ฒฐ๋˜๋Š” ๋ฌธ์ œ

 

@app.route("/step1", methods=["GET", "POST"])
def step1():
    if request.method == "GET":
        prm1 = request.args.get("param", "")
        prm2 = request.args.get("param2", "")
        step1_text = "param : " + prm1 + "\nparam2 : " + prm2 + "\n"
        if prm1 == "getget" and prm2 == "rerequest":
            return redirect(url_for("step2", prev_step_num = step1_num))
        return render_template("step1.html", text = step1_text)
    else: 
        return render_template("step1.html", text = "Not POST")

prm1์— getget, prm2์— rerequest๋ฅผ ๋„ฃ์œผ๋ฉด step2๋กœ ์ด๋™ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค

 

์™€! ์ด๋™ํ–ˆ๋‹ค !

 

@app.route("/flag", methods=["GET", "POST"])
def flag():
    if request.method == "GET":
        return render_template("flag.html", flag_txt="Not yet")
    else:
                prm1 = request.form.get("param", "")
                prm2 = request.form.get("param2", "")
                if prm1 == "pooost" and prm2 == "requeeest":
                    return render_template("flag.html", flag_txt=FLAG)
                else:
                    return redirect(url_for("step2", prev_step_num = str(step1_num)))
            return render_template("flag.html", flag_txt="Not yet")
        except:
            return render_template("flag.html", flag_txt="Not yet")

 

์ด์ชฝ ๋˜ํ•œ ์ฝ”๋“œ์— ๋‚˜์™€์žˆ๋Š”๋Œ€๋กœ pooost ์™€ requeeest๋ฅผ ์ž…๋ ฅํ•˜๋ฉด

 

๋‹ต ํ”Œ๋ž˜๊ทธ๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค

๋ฐ˜์‘ํ˜•