diff --git a/CTFd/plugins/insanity_check/README.md b/CTFd/plugins/insanity_check/README.md new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/CTFd/plugins/insanity_check/README.md @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/CTFd/plugins/insanity_check/__init__.py b/CTFd/plugins/insanity_check/__init__.py new file mode 100644 index 0000000000..e0ec765c08 --- /dev/null +++ b/CTFd/plugins/insanity_check/__init__.py @@ -0,0 +1,39 @@ +from flask import Blueprint + +from CTFd.models import ( + ChallengeFiles, + Challenges, + Fails, + Flags, + Hints, + Solves, + Tags, + db, +) +from CTFd.plugins import register_plugin_assets_directory +from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge + +class InsaneChallenge(BaseChallenge): + id = "insane" # Unique identifier used to register challenges + name = "insane" # Name of a challenge type + + # locations of the html templates + templates = { # Handlebars templates used for each aspect of challenge editing & viewing + 'create': '/plugins/insanity_check/assets/create.html', + 'update': '/plugins/insanity_check/assets/update.html', + 'view': '/plugins/insanity_check/assets/view.html', + } + + # location of the JavaScript files + scripts = { # Scripts that are loaded when a template is loaded + 'create': '/plugins/insanity_check/assets/create.js', + 'update': '/plugins/insanity_check/assets/update.js', + 'view': '/plugins/insanity_check/assets/view.js', + } + + challenge_model = Challenges + +CHALLENGE_CLASSES["insane"] = InsaneChallenge + +def load(app): + register_plugin_assets_directory(app, base_path='/plugins/insanity_check/assets/') \ No newline at end of file diff --git a/CTFd/plugins/insanity_check/assets/create.html b/CTFd/plugins/insanity_check/assets/create.html new file mode 100644 index 0000000000..dd985c3630 --- /dev/null +++ b/CTFd/plugins/insanity_check/assets/create.html @@ -0,0 +1 @@ +{% extends "admin/challenges/create.html" %} \ No newline at end of file diff --git a/CTFd/plugins/insanity_check/assets/create.js b/CTFd/plugins/insanity_check/assets/create.js new file mode 100644 index 0000000000..5ba26b2a1b --- /dev/null +++ b/CTFd/plugins/insanity_check/assets/create.js @@ -0,0 +1,4 @@ +CTFd.plugin.run((_CTFd) => { + const $ = _CTFd.lib.$ + const md = _CTFd.lib.markdown() +}) \ No newline at end of file diff --git a/CTFd/plugins/insanity_check/assets/update.html b/CTFd/plugins/insanity_check/assets/update.html new file mode 100644 index 0000000000..faec1b7957 --- /dev/null +++ b/CTFd/plugins/insanity_check/assets/update.html @@ -0,0 +1,3 @@ +{% extends "admin/challenges/update.html" %} + +

hi

diff --git a/CTFd/plugins/insanity_check/assets/update.js b/CTFd/plugins/insanity_check/assets/update.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/CTFd/plugins/insanity_check/assets/view.html b/CTFd/plugins/insanity_check/assets/view.html new file mode 100644 index 0000000000..36d8015b1d --- /dev/null +++ b/CTFd/plugins/insanity_check/assets/view.html @@ -0,0 +1,140 @@ + \ No newline at end of file diff --git a/CTFd/plugins/insanity_check/assets/view.js b/CTFd/plugins/insanity_check/assets/view.js new file mode 100644 index 0000000000..0d055539ed --- /dev/null +++ b/CTFd/plugins/insanity_check/assets/view.js @@ -0,0 +1,37 @@ +CTFd._internal.challenge.data = undefined; + +// TODO: Remove in CTFd v4.0 +CTFd._internal.challenge.renderer = null; + +CTFd._internal.challenge.preRender = function() {}; + +// TODO: Remove in CTFd v4.0 +CTFd._internal.challenge.render = null; + +CTFd._internal.challenge.postRender = function() {}; + +CTFd._internal.challenge.submit = function(preview) { + var challenge_id = parseInt(CTFd.lib.$("#challenge-id").val()); + var submission = CTFd.lib.$("#challenge-input").val(); + + var body = { + challenge_id: challenge_id, + submission: submission + }; + var params = {}; + if (preview) { + params["preview"] = true; + } + + return CTFd.api.post_challenge_attempt(params, body).then(function(response) { + if (response.status === 429) { + // User was ratelimited but process response + return response; + } + if (response.status === 403) { + // User is not logged in or CTF is paused. + return response; + } + return response; + }); +}; \ No newline at end of file