diff --git a/app.py b/app.py index 12e709a..1ba9a61 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,11 @@ import werkzeug -from flask import Flask, render_template, request, url_for, session, redirect, g, abort, send_file +from flask import Flask, render_template, request, url_for, session, redirect, g, abort, send_file, render_template_string import sqlite3 from random import getrandbits from func import * import base64 + connection = sqlite3.connect('database.db') cursor = connection.cursor() cursor.execute(''' @@ -73,9 +74,35 @@ def webidor(): def webpt(): return render_template('path-traversal.html') -@app.route("/web/ssti") +@app.route("/web/ssti", methods=('GET', 'POST')) def webssti(): - return render_template('ssti.html') + id = session.get('ssti_id') + flag = session.get('flag_ssti') + if id not in comments.keys(): + session['ssti_id'] = id = hex(getrandbits(45))[2:] + comments[id] = [] + session['flag_ssti'] = flag = f'C4TchFl4g{{{hex(getrandbits(45))[2:]}}}' + + if request.method == 'POST': + if 'user_flag' in request.form.keys(): + user_flag = request.form['user_flag'] + if user_flag == flag: + return render_template('ssti.html', flag=flag, success_flag='.') + return render_template('ssti.html', flag=flag, error='Ошибка: неверный флаг!') + + username = request.form['username'] + comment = request.form['user_comment'] + comments[id].append((username, comment)) + def render(x): + try: + return render_template_string(x, flag=flag) + except: + return x + return render_template('ssti.html', render_template_string=render, comments=comments[id], flag=flag) + + +comments = {} + @app.route("/web/portswigger-guide") def webpsguide(): diff --git a/static/index.css b/static/index.css index fcbe31a..32e5fe0 100644 --- a/static/index.css +++ b/static/index.css @@ -168,6 +168,13 @@ align-content: flex-start; } +.comments { + background-color: rgb(35, 33, 54); + height: 60%; + width: 80%; + text-align: left; +} + .navgoodlinks { display:flex; justify-content: start; diff --git a/templates/ssti.html b/templates/ssti.html new file mode 100644 index 0000000..8a60acc --- /dev/null +++ b/templates/ssti.html @@ -0,0 +1,43 @@ +{% extends 'utils/_task.html' %} +{% include 'utils/_forensicsidenav.html' %} +{% block content %} + + +
+
+

Приветствую тебя, о сетевой путник! Прошу, оставь упоминание о себе здесь!

+
+

Имя:

+

Комментарий:

+ +
+
+ {% for (username, comment) in comments -%} +

{{ username }}

+

{{ render_template_string(comment) }}

+ {% endfor -%} +
+
+
+

Введите ответ:

+
+ + +
+
+
+ + + + {% if error %} +

{{ error }}

+ {% elif success_flag %} +
+

Вы прошли задание!

+ + < Вернуться к заданиям > +
+ {% endif %} +{% endblock %} \ No newline at end of file