Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions handlers/AdminHandlers/AdminGameObjectHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
FLAG_FILE,
FLAG_REGEX,
FLAG_STATIC,
FLAG_REMOTE,
FLAG_REMOTESTRING,
Flag,
)
from models.FlagAttachment import FlagAttachment
Expand Down Expand Up @@ -80,6 +82,8 @@ def get(self, *args, **kwargs):
"flag/static": "admin/create/flag-static.html",
"flag/datetime": "admin/create/flag-datetime.html",
"flag/choice": "admin/create/flag-choice.html",
"flag/remote": "admin/create/flag-remote.html",
"flag/remotestring": "admin/create/flag-remotestring.html",
"game_level": "admin/create/game_level.html",
"hint": "admin/create/hint.html",
"team": "admin/create/team.html",
Expand Down Expand Up @@ -107,6 +111,8 @@ def post(self, *args, **kwargs):
"flag/static": self.create_flag_static,
"flag/datetime": self.create_flag_datetime,
"flag/choice": self.create_flag_choice,
"flag/remote": self.create_flag_remote,
"flag/remotestring": self.create_flag_remotestring,
"game_level": self.create_game_level,
"hint": self.create_hint,
"team": self.create_team,
Expand Down Expand Up @@ -270,6 +276,25 @@ def create_flag_datetime(self):
"admin/create/flag-datetime.html", errors=[str(error)], box=None
)

def create_flag_remote(self):
"""Create a regex flag"""
try:
self._mkflag(FLAG_REMOTE)
except ValidationError as error:
self.render(
"admin/create/flag-remote.html", errors=[str(error)], box=None
)

def create_flag_remotestring(self):
"""Create a remote string flag"""
try:
self._mkflag(FLAG_REMOTESTRING)
except ValidationError as error:
self.render(
"admin/create/flag-remotestring.html", errors=[str(error)], box=None
)


def create_game_level(self):
"""
Creates a new level in the database, the levels are basically a
Expand Down
30 changes: 26 additions & 4 deletions handlers/MissionsHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import json
import logging
from builtins import next, str
from uuid import uuid4

from past.utils import old_div
from tornado.options import options
Expand Down Expand Up @@ -144,7 +145,7 @@ def get(self, *args, **kwargs):

@authenticated
@game_started
def post(self, *args, **kwargs):
async def post(self, *args, **kwargs):
"""Check validity of flag submissions"""
box_id = self.get_argument("box_id", None)
uuid = self.get_argument("uuid", "")
Expand Down Expand Up @@ -189,6 +190,8 @@ def post(self, *args, **kwargs):
if flag is not None and flag.is_file:
if hasattr(self.request, "files") and "flag" in self.request.files:
submission = self.request.files["flag"][0]["body"]
elif flag is not None and flag.is_remote:
submission = f"Remote Submission: {uuid4()}"
else:
submission = self.get_argument("token", "").replace("__quote__", '"')
if len(submission) == 0:
Expand All @@ -197,7 +200,7 @@ def post(self, *args, **kwargs):
)
return
old_reward = flag.dynamic_value(user.team) if flag is not None else 0
if flag is not None and self.attempt_capture(flag, submission):
if flag is not None and await self.attempt_capture(flag, submission):
self.add_content_policy("script", "'unsafe-eval'")
success = self.success_capture(user, flag, old_reward)
if options.story_mode:
Expand All @@ -219,11 +222,23 @@ def post(self, *args, **kwargs):
self.render_page_by_flag(flag, success=success)
return
else:
if flag is not None and flag in user.team.flags:
self.render_page_by_flag(flag)
return
self.failed_attempt(flag, user, submission, box_id)
else:
self.render("public/404.html")

def failed_attempt(self, flag, user, submission, box_id):
remote_error = (
flag is not None
and (flag.is_remote or flag.is_remotestring)
and flag.status == "error"
)
if remote_error:
msg = f"Error: {flag.message} please inform the trainer"
self.render_page_by_flag(flag, info=[msg])
return
if flag is None or Penalty.by_token_count(flag, user.team, submission) == 0:
if options.teams:
teamval = "team's "
Expand Down Expand Up @@ -252,6 +267,8 @@ def failed_attempt(self, flag, user, submission, box_id):
+ teamval
+ "score."
)
if flag is not None and (flag.is_remote or flag.is_remotestring):
penalty_dialog = f"{penalty_dialog} Message: {flag.message}"
if flag is None:
self.render_page_by_box_id(box_id, errors=[penalty_dialog])
else:
Expand All @@ -278,6 +295,8 @@ def success_capture(self, user, flag, old_reward=None):
teamval = ""
old_reward = flag.dynamic_value(user.team) if old_reward is None else old_reward
reward_dialog = flag.name + " answered correctly. "
if flag is not None and (flag.is_remote or flag.is_remotestring):
reward_dialog = f"{reward_dialog} Message: {flag.message}"
if options.banking:
reward_added_str_template = (
"${} has been added to your " + teamval + "account."
Expand Down Expand Up @@ -405,15 +424,18 @@ def failed_capture(self, flag, submission):
return penalty
return False

def attempt_capture(self, flag, submission):
async def attempt_capture(self, flag, submission):
"""Compares a user provided token to the token in the db"""
user = self.get_current_user()
team = user.team
logging.info(
"%s (%s) capture the flag '%s'" % (user.handle, team.name, flag.name)
)
if submission is not None and flag not in team.flags:
if flag.capture(submission):
captured = await flag.capture_async(
submission, player_ip=self.request.remote_ip
)
if captured and flag not in team.flags:
flag_value = flag.dynamic_value(team)
if (
options.dynamic_flag_value
Expand Down
6 changes: 6 additions & 0 deletions locale/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Create New Paste,Neuen Paste erstellen
Create Notification,Benachrichtigung erstellen
Create Regex Flag,Regex-Flagge erstellen
Create Static Flag,Statische Flagge erstellen
Create Remote Flag,Remote-Flagge erstellen
Create Remote String Flag,Remote-String-Flagge erstellen
Create Team,Team erstellen
Created,Erstellt
Current algorithm,Aktueller Algorithmus
Expand Down Expand Up @@ -258,6 +260,7 @@ Enter a Matching Flag,Geben Sie eine passende Flagge ein
Enter Choice,Auswahl eingeben
Enter the same password as before,Geben Sie dasselbe Passwort wie zuvor ein
ERROR,ERROR
Error, Fehler
Expire,Verlopen
Export Game Objects,Spielobjekte exportieren
Export of gameplay settings does not include the entire server and database configuration.,Der Export der Gameplay-Einstellungen umfasst nicht die gesamte Server- und Datenbankkonfiguration.
Expand All @@ -282,6 +285,7 @@ Flag Decrease Value,Flaggenwert verringern
Flag Details,Flaggendetails
Flag File,Flaggendatei
Flag Hints,Flaggenhinweise
Flag ID, Flaggen ID
Flag Minimum Value,Vlag Minimumwaarde
Flag Name,Flaggenname
Flag Penalty,Flaggenstrafe
Expand Down Expand Up @@ -338,6 +342,7 @@ In Progress,In Bearbeitung
"In this case, the flag is a Date / Time string. This flag type will try to match on common datetime format variations and deal with differences like slashes, dashes, padding, 12hr, 24hr, etc. It can handle a date, time, or a datetime.","In diesem Fall ist die Flagge eine Datums- / Uhrzeitzeichenfolge. Dieser Flaggentyp versucht, mit gängigen Datums- / Uhrzeit-Formatvariationen übereinzustimmen und behandelt Unterschiede wie Schrägstriche, Bindestriche, Auffüllungen, 12 Stunden, 24 Stunden usw. Er kann ein Datum, eine Uhrzeit oder eine Datums- / Uhrzeitangabe verarbeiten."
"In this case, the flag is a multiple choice question where the selected option is the token.","In diesem Fall ist die Flagge eine Multiple-Choice-Frage, bei der die ausgewählte Option das Token ist."
"In this case, the flag is a regular expression. The user must submit the a string which matches the pattern to capture the flag. Matches can be insensitive. Please be sure to test your regex, and ensure its not too broad.","In diesem Fall ist die Flagge ein regulärer Ausdruck. Der Benutzer muss eine Zeichenfolge übermitteln, die mit dem Muster übereinstimmt, um die Flagge zu erobern. Übereinstimmungen können unempfindlich sein. Bitte stellen Sie sicher, dass Sie Ihren regulären Ausdruck testen, und stellen Sie sicher, dass er nicht zu breit angelegt ist."
"In this case, the flag is a remote Flag, the ID is submited to the flag-check-server.","In diesem Fall ist die Flagge eine Remote-Flagge, die ID wird an den Flaggen-Test-Server übermittelt"
"In this case, the flag is a static string. The user must submit the exact token to capture the flag. Whitespace at the beginning and end are stripped.","In diesem Fall ist die Flagge eine statische Zeichenfolge. Der Benutzer muss das genaue Token senden, um die Flagge zu erobern. Leerzeichen am Anfang und Ende werden entfernt."
Include gameplay settings (such as those under ,Das Einbeziehen von Gameplay-Einstellungen (z. B. beim Exportieren von Gameplay-Einstellungen) umfasst nicht die gesamte Server- und Datenbankkonfiguration.
Income,Einkommen
Expand Down Expand Up @@ -483,6 +488,7 @@ Player Arrested!,Spieler verhaftet!
Player Email,Spieler E-Mail
Player Name,Spielername
"Player's bank account passwords are also available, allowing you to crack each other's passwords and steal the money.","Passwörter für das Bankkonto des Spielers sind ebenfalls verfügbar, sodass Sie die Passwörter des anderen knacken und das Geld stehlen können."
please inform your trainer ,Bitte informieren sie den Referenten.
Players,Spieler
Please do NOT enter your real bank account password.,Bitte geben Sie NICHT Ihr echtes Bankkonto-Passwort ein.
points,Punkte
Expand Down
Loading