alert("not found user");history.go(-1);' if pw == password: resp = make_r"> alert("not found user");history.go(-1);' if pw == password: resp = make_r"> alert("not found user");history.go(-1);' if pw == password: resp = make_r">

#!/usr/bin/python3from flask import Flask, request, render_template, make_response, redirect, url_for

app = Flask(__name__)

try:
    FLAG = open('./flag.txt', 'r').read()
except:
    FLAG = '[**FLAG**]'

users = {
    'guest': 'guest',
    'admin': FLAG
}

@app.route('/')
def index():
    username = request.cookies.get('username', None)
    if username:
        return render_template('index.html', text=f'Hello {username}, {"flag is " + FLAG if username == "admin" else "you are not admin"}')
    return render_template('index.html')

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'GET':
        return render_template('login.html')
    elif request.method == 'POST':
        username = request.form.get('username')
        password = request.form.get('password')
        try:
            pw = users[username]
        except:
            return '<script>alert("not found user");history.go(-1);</script>'
        if pw == password:
            resp = make_response(redirect(url_for('index')) )
            resp.set_cookie('username', username)
            return resp
        return '<script>alert("wrong password");history.go(-1);</script>'

app.run(host='0.0.0.0', port=8000)

대놓고 아이디와 비밀번호를 알려준다. 여기서 admin :  FLAG는 아이디와 비밀번호가 FLAG인 것을 나타낸다.

해당부분에서 깔끔하게 쿠키값을 변조하여 접속하면 단순히 플래그를 획득할 수 있다.