From 1acd05d3b36fdc34c3ed3a9f17d932e7bdfdf89a Mon Sep 17 00:00:00 2001 From: John Hammond Date: Wed, 17 Aug 2016 08:58:35 -0400 Subject: [PATCH] Renamed `skeleton` folder to `ctf_skeleton` and made it clear it is a separate project in the README --- README.md | 7 +- {skeleton => ctf_skeleton}/certificate.crt | 0 {skeleton => ctf_skeleton}/clean.sh | 0 {skeleton => ctf_skeleton}/privateKey.key | 0 {skeleton => ctf_skeleton}/schema.sql | 0 {skeleton => ctf_skeleton}/server.py | 0 .../services/balloon_saloon/balloon_saloon.py | 0 .../balloon_saloon/balloon_saloon2.py | 0 .../services/balloon_saloon/flag | 0 .../services/base_service/base_service.py | 0 .../services/bit_bot/bitbot.py | 0 .../services/bit_bot/flag | 0 .../services/bytebot/bytebot.py | 0 .../services/bytebot/flag | 0 .../services/d-code/d-code.py | 0 .../services/d-code/flag | 0 .../services/flagger/flag | 0 .../services/flagger/flagger.py | 0 .../services/lampchamp0/exploit_lampchamp.py | 0 .../services/lampchamp0/flag | 0 .../services/lampchamp0/lampchamp.py | 0 .../services/lampchamp0/lamps.py | 0 .../services/lampchamp0/lamps.pyc | Bin .../services/qr-uiz/qr-uiz.py | 0 ctf_skeleton/setup.sh | 176 ++++++++++++++++++ {skeleton => ctf_skeleton}/static/control.js | 0 .../static/downloads/downloadable_file.txt | 0 .../static/downloads/downloadable_file.txt~ | 0 .../static/downloads/first/bowser.tar.gz | Bin .../downloads/first/captured_packets.pcapng | Bin .../downloads/first/easier_than_you_think.c | 0 .../downloads/first/i_will_drink_to_that.jpeg | Bin .../static/downloads/first/lolteam.pcapng | Bin .../first/looks_can_be_deceiving.rar | Bin .../static/downloads/first/lots_of_stego.pdf | Bin .../static/downloads/first/nagoya_castle.png | Bin .../static/downloads/first/page_11.png | Bin .../static/downloads/first/super_secure.zip | Bin .../static/jquery-ui.min.js | 0 {skeleton => ctf_skeleton}/static/jquery.js | 0 {skeleton => ctf_skeleton}/static/notify.js | 0 .../static/stylesheet.css | 0 {skeleton => ctf_skeleton}/stop.sh | 0 .../templates/about.html | 0 .../templates/base_page.html | 0 .../templates/challenges.html | 0 .../templates/login.html | 0 .../templates/register.html | 0 .../templates/scoreboard.html | 0 .../templates/stylesheet.css | 0 skeleton/setup.sh => setup.sh | 0 51 files changed, 180 insertions(+), 3 deletions(-) rename {skeleton => ctf_skeleton}/certificate.crt (100%) rename {skeleton => ctf_skeleton}/clean.sh (100%) rename {skeleton => ctf_skeleton}/privateKey.key (100%) rename {skeleton => ctf_skeleton}/schema.sql (100%) rename {skeleton => ctf_skeleton}/server.py (100%) rename {skeleton => ctf_skeleton}/services/balloon_saloon/balloon_saloon.py (100%) rename {skeleton => ctf_skeleton}/services/balloon_saloon/balloon_saloon2.py (100%) rename {skeleton => ctf_skeleton}/services/balloon_saloon/flag (100%) rename {skeleton => ctf_skeleton}/services/base_service/base_service.py (100%) rename {skeleton => ctf_skeleton}/services/bit_bot/bitbot.py (100%) rename {skeleton => ctf_skeleton}/services/bit_bot/flag (100%) rename {skeleton => ctf_skeleton}/services/bytebot/bytebot.py (100%) rename {skeleton => ctf_skeleton}/services/bytebot/flag (100%) rename {skeleton => ctf_skeleton}/services/d-code/d-code.py (100%) rename {skeleton => ctf_skeleton}/services/d-code/flag (100%) rename {skeleton => ctf_skeleton}/services/flagger/flag (100%) rename {skeleton => ctf_skeleton}/services/flagger/flagger.py (100%) rename {skeleton => ctf_skeleton}/services/lampchamp0/exploit_lampchamp.py (100%) rename {skeleton => ctf_skeleton}/services/lampchamp0/flag (100%) rename {skeleton => ctf_skeleton}/services/lampchamp0/lampchamp.py (100%) rename {skeleton => ctf_skeleton}/services/lampchamp0/lamps.py (100%) rename {skeleton => ctf_skeleton}/services/lampchamp0/lamps.pyc (100%) rename {skeleton => ctf_skeleton}/services/qr-uiz/qr-uiz.py (100%) create mode 100755 ctf_skeleton/setup.sh rename {skeleton => ctf_skeleton}/static/control.js (100%) rename {skeleton => ctf_skeleton}/static/downloads/downloadable_file.txt (100%) rename {skeleton => ctf_skeleton}/static/downloads/downloadable_file.txt~ (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/bowser.tar.gz (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/captured_packets.pcapng (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/easier_than_you_think.c (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/i_will_drink_to_that.jpeg (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/lolteam.pcapng (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/looks_can_be_deceiving.rar (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/lots_of_stego.pdf (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/nagoya_castle.png (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/page_11.png (100%) rename {skeleton => ctf_skeleton}/static/downloads/first/super_secure.zip (100%) rename {skeleton => ctf_skeleton}/static/jquery-ui.min.js (100%) rename {skeleton => ctf_skeleton}/static/jquery.js (100%) rename {skeleton => ctf_skeleton}/static/notify.js (100%) rename {skeleton => ctf_skeleton}/static/stylesheet.css (100%) rename {skeleton => ctf_skeleton}/stop.sh (100%) rename {skeleton => ctf_skeleton}/templates/about.html (100%) rename {skeleton => ctf_skeleton}/templates/base_page.html (100%) rename {skeleton => ctf_skeleton}/templates/challenges.html (100%) rename {skeleton => ctf_skeleton}/templates/login.html (100%) rename {skeleton => ctf_skeleton}/templates/register.html (100%) rename {skeleton => ctf_skeleton}/templates/scoreboard.html (100%) rename {skeleton => ctf_skeleton}/templates/stylesheet.css (100%) rename skeleton/setup.sh => setup.sh (100%) mode change 100755 => 100644 diff --git a/README.md b/README.md index 8d730d9..747c07a 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ I plan to do this project in [Python] with [Flask]. File & Directory Information ---------------- -* [`skeleton/`](skeleton/) +* [`ctf_skeleton/`](ctf_skeleton/) - This directory holds some code from a recent CTF platform I tried to build on my own. I am using elements from it, so I just snagged to code to be able to cherry-pick off of it and change what I need to get this project rolling. + This directory holds some code from a recent CTF platform I tried to build on my own. I am using elements from it, so I just snagged to code to be able to cherry-pick off of it and change what I need to get this project rolling. __Do not consider it a part of this project; it is _not_. It is just included as a convenience for me while the BearShop project is still be developed.__ * [`schema.sql`](schema.sql) @@ -22,7 +22,8 @@ File & Directory Information * [`setup.sh`](setup.sh) - This is the [`bash`][bash] script that I planned on using to initially create the server. It sets up the database, creates private keys to be used, and modifies a "base" rendition of the server [Python] script to add all of the configuration variables that can be set _in the [`setup.sh`](setup,sh)_ script. + This is the [`bash`][bash] script that I planned on using to initially create the server. It sets up the database, creates private keys to be used, and modifies a "base" rendition of the server [Python] script to add all of the configuration variables that can be set _in the_ [`setup.sh`](setup.sh) script. + diff --git a/skeleton/certificate.crt b/ctf_skeleton/certificate.crt similarity index 100% rename from skeleton/certificate.crt rename to ctf_skeleton/certificate.crt diff --git a/skeleton/clean.sh b/ctf_skeleton/clean.sh similarity index 100% rename from skeleton/clean.sh rename to ctf_skeleton/clean.sh diff --git a/skeleton/privateKey.key b/ctf_skeleton/privateKey.key similarity index 100% rename from skeleton/privateKey.key rename to ctf_skeleton/privateKey.key diff --git a/skeleton/schema.sql b/ctf_skeleton/schema.sql similarity index 100% rename from skeleton/schema.sql rename to ctf_skeleton/schema.sql diff --git a/skeleton/server.py b/ctf_skeleton/server.py similarity index 100% rename from skeleton/server.py rename to ctf_skeleton/server.py diff --git a/skeleton/services/balloon_saloon/balloon_saloon.py b/ctf_skeleton/services/balloon_saloon/balloon_saloon.py similarity index 100% rename from skeleton/services/balloon_saloon/balloon_saloon.py rename to ctf_skeleton/services/balloon_saloon/balloon_saloon.py diff --git a/skeleton/services/balloon_saloon/balloon_saloon2.py b/ctf_skeleton/services/balloon_saloon/balloon_saloon2.py similarity index 100% rename from skeleton/services/balloon_saloon/balloon_saloon2.py rename to ctf_skeleton/services/balloon_saloon/balloon_saloon2.py diff --git a/skeleton/services/balloon_saloon/flag b/ctf_skeleton/services/balloon_saloon/flag similarity index 100% rename from skeleton/services/balloon_saloon/flag rename to ctf_skeleton/services/balloon_saloon/flag diff --git a/skeleton/services/base_service/base_service.py b/ctf_skeleton/services/base_service/base_service.py similarity index 100% rename from skeleton/services/base_service/base_service.py rename to ctf_skeleton/services/base_service/base_service.py diff --git a/skeleton/services/bit_bot/bitbot.py b/ctf_skeleton/services/bit_bot/bitbot.py similarity index 100% rename from skeleton/services/bit_bot/bitbot.py rename to ctf_skeleton/services/bit_bot/bitbot.py diff --git a/skeleton/services/bit_bot/flag b/ctf_skeleton/services/bit_bot/flag similarity index 100% rename from skeleton/services/bit_bot/flag rename to ctf_skeleton/services/bit_bot/flag diff --git a/skeleton/services/bytebot/bytebot.py b/ctf_skeleton/services/bytebot/bytebot.py similarity index 100% rename from skeleton/services/bytebot/bytebot.py rename to ctf_skeleton/services/bytebot/bytebot.py diff --git a/skeleton/services/bytebot/flag b/ctf_skeleton/services/bytebot/flag similarity index 100% rename from skeleton/services/bytebot/flag rename to ctf_skeleton/services/bytebot/flag diff --git a/skeleton/services/d-code/d-code.py b/ctf_skeleton/services/d-code/d-code.py similarity index 100% rename from skeleton/services/d-code/d-code.py rename to ctf_skeleton/services/d-code/d-code.py diff --git a/skeleton/services/d-code/flag b/ctf_skeleton/services/d-code/flag similarity index 100% rename from skeleton/services/d-code/flag rename to ctf_skeleton/services/d-code/flag diff --git a/skeleton/services/flagger/flag b/ctf_skeleton/services/flagger/flag similarity index 100% rename from skeleton/services/flagger/flag rename to ctf_skeleton/services/flagger/flag diff --git a/skeleton/services/flagger/flagger.py b/ctf_skeleton/services/flagger/flagger.py similarity index 100% rename from skeleton/services/flagger/flagger.py rename to ctf_skeleton/services/flagger/flagger.py diff --git a/skeleton/services/lampchamp0/exploit_lampchamp.py b/ctf_skeleton/services/lampchamp0/exploit_lampchamp.py similarity index 100% rename from skeleton/services/lampchamp0/exploit_lampchamp.py rename to ctf_skeleton/services/lampchamp0/exploit_lampchamp.py diff --git a/skeleton/services/lampchamp0/flag b/ctf_skeleton/services/lampchamp0/flag similarity index 100% rename from skeleton/services/lampchamp0/flag rename to ctf_skeleton/services/lampchamp0/flag diff --git a/skeleton/services/lampchamp0/lampchamp.py b/ctf_skeleton/services/lampchamp0/lampchamp.py similarity index 100% rename from skeleton/services/lampchamp0/lampchamp.py rename to ctf_skeleton/services/lampchamp0/lampchamp.py diff --git a/skeleton/services/lampchamp0/lamps.py b/ctf_skeleton/services/lampchamp0/lamps.py similarity index 100% rename from skeleton/services/lampchamp0/lamps.py rename to ctf_skeleton/services/lampchamp0/lamps.py diff --git a/skeleton/services/lampchamp0/lamps.pyc b/ctf_skeleton/services/lampchamp0/lamps.pyc similarity index 100% rename from skeleton/services/lampchamp0/lamps.pyc rename to ctf_skeleton/services/lampchamp0/lamps.pyc diff --git a/skeleton/services/qr-uiz/qr-uiz.py b/ctf_skeleton/services/qr-uiz/qr-uiz.py similarity index 100% rename from skeleton/services/qr-uiz/qr-uiz.py rename to ctf_skeleton/services/qr-uiz/qr-uiz.py diff --git a/ctf_skeleton/setup.sh b/ctf_skeleton/setup.sh new file mode 100755 index 0000000..a0f262a --- /dev/null +++ b/ctf_skeleton/setup.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash +# Author: John Hammond +# Date: 11JAN2016 +# Description: +# This script should install all the necessary dependencies and generate a self-signing +# certificate to be used by a CTF server you can run on your own local machine. +# If you configure your own CTF with a .json file, you can give that to the server +# script and it will easily spin up a CTF competition for everyone in the local +# network. +# + +# Optional variables: this should be modified by the commandline arguments +DATABASE="" +CONFIGURATION="" + +# Internal variables; do not edit. +DEPENDENCIES="python-pip sqlite3 python-flask python-passlib" +SERVER_FILE="server_base.py" +NEW_SERVER_FILE="server.py" +SCHEMA_FILE="schema.sql" +PRIVATEKEY_FILE='privateKey.key' +CERTIFICATE_FILE='certificate.crt' + +CURRENT_USER=`logname` +RED=`tput setaf 1` # code for red console text +GREEN=`tput setaf 2` # code for green text +NC=`tput sgr0` # Reset the text color + +function display_help() { + cat < $NEW_SERVER_FILE || panic + sed -i "0,/\$PRIVATEKEY_FILE/{s/\$PRIVATEKEY_FILE/$PRIVATEKEY_FILE/}" $NEW_SERVER_FILE || panic + + +} + +function create_database(){ + + echo "$0: ${GREEN}creating sqlite3 database...${NC}" + + rm -f $DATABASE + sqlite3 $DATABASE < $SCHEMA_FILE || panic + chown $CURRENT_USER $DATABASE || panic + sed -i '0,/\$DATABASE/{s/\$DATABASE/'${DATABASE//\//\\/}'/}' $NEW_SERVER_FILE || panic + +} + +function configure_ctf(){ + + echo "$0: ${GREEN}configuring CTF...${NC}" + + sed -i "0,/\$CONFIGURATION/{s/\$CONFIGURATION/$CONFIGURATION/}" $NEW_SERVER_FILE || panic + +} + +function create_new_server(){ + + cp $SERVER_FILE $NEW_SERVER_FILE + chown $CURRENT_USER $NEW_SERVER_FILE + chmod 744 $NEW_SERVER_FILE +} + +function configure_firewall(){ + + # Allow incoming connections... + echo "$0: ${GREEN} Configuring firewall for HTTPS connections...${NC}" + ufw allow https +} + +function main() +{ + + install_dependencies + + create_new_server + + create_certificate + + create_database + + configure_ctf + + configure_firewall + + echo "$0: ${GREEN} CTF server successfully setup!${NC}" + echo "$0: ${GREEN} You should now be able to run the server with the command: ${NC}" + echo '`sudo python server.py`' + + exit 0 + +} + +# Print a fatal error message and exit +# Usage: +# some_command parameter || panic +# +# This will print the panic message and exit if `some_command` fails. +function panic +{ + echo "$0: ${RED}fatal error${NC}" + exit -1 +} + + +# Make sure the user is root (e.g. running as sudo) +if [ "$(id -u)" != "0" ]; then + echo "$0: ${RED}you must be root to configure this box.${NC}" + exit -1 +fi + +# Parse script options +while getopts d:c:h opt; do + + case $opt in + d) + echo "$0: ${GREEN}using database file ${OPTARG}${NC}" + DATABASE=$OPTARG + ;; + c) + echo "$0: ${GREEN}using configuration file ${OPTARG}${NC}" + CONFIGURATION=$OPTARG + ;; + h) + display_help + exit 0 + ;; + \?) + exit -1 + ;; + esac +done + + +# Make sure we entered a database name +if [ "$DATABASE" == "" ]; then + echo "$0: ${RED}you must specify a database file!${NC}" + display_help + exit -1 +fi + +# Make sure we entered a configuration file +if [ "$CONFIGURATION" == "" ]; then + echo "$0: ${RED}you must specify a configuration file!${NC}" + display_help + exit -1 +fi + +# This makes it so every function has a "pre-declaration" of all the functions +main "$@" \ No newline at end of file diff --git a/skeleton/static/control.js b/ctf_skeleton/static/control.js similarity index 100% rename from skeleton/static/control.js rename to ctf_skeleton/static/control.js diff --git a/skeleton/static/downloads/downloadable_file.txt b/ctf_skeleton/static/downloads/downloadable_file.txt similarity index 100% rename from skeleton/static/downloads/downloadable_file.txt rename to ctf_skeleton/static/downloads/downloadable_file.txt diff --git a/skeleton/static/downloads/downloadable_file.txt~ b/ctf_skeleton/static/downloads/downloadable_file.txt~ similarity index 100% rename from skeleton/static/downloads/downloadable_file.txt~ rename to ctf_skeleton/static/downloads/downloadable_file.txt~ diff --git a/skeleton/static/downloads/first/bowser.tar.gz b/ctf_skeleton/static/downloads/first/bowser.tar.gz similarity index 100% rename from skeleton/static/downloads/first/bowser.tar.gz rename to ctf_skeleton/static/downloads/first/bowser.tar.gz diff --git a/skeleton/static/downloads/first/captured_packets.pcapng b/ctf_skeleton/static/downloads/first/captured_packets.pcapng similarity index 100% rename from skeleton/static/downloads/first/captured_packets.pcapng rename to ctf_skeleton/static/downloads/first/captured_packets.pcapng diff --git a/skeleton/static/downloads/first/easier_than_you_think.c b/ctf_skeleton/static/downloads/first/easier_than_you_think.c similarity index 100% rename from skeleton/static/downloads/first/easier_than_you_think.c rename to ctf_skeleton/static/downloads/first/easier_than_you_think.c diff --git a/skeleton/static/downloads/first/i_will_drink_to_that.jpeg b/ctf_skeleton/static/downloads/first/i_will_drink_to_that.jpeg similarity index 100% rename from skeleton/static/downloads/first/i_will_drink_to_that.jpeg rename to ctf_skeleton/static/downloads/first/i_will_drink_to_that.jpeg diff --git a/skeleton/static/downloads/first/lolteam.pcapng b/ctf_skeleton/static/downloads/first/lolteam.pcapng similarity index 100% rename from skeleton/static/downloads/first/lolteam.pcapng rename to ctf_skeleton/static/downloads/first/lolteam.pcapng diff --git a/skeleton/static/downloads/first/looks_can_be_deceiving.rar b/ctf_skeleton/static/downloads/first/looks_can_be_deceiving.rar similarity index 100% rename from skeleton/static/downloads/first/looks_can_be_deceiving.rar rename to ctf_skeleton/static/downloads/first/looks_can_be_deceiving.rar diff --git a/skeleton/static/downloads/first/lots_of_stego.pdf b/ctf_skeleton/static/downloads/first/lots_of_stego.pdf similarity index 100% rename from skeleton/static/downloads/first/lots_of_stego.pdf rename to ctf_skeleton/static/downloads/first/lots_of_stego.pdf diff --git a/skeleton/static/downloads/first/nagoya_castle.png b/ctf_skeleton/static/downloads/first/nagoya_castle.png similarity index 100% rename from skeleton/static/downloads/first/nagoya_castle.png rename to ctf_skeleton/static/downloads/first/nagoya_castle.png diff --git a/skeleton/static/downloads/first/page_11.png b/ctf_skeleton/static/downloads/first/page_11.png similarity index 100% rename from skeleton/static/downloads/first/page_11.png rename to ctf_skeleton/static/downloads/first/page_11.png diff --git a/skeleton/static/downloads/first/super_secure.zip b/ctf_skeleton/static/downloads/first/super_secure.zip similarity index 100% rename from skeleton/static/downloads/first/super_secure.zip rename to ctf_skeleton/static/downloads/first/super_secure.zip diff --git a/skeleton/static/jquery-ui.min.js b/ctf_skeleton/static/jquery-ui.min.js similarity index 100% rename from skeleton/static/jquery-ui.min.js rename to ctf_skeleton/static/jquery-ui.min.js diff --git a/skeleton/static/jquery.js b/ctf_skeleton/static/jquery.js similarity index 100% rename from skeleton/static/jquery.js rename to ctf_skeleton/static/jquery.js diff --git a/skeleton/static/notify.js b/ctf_skeleton/static/notify.js similarity index 100% rename from skeleton/static/notify.js rename to ctf_skeleton/static/notify.js diff --git a/skeleton/static/stylesheet.css b/ctf_skeleton/static/stylesheet.css similarity index 100% rename from skeleton/static/stylesheet.css rename to ctf_skeleton/static/stylesheet.css diff --git a/skeleton/stop.sh b/ctf_skeleton/stop.sh similarity index 100% rename from skeleton/stop.sh rename to ctf_skeleton/stop.sh diff --git a/skeleton/templates/about.html b/ctf_skeleton/templates/about.html similarity index 100% rename from skeleton/templates/about.html rename to ctf_skeleton/templates/about.html diff --git a/skeleton/templates/base_page.html b/ctf_skeleton/templates/base_page.html similarity index 100% rename from skeleton/templates/base_page.html rename to ctf_skeleton/templates/base_page.html diff --git a/skeleton/templates/challenges.html b/ctf_skeleton/templates/challenges.html similarity index 100% rename from skeleton/templates/challenges.html rename to ctf_skeleton/templates/challenges.html diff --git a/skeleton/templates/login.html b/ctf_skeleton/templates/login.html similarity index 100% rename from skeleton/templates/login.html rename to ctf_skeleton/templates/login.html diff --git a/skeleton/templates/register.html b/ctf_skeleton/templates/register.html similarity index 100% rename from skeleton/templates/register.html rename to ctf_skeleton/templates/register.html diff --git a/skeleton/templates/scoreboard.html b/ctf_skeleton/templates/scoreboard.html similarity index 100% rename from skeleton/templates/scoreboard.html rename to ctf_skeleton/templates/scoreboard.html diff --git a/skeleton/templates/stylesheet.css b/ctf_skeleton/templates/stylesheet.css similarity index 100% rename from skeleton/templates/stylesheet.css rename to ctf_skeleton/templates/stylesheet.css diff --git a/skeleton/setup.sh b/setup.sh old mode 100755 new mode 100644 similarity index 100% rename from skeleton/setup.sh rename to setup.sh