문제 소스코드를 보면 다음과 같다.
users = {
'guest': 'guest',
'user': 'user1234',
'admin': FLAG
}
@app.route('/')
def index():
session_id = request.cookies.get('sessionid', None)
try:
# get username from session_storage
username = session_storage[session_id]
except KeyError:
return render_template('index.html')
return render_template('index.html', text=f'Hello {username}, {"flag is " + FLAG if username == "admin" else "you are not admin"}')
@app.route('/admin')
def admin():
# developer's note: review below commented code and uncomment it (TODO)
#session_id = request.cookies.get('sessionid', None)
#username = session_storage[session_id]
#if username != 'admin':
# return render_template('index.html')
return session_storage
문제에서 주어진 guest계정으로 로그인을 하면 admin이 아니라고 뜬다.
/admin페이지에 접속해보면 session_storage에 저장된 값들을 볼 수 있다.
여기서 admin 값도 확인할 수 있다.
확인한 admin값을 sessionid라는 이름의 쿠기에 넣고 새로고침을 하면 flag를 얻을 수 있다.
* 쿠키는 크롬 개발자 도구 또는 editthiscookie 등의 도구를 사용하면 된다.