Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit d6d211d

Browse files
committed
move stuff around to try to be more modular
1 parent 04b0815 commit d6d211d

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

hints/flags.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
stages = { # Sample dictionary with flags and multiple hints
2+
1: {
3+
"flag": "flag{stage1}",
4+
"hints": [
5+
"This is the least revealing hint for stage 1.",
6+
"This is a more revealing hint for stage 1.",
7+
"This is the most revealing hint for stage 1."
8+
]
9+
},
10+
2: {
11+
"flag": "flag{stage2}",
12+
"hints": [
13+
"This is the least revealing hint for stage 2.",
14+
"This is a more revealing hint for stage 2.",
15+
"This is the most revealing hint for stage 2."
16+
]
17+
},
18+
3: {
19+
"flag": "flag{stage3}",
20+
"hints": [
21+
"Almost there"
22+
]
23+
}
24+
}

hints/routes.py

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
11
from flask import Blueprint, render_template, request, redirect, url_for, flash, make_response, session
22
import datetime
3-
3+
from flags import stages
44
bp = Blueprint('ctf', __name__)
55

6-
# Sample dictionary with flags and multiple hints
7-
stages = {
8-
1: {
9-
"flag": "flag{stage1}",
10-
"hints": [
11-
"This is the least revealing hint for stage 1.",
12-
"This is a more revealing hint for stage 1.",
13-
"This is the most revealing hint for stage 1."
14-
]
15-
},
16-
2: {
17-
"flag": "flag{stage2}",
18-
"hints": [
19-
"This is the least revealing hint for stage 2.",
20-
"This is a more revealing hint for stage 2.",
21-
"This is the most revealing hint for stage 2."
22-
]
23-
},
24-
3: {
25-
"flag": "flag{stage3}",
26-
"hints": [
27-
"Almost there"
28-
]
29-
}
30-
}
6+
317

328
current_stage = 1
339
hint_index = 0
@@ -88,27 +64,33 @@ def flags():
8864
return render_template('flags.html', stage=current_stage, hints=hints, hint_index=hint_index, submitted_flags=submitted_flags)
8965

9066

91-
@bp.route('/', methods=['GET', 'POST']) # also for index
92-
@bp.route('/index', methods=['GET', 'POST'])
93-
@bp.route('/home', methods=['GET', 'POST'])
94-
@bp.route('/index.html', methods=['GET', 'POST'])
67+
@bp.route('/', methods=['GET']) # also for index
68+
@bp.route('/index', methods=['GET'])
69+
@bp.route('/home', methods=['GET'])
70+
@bp.route('/index.html', methods=['GET'])
9571
def index():
9672
# initialize session variables
9773
if "submitted_flags" not in session:
9874
session['submitted_flags'] = []
9975
if "current_stage" not in session:
10076
session['current_stage'] = 1
10177

102-
flash("Welcome to the CTF! Can you find the flags?", 'info')
78+
flash("Welcome to the CTF, please read the following messages: ", 'info')
10379
brief = """
104-
Do not use this site for any illegal activities, please do not attack it in any way as it harms other users who are solving the CTF.
80+
This site is not required to solve the CTF challenge. It does not store any of your flags, so make sure to keep track of them yourself!
81+
\n
82+
Do not use this site for any illegal activities, please do not attack it in any way as it harms other users who are solving the CTF.
83+
The site collects logs for security purposes.
10584
This site is not a part of the CTF challenge itself, but a tool to help you keep track of your progress. The flags are not hidden on this site. You need to find them on your own. Good luck!
85+
\n
10686
"""
10787

108-
return render_template('index.html', summary= brief)
88+
return render_template('index.html', summary=brief)
10989

110-
@bp.route('/restart')
111-
@bp.route('/reset')
90+
@bp.route('/restart', methods=['GET'])
91+
@bp.route('/restart.html', methods=['GET'])
92+
@bp.route('/reset', methods=['GET'])
93+
@bp.route('/reset.html', methods=['GET'])
11294
def restart():
11395
session.clear()
11496
flash("Progress reset. You are back to Stage 1.", 'info')

hints/templates/flags.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h3>Stage {{ stage }}</h3>
1515
<form method="POST">
1616
<div class="form-group">
1717
<label for="flag">Enter Flag:</label>
18-
<input type="text" id="flag" name="flag" class="form-control" placeholder="flag{...}">
18+
<input type="text" id="flag" name="flag" class="form-control" placeholder="flag{...}" required>
1919
</div>
2020
<button type="submit" name="submit_flag" class="btn btn-primary">Submit Flag</button>
2121
</form>

hints/templates/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
3131
<li class="nav-item"><a href="{{ url_for('ctf.index') }}" class="nav-link px-2 text-muted">Home</a></li>
3232
<li class="nav-item"><a href="{{ url_for('ctf.flags') }}" class="nav-link px-2 text-muted">Flags</a></li>
33-
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">Pricing</a></li>
33+
<!-- <li class="nav-item"><a href="#" class="nav-link px-2 text-muted">Pricing</a></li>
3434
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">FAQs</a></li>
35-
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">About</a></li>
35+
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">About</a></li> -->
3636
</ul>
3737
<p class="text-center text-muted">&copy; {{year}} aviparshan.com</p>
3838
</footer>

0 commit comments

Comments
 (0)