diff --git a/app.py b/app.py index 3b859a6..a85fe5e 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ import werkzeug from flask import Flask, render_template, request, url_for, session, redirect, g, abort import sqlite3 +from random import getrandbits connection = sqlite3.connect('database.db') cursor = connection.cursor() @@ -46,7 +47,7 @@ def sql(): user = cursor.fetchone() if not user: return render_template('sql-injection.html', error='Ошибка: неверный логин или пароль') - session['success_login'] = True + session['sql_flag'] = f'C4TchFl4g{{{hex(getrandbits(45))[2:]}}}' return redirect(url_for('success_login'), code=302) return render_template('sql-injection.html') @@ -58,10 +59,15 @@ def found(): def decode(): return render_template('decode.html') -@app.route("/success_login") +@app.route("/success_login", methods=('GET', 'POST')) def success_login(): - if session.get('success_login'): - return render_template('success.html') + if request.method == 'POST': + user_flag = request.form['user_flag'] + if user_flag == session.get('sql_flag'): + return render_template('success.html', success_flag='.') + return render_template('success.html', error='Ошибка: неверный флаг!') + if flag := session.get('sql_flag'): + return render_template('success.html', flag=flag) abort(404) @app.errorhandler(werkzeug.exceptions.NotFound) diff --git a/static/index.css b/static/index.css index db3b962..a32223c 100644 --- a/static/index.css +++ b/static/index.css @@ -13,17 +13,51 @@ overflow-y: auto; } +.task-done { + position: absolute; + position-area: center; + width: 100%; + height: 100%; + background-color: rgba(0,0,0,0.90); +} + ::-webkit-scrollbar { display: none; } +.divv { + background-color: rgb(0 0 0 / 85%); + border: dashed rgba(225, 225, 225, 0.75); + border-width: 2px 3px; + border-radius: 2rem/2rem; + box-sizing: border-box; + margin-left: 2rem; + margin-top: 2rem; +} + .profile { width: fit-content; + height: fit-content; max-width: 40rem; margin: 3.5rem 0rem; padding: 0.7rem 2rem; background-color: rgba(0,0,0, 0.85); text-align: left; +} + +.flag-input { + width: 20rem; + max-width: 40rem; + height: fit-content; + padding: 0.7rem 2rem; + padding-bottom: 1rem; + margin: 3.5rem 2rem ; + background-color: rgba(0,0,0, 0.85); + text-align: left; + border: dashed 0.13rem rgba(225,225,225,0.8); + border-radius: 2%; +} + .close-btn { display: block; @@ -38,8 +72,8 @@ } .inpt { - width: 15vw; - height: 1vw; + width: 60%; + height: 1.2rem; box-shadow: 0.27em 0.27em 0em 0px rgba(186, 65, 166, 0.6); border: none; transition: 0.3s; @@ -116,15 +150,6 @@ } -.divv { - background-color: rgb(0 0 0 / 85%); - border: dashed rgba(225, 225, 225, 0.75); - border-width: 2px 3px; - border-radius: 2rem/2rem; - box-sizing: border-box; - margin-left: 2rem; - margin-top: 2rem; -} #sqlInpt { position: relative; diff --git a/templates/sql-injection.html b/templates/sql-injection.html index afd8d8e..1fd7f51 100644 --- a/templates/sql-injection.html +++ b/templates/sql-injection.html @@ -20,7 +20,7 @@ cursor.execute(f'SELECT * FROM Users WHERE login == "{login}" AND password == "{