#!/usr/bin/env python3 # -*- coding: utf-8 -*- from flask import Flask, render_template, request,session from config import create import os app = Flask(__name__) app.config['SECRET_KEY'] = os.urandom(24) ## flag is in /flag try to get it @app.route('/', methods=['GET', 'POST']) deffilter(string): for black_word in black_list: if black_word in string: return"hack" return string
if request.method == 'POST': input = request.form['input'] create_question = create() input_question = session.get('question') session['question'] = create_question if input_question==None: return render_template('index.html', answer="Invalid session please try again!", question=create_question) if filter(input)=="hack": return render_template('index.html', answer="hack", question=create_question) try: calc_result = str((eval(input_question + "=" + str(input)))) if calc_result == 'True': result = "Congratulations" elif calc_result == 'False': result = "Error" else: result = "Invalid" except: result = "Invalid" return render_template('index.html', answer=result,question=create_question) if request.method == 'GET': create_question = create() session['question'] = create_question return render_template('index.html',question=create_question) @app.route('/source') defsource(): return open("app.py", "r").read() if __name__ == '__main__': app.run(host="0.0.0.0", debug=False)