Very Secure

Description

web/very-secure (by _____) | 439 points

this website is obviously 100% secure

Website: http://very-secure.hsctf.com/arrow-up-right

File: very-secure.ziparrow-up-right

Analysis

Website is an empty placeholder for content.

If we take a look inside zip we can find the source code for application.

from flask import Flask, render_template, session
import os

app = Flask(__name__)
SECRET_KEY = os.urandom(2)
app.config['SECRET_KEY'] = SECRET_KEY
FLAG = open("flag.txt", "r").read()

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/flag')
def get_flag():
    if "name" not in session:
        session['name'] = "user"
    is_admin = session['name'] == "admin"
    return render_template("flag.html", flag=FLAG, admin = is_admin)

if __name__ == '__main__':
    app.run()

Flag is located at /flag but we need admin privileges. privilege is checked from session (cookie). So we have to decode the cookie, change the value, encode and replace.

Solution

First I generated all possible keys which os.urandom(2) can generate.

After that I used flask-unsignarrow-up-right to get the secret key.

Forge new key

Change cookie value -> Visit /flag -> Submit

Last updated