728x90
1. 문제 설명

STEP 1하고 2를 통과하여 FLAG 페이지에 도달해야함을 확인한다.
2. 문제 풀이

먼저 사이트에 접속해본다.
import os
from flask import Flask, request, render_template, redirect, url_for
import sys
app = Flask(__name__)
try:
# flag is here!
FLAG = open("./flag.txt", "r").read()
except:
FLAG = "[**FLAG**]"
@app.route("/")
def index():
return render_template("index.html")
@app.route("/step1", methods=["GET", "POST"])
def step1():
#### 풀이와 관계없는 치팅 방지 코드
global step1_num
step1_num = int.from_bytes(os.urandom(16), sys.byteorder)
####
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")
@app.route("/step2", methods=["GET", "POST"])
def step2():
if request.method == "GET":
#### 풀이와 관계없는 치팅 방지 코드
if request.args.get("prev_step_num"):
try:
prev_step_num = request.args.get("prev_step_num")
if prev_step_num == str(step1_num):
global step2_num
step2_num = int.from_bytes(os.urandom(16), sys.byteorder)
return render_template("step2.html", prev_step_num = step1_num, hidden_num = step2_num)
except:
return render_template("step2.html", text="Not yet")
return render_template("step2.html", text="Not yet")
####
else:
return render_template("step2.html", text="Not POST")
@app.route("/flag", methods=["GET", "POST"])
def flag():
if request.method == "GET":
return render_template("flag.html", flag_txt="Not yet")
else:
#### 풀이와 관계없는 치팅 방지 코드
prev_step_num = request.form.get("check", "")
try:
if prev_step_num == str(step2_num):
####
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")
app.run(host="0.0.0.0", port=8000)
주어진 코드에 답이 전부 있다. prm1과 prm2의 값이랑 똑같이 적어준다.


위 코드대로 적으면 STEP1과 STEP2를 통과할 수 있다.

전부 통과하면 DH{}로 시작하는 FLAG값이 출력된다.
3. 정리
py파일 보고 그대로 따라하면 쉽게 FLAG를 구할 수 있다.
'컴퓨터 공부 > Dreamhack' 카테고리의 다른 글
| Dreamhack Flying Chars 문제 풀이 (0) | 2025.12.30 |
|---|---|
| Dreamhack php7cmp4re 문제 풀이 (0) | 2025.12.30 |
| Dreamhack file-download-1 문제 풀이 (0) | 2025.12.30 |
| Dreamhack xss-1 문제 풀이 (0) | 2025.12.30 |
| Dreamhack devtools-source 문제 풀이 (0) | 2025.12.30 |
댓글