forked from CTFd/CTFd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from CTFd.plugins import register_plugin_assets_directory | ||
from CTFd.plugins.flags import FLAG_CLASSES, BaseFlag | ||
from CTFd.utils.user import get_current_user | ||
import hashlib | ||
|
||
|
||
# Represents a flag about | ||
class TryITFlag(BaseFlag): | ||
name = "TryIT" | ||
templates = { # Nunjucks templates used for key editing & viewing | ||
"create": "/plugins/daetsiinf_tryit_flag/assets/create.html", | ||
"update": "/plugins/daetsiinf_tryit_flag/assets/edit.html", | ||
} | ||
|
||
|
||
@staticmethod | ||
def compare(chal_key_obj, provided): | ||
saved = chal_key_obj.content | ||
|
||
expected_flag_content = "%d:%s" % (get_current_user().id, saved) | ||
expected_input = "tryIT{%s}" % hashlib.md5(expected_flag_content.encode('utf-8')).hexdigest() | ||
return expected_input == provided | ||
|
||
|
||
def load(app): | ||
FLAG_CLASSES["TryIT"] = TryITFlag | ||
register_plugin_assets_directory(app, base_path="/plugins/daetsiinf_tryit_flag/assets/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<label> | ||
TryIT Flag<br> | ||
<small>Enter the value for the TryIT flag. If you type "foo" as the value of the flag, | ||
players will need to type <code>TryIT{md5("playerid:foo")}</code> in order to solve it</small> | ||
</label> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" name="content" value="{{ content }}"> | ||
</div> | ||
<input type="hidden" name="type" value="TryIT"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<label> | ||
TryIT Flag<br> | ||
<small>Enter the value for the TryIT flag. If you type "foo" as the value of the flag, | ||
players will need to type <code>TryIT{md5("playerid:foo")}</code> in order to solve it</small> | ||
</label> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" name="content" value="{{ content }}"> | ||
</div> | ||
<input type="hidden" name="type" value="TryIT"> | ||
<input type="hidden" name="id" value="{{ id }}"> | ||
<hr> | ||
<div class="form-group"> | ||
<button class="btn btn-success float-right">Update</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters