forked from fausecteam/ctf-gameserver
-
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.
Merge branch 'master' into kdctf-2023
- Loading branch information
Showing
115 changed files
with
3,341 additions
and
1,845 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"image": "python:3.9-alpine", | ||
"updateContentCommand": "apk --no-cache add git curl build-base jpeg-dev zlib-dev iputils-ping", | ||
"postCreateCommand": "pip3 install --editable .[dev] && make dev", | ||
"extensions": ["ms-python.python"] | ||
} |
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
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
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 |
---|---|---|
@@ -1,63 +1,69 @@ | ||
CTF Gameserver | ||
============== | ||
|
||
This is a gameserver for [attack-defense (IT security) CTFs](https://ctftime.org/ctf-wtf/). It was originally | ||
written for [FAUST CTF 2015](https://www.faustctf.net/2015/), but is designed to be re-usable for other | ||
This is a Gameserver for [attack-defense (IT security) CTFs](https://ctftime.org/ctf-wtf/). It is used for | ||
hosting [FAUST CTF](https://www.faustctf.net), but designed to be re-usable for other competitions. It is | ||
scalable to large online CTFs, battle-tested in many editions of FAUST CTF, and customizable for other | ||
competitions. | ||
|
||
What's included | ||
For documentation on architecture, installation, etc., head to [ctf-gameserver.org](https://ctf-gameserver.org/). | ||
|
||
What's Included | ||
--------------- | ||
The gameserver consists of multiple components. They may be deployed separately of each other as their only | ||
means of communication is a shared database. | ||
The Gameserver consists of multiple components: | ||
|
||
* Web: A [Django](https://www.djangoproject.com/)-based web application for team registration and | ||
scoreboards. It also contains the model files, which define the database structure. | ||
* Web: A [Django](https://www.djangoproject.com/)-based web application for team registration, scoreboards, | ||
and simple hosting of informational pages. It also contains the model files, which define the database | ||
structure. | ||
* Controller: Coordinates the progress of the competition, e.g. the current tick and flags to be placed. | ||
* Checker: Offers an interface for checker scripts, which place and retrieve flags and test the status of | ||
services. | ||
* Checker: Place and retrieve flags and test the service status on all teams' Vulnboxes. The Checker Master | ||
launches Checker Scripts, which are individual to each service. | ||
* Checkerlib: Libraries to assist in developing Checker Scripts. Currently, Python and Go are supported. | ||
* Submission: Server to submit captured flags to. | ||
* Lib: Some code that is shared between the components. | ||
|
||
For deployment instructions and details on the implementations, see the `README`s of the individual | ||
components. | ||
* VPN Status: Optional helper that collects statistics about network connectivity to teams. | ||
|
||
Related projects | ||
Related Projects | ||
---------------- | ||
There are several alternatives out there, although none of them could really convince us. Your mileage may | ||
vary at this point. | ||
|
||
* ucsb-seclab/ictf-framework from the team behind iCTF, one of the most well-known | ||
attack-defense CTFs. In addition to a gameserver, it includes utilities for VM creation and network setup. | ||
We had trouble to get it running and documentation is generally rather rare. | ||
* HackerDom/checksystem is the gameserver powering the RuCTF. The first impression wasn't too bad, but it | ||
didn't look quite feature-complete to us. However, we didn't really grasp the Perl code, so we might have | ||
overlooked something. | ||
* isislab/CTFd appears to be de-facto standard for [jeopardy-based CTFs](https://ctftime.org/ctf-wtf/). It | ||
is, however, not suitable for an attack-defense CTF. | ||
There are several alternatives out there, although none of them could really convince us when we started the | ||
project in 2015. Your mileage may vary. | ||
|
||
* [ictf-framework](https://github.com/shellphish/ictf-framework) from the team behind iCTF, one of the most | ||
well-known attack-defense CTFs. In addition to a gameserver, it includes utilities for VM creation and | ||
network setup. We had trouble to get it running and documentation is generally rather scarce. | ||
* [HackerDom checksystem](https://github.com/HackerDom/checksystem) is the Gameserver powering RuCTF. The | ||
first impression wasn't too bad, but it didn't look quite feature-complete to us. However, we didn't really | ||
grasp the Perl code, so we might have overlooked something. | ||
* [saarctf-gameserver](https://github.com/MarkusBauer/saarctf-gameserver) from our friends at saarsec is | ||
younger than our Gameserver. It contains a nice scoreboard and infrastructure for VPN/network setup. | ||
* [EnoEngine](https://github.com/enowars/EnoEngine) by our other friends at ENOFLAG is also younger than | ||
our solution. | ||
* [CTFd](https://ctfd.io/) is the de-facto standard for [jeopardy-based CTFs](https://ctftime.org/ctf-wtf/). | ||
It is, however, not suitable for an attack-defense CTF. | ||
|
||
Another factor for the creation of our own system was that we didn't want to build a large CTF on top of a | ||
system which we don't entirely understand. | ||
|
||
Design principles | ||
----------------- | ||
The software will probably only be used once a year for severals hours, but it has to work reliably then. It | ||
will hopefully continue to be used by future generations. These requirements led to the incorporation of | ||
some principles: | ||
|
||
* Non-complex solutions: Keep the amount of code low and chose the less fancy path. That's why we use the | ||
built-in Django admin interface instead of writing a custom admin dashboard – it'll be good enough for the | ||
few people using it. | ||
* Few external dependencies: Of course one shouldn't re-invent the wheel all over again, but every external | ||
dependency means another moving part. Some libraries you always have to keep up with, others will become | ||
unmaintained. We therefore focus on few, mature, well-chosen external dependencies. That's why we use a | ||
plain old Makefile instead of [Bower](http://bower.io/) for JavaScript dependencies and Django's built-in | ||
PBKDF2 instead of fancy [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) for password hashing. | ||
* Extensive documentation: This should be a no-brainer for any project, although it is easier said than done. | ||
* Re-usability: The gameserver should be adjustable to your needs with some additional lines of code. An | ||
example for such customizations can be found in the `faustctf-2015` branch of this repository. | ||
* Scalability: We couldn't really estimate the load beforehand, nor could we easily do realistic | ||
load-testing. That's why the components are loosely coupled and can be run on different machines. | ||
|
||
Licensing | ||
Development | ||
----------- | ||
For a local development environment, set up a [Python venv](https://docs.python.org/3/library/venv.html) or | ||
use our [dev container](https://code.visualstudio.com/docs/devcontainers/containers) from | ||
`.devcontainer.json`. | ||
|
||
Then, run `make dev`. Tests can be executed through `make test` and a development instance of the Web | ||
component can be launched with `make run_web`. | ||
|
||
We always aim to keep our Python dependencies compatible with the versions packaged in Debian stable. | ||
Debian-based distributions are our primary target, but the Python code should generally be | ||
platform-independent. | ||
|
||
Security | ||
-------- | ||
Should you encounter any security vulnerabilities in the Gameserver, please report them to us privately. | ||
Use GitHub vulnerability reporting or contact Felix Dreissig or Simon Ruderich directly. | ||
|
||
Copyright | ||
--------- | ||
The whole gameserver is released under the MIT (expat) license. Contributions are welcome! | ||
The Gameserver was initially created by Christoph Egger and Felix Dreissig. It is currently maintained by | ||
Felix Dreissig and Simon Ruderich with contributions from others. | ||
|
||
It is released under the ISC License. |
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 |
---|---|---|
@@ -1,5 +1,2 @@ | ||
CTF_LOGLEVEL="INFO" | ||
CTF_DBHOST="localhost" | ||
CTF_DBNAME="ctf_gameserver" | ||
CTF_DBUSER="ctf_controller" | ||
CTF_DBPASSWORD="PASSWORD" | ||
CTF_DBNAME="DUMMY" | ||
CTF_DBUSER="DUMMY" |
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 |
---|---|---|
@@ -1,16 +1,34 @@ | ||
[Unit] | ||
Description=CTF Flag-Submission Service | ||
Wants=postgresql.service | ||
After=postgresql.service | ||
|
||
[Service] | ||
Type=notify | ||
DynamicUser=yes | ||
# Python breaks without HOME environment variable and with `DynamicUser` | ||
Environment=HOME=/tmp | ||
EnvironmentFile=/etc/ctf-gameserver/submission.env | ||
ExecStart=/usr/bin/ctf-submission --port %i | ||
User=nobody | ||
Group=nogroup | ||
RestartSec=10 | ||
EnvironmentFile=-/etc/ctf-gameserver/submission-%i.env | ||
ExecStart=/usr/bin/ctf-submission | ||
Restart=on-failure | ||
RestartSec=5 | ||
|
||
# Security options | ||
CapabilityBoundingSet= | ||
LockPersonality=yes | ||
MemoryDenyWriteExecute=yes | ||
NoNewPrivileges=yes | ||
PrivateDevices=yes | ||
PrivateTmp=yes | ||
PrivateUsers=yes | ||
ProtectControlGroups=yes | ||
ProtectHome=yes | ||
ProtectKernelModules=yes | ||
ProtectKernelTunables=yes | ||
ProtectSystem=strict | ||
RestrictNamespaces=yes | ||
RestrictRealtime=yes | ||
SystemCallArchitectures=native | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CTF_DBNAME="DUMMY" | ||
CTF_DBUSER="DUMMY" | ||
CTF_SECRET="DUMMY" | ||
|
||
CTF_FLAGSECRET="RFVNTVlTRUNSRVQ=" | ||
CTF_TEAMREGEX="^0\.0\.(\d+)\.\d+$" |
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,10 @@ | ||
CTF_DBNAME="DUMMY" | ||
CTF_DBUSER="DUMMY" | ||
|
||
CTF_WIREGUARD_IFPATTERN="wg%d" | ||
|
||
CTF_GATEWAY_IPPATTERN="0.0.%s.1" | ||
CTF_DEMO_IPPATTERN="0.0.%s.3" | ||
CTF_DEMO_SERVICEPORT="80" | ||
CTF_VULNBOX_IPPATTERN="0.0.%s.2" | ||
CTF_VULNBOX_SERVICEPORT="80" |
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,20 @@ | ||
[Unit] | ||
Description=CTF Gameserver Controller | ||
After=postgresql.service | ||
|
||
[Service] | ||
Type=notify | ||
User=ctf-vpnstatus | ||
EnvironmentFile=/etc/ctf-gameserver/vpnstatus.env | ||
ExecStart=/usr/bin/ctf-vpnstatus | ||
Restart=on-failure | ||
RestartSec=5 | ||
|
||
# Security options, cannot use any which imply `NoNewPrivileges` because checks can get executed using sudo | ||
PrivateTmp=yes | ||
ProtectControlGroups=yes | ||
ProtectHome=yes | ||
ProtectSystem=strict | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Oops, something went wrong.