from flask import Flask, request

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello"

@app.route("/flag", methods = ["GET", "POST"])
def flag():
    if request.method == "GET":
        return "서버 소스코드를 읽고 알맞은 요청을 보내보세요."
    elif request.method == "POST":
        if request.form.get("key1") == "hehe":
            if request.form.get("key2") == "529ca8050a00180790cf88b63468826a":
                return "L7{**SECRET**}"
            else:
                return "거의 다왔습니다."
        else:
            return "좋은 시도입니다."

app.run(host="0.0.0.0",port=10000)

Untitled

파이썬으로 작성된 사이트다. 먼저 코드 분석을 해보자.

Untitled

경로 /flag에서 GET방식과 POST 방식으로 요청을 보낼 수 있다.

그중 POST 방식으로 key1값과 Key2값을 보내면 플래그를 출력시킬 수 있을 것이다.

import requests

url = "<http://158.247.218.9:10000/flag>"
headers = {
    "Host": "158.247.218.9:10000",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.110 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
    "Connection": "close",
}

data = {
    "key1": "hehe",
    "key2": "529ca8050a00180790cf88b63468826a"
}

response = requests.post(url, headers=headers, data=data)
print(response.text)

작성한 페이로드는 위와 같다.

Untitled