Skip to content

Commit ef3af01

Browse files
committed
ECSC2022
1 parent ce56a10 commit ef3af01

File tree

37 files changed

+1125
-323
lines changed

37 files changed

+1125
-323
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "saarctf-gameserver"]
2+
path = saarctf-gameserver
3+
url = https://github.com/ECSC2022/saarctf-gameserver.git

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM python:3.8 as gameserver-base
2+
RUN apt-get update && apt-get install -y libmemcached-dev libsystemd-dev postgresql-client && rm -rf /var/lib/apt/lists/*
3+
ADD src /opt/ctf-gameserver/src/
4+
ADD scripts /opt/ctf-gameserver/scripts/
5+
ADD setup.py Makefile /opt/ctf-gameserver/
6+
RUN cd /opt/ctf-gameserver && make ext
7+
RUN mkdir -p /etc/ctf-gameserver
8+
RUN pip install /opt/ctf-gameserver[prod]
9+
10+
FROM gameserver-base as web
11+
RUN pip install uwsgi
12+
RUN mkdir /uploads && chmod -R 777 /uploads
13+
ADD conf/web/prod_settings.py /etc/ctf-gameserver/web/
14+
ADD doc/controller/scoring.sql /scoring.sql
15+
ADD doc/controller/scoreboard_v2.sql /scoreboard_v2.sql
16+
ENV CTF_IPPATTERN=10.10.%s.1
17+
EXPOSE 5000
18+
CMD uwsgi --http-socket 0.0.0.0:5000 --module ctf_gameserver.web.wsgi \
19+
--python-path=/etc/ctf-gameserver/web \
20+
--env "CTF_IPPATTERN=${CTF_IPPATTERN}" \
21+
--env "DJANGO_SETTINGS_MODULE=prod_settings" \
22+
--static-map '/static/admin=/usr/local/lib/python3.8/site-packages/django/contrib/admin/static/admin' \
23+
--static-map '/static=/usr/local/lib/python3.8/site-packages/ctf_gameserver/web/static'
24+
25+
FROM web as web-init
26+
RUN pip install ansible passlib
27+
COPY ./init/docker-init.sh /bin/
28+
COPY ./init/ansible /ansible/
29+
CMD /bin/docker-init.sh
30+
31+
FROM gameserver-base as submission
32+
RUN useradd -m -U -s /bin/bash ctf-submission
33+
USER ctf-submission
34+
ENTRYPOINT [ "ctf-submission" ]
35+
36+
FROM gameserver-base as controller
37+
RUN useradd -m -U -s /bin/bash ctf-controller
38+
USER ctf-controller
39+
ENTRYPOINT [ "ctf-controller" ]
40+
41+
FROM gameserver-base as checkerbase
42+
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
43+
RUN useradd -m -U -s /bin/bash ctf-checkermaster
44+
RUN useradd -m -U -s /bin/bash ctf-checkerrunner
45+
ADD examples/checker/sudoers.d/ctf-checker /etc/sudoers.d/
46+
ADD scripts/checker/docker-entrypoint.sh /sbin/
47+
#USER ctf-checkermaster # do this downstream checkers
48+
ENV CTF_SUDOUSER ctf-checkerrunner
49+
ENTRYPOINT [ "/sbin/docker-entrypoint.sh" ]

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
CTF Gameserver
1+
CTF Gameserver (ECSC 2022 Version)
2+
==============
3+
4+
This repo contains the FAUST framework with adaptations for the European Cyber Security Challenge 2022. The main changes are:
5+
6+
- Added support for multiple flagstores per challenge via ServiceGroups
7+
- Separate checker for each flagstore, Flags and SLA status is evaluated for each flagstore
8+
- Points are aggregated by ServiceGroup
9+
- Attack and Defense Points are calculated according to the original FaustCTF formula
10+
- SLA points depend on other services of the same ServiceGroup:
11+
- ServiceGroups with all services up give SLA points according to the original FaustCTF formula
12+
- ServiceGroups with at least one service recovering give 50% of regular SLA points
13+
- ServiceGroups with at least one service down/faulty/not checked give SLA 0 points
14+
- Added checker status messages, telling participants what went wrong
15+
- Improved integration with the Saarctf scoreboard:
16+
- Added ability to freeze the scoreboard
17+
- Displaying of team IP addresses
18+
- Displaying of service status messages
19+
- First blood is displayed per flagstore
20+
- Added checker logging via Loki
21+
- ECSC-specific theme changes
22+
23+
Original README
224
==============
325

426
This is a gameserver for [attack-defense (IT security) CTFs](https://ctftime.org/ctf-wtf/). It was originally

conf/web/prod_settings.py

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
DATABASES = {
3131
'default': {
3232
'ENGINE': 'django.db.backends.postgresql',
33-
'HOST': '',
34-
'PORT': '',
35-
'NAME': '',
36-
'USER': '',
37-
'PASSWORD': '',
33+
'HOST': 'gameserver-postgres',
34+
'PORT': 5432,
35+
'NAME': 'ctf-gameserver',
36+
'USER': 'ctf-gameserver',
37+
'PASSWORD': '9iyzXY6pMYzRvXZi',
3838
'CONN_MAX_AGE': 60
3939
}
4040
}
@@ -44,42 +44,44 @@
4444
CACHES = {
4545
'default': {
4646
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
47-
'LOCATION': '',
47+
'LOCATION': 'gameserver-memcached:11211',
4848
'TIMEOUT': 60
4949
}
5050
}
5151

5252
# Settings for the SMTP server that will be used to send email messages
5353
# See https://docs.djangoproject.com/en/1.8/ref/settings/#email-host and other options
54-
EMAIL_HOST = ''
55-
EMAIL_PORT = 25
56-
EMAIL_HOST_USER = ''
57-
EMAIL_HOST_PASSWORD = ''
58-
# See https://docs.djangoproject.com/en/1.8/ref/settings/#email-use-tls
59-
EMAIL_USE_TLS = False
60-
EMAIL_USE_SSL = False
61-
62-
# Sender address for messages sent by the gameserver
63-
DEFAULT_FROM_EMAIL = ''
54+
# EMAIL_HOST = ''
55+
# EMAIL_PORT = 25
56+
# EMAIL_HOST_USER = ''
57+
# EMAIL_HOST_PASSWORD = ''
58+
# # See https://docs.djangoproject.com/en/1.8/ref/settings/#email-use-tls
59+
# EMAIL_USE_TLS = False
60+
# EMAIL_USE_SSL = False
61+
62+
# # Sender address for messages sent by the gameserver
63+
# DEFAULT_FROM_EMAIL = ''
64+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
65+
DEFAULT_FROM_EMAIL = 'ctf-gameserver.web@localhost'
6466

6567
# Filesystem path where user-uploaded files are stored
6668
# This directory must be served by the web server under the path defined by MEDIA_URL in 'base_settings.py'
6769
# ("/uploads" by default)
68-
MEDIA_ROOT = ''
70+
MEDIA_ROOT = '/uploads'
6971

7072
# The backend used to store user sessions
7173
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
7274

7375
# A long, random string, which you are supposed to keep secret
74-
SECRET_KEY = ''
76+
SECRET_KEY = '4HqT2rlhn4efX7jZ2d8MkCBzgRLO0t33udFoqi5YEt72VeHhBv3pTI6pUIGsCPZP'
7577

7678
# Insert all hostnames your site is available under
7779
# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts
78-
ALLOWED_HOSTS = []
80+
ALLOWED_HOSTS = ['*']
7981

8082
# The name of the time zone (i.e. something like "Europe/Berlin") in which dates should be displayed
8183
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid options
82-
TIME_ZONE = ''
84+
TIME_ZONE = 'Europe/Vienna'
8385

8486
# First day of the week: 0 means Sunday, 1 means Monday and so on
8587
FIRST_DAY_OF_WEEK = 1
@@ -91,23 +93,23 @@
9193

9294
# You should not have to edit anything below this line
9395

94-
# Set up logging to syslog
95-
LOGGING = {
96-
'version': 1,
97-
'disable_existing_loggers': False,
98-
'handlers': {
99-
'syslog': {
100-
'class': 'logging.handlers.SysLogHandler',
101-
'address': '/dev/log'
102-
}
103-
},
104-
'loggers': {
105-
'django': {
106-
'handlers': ['syslog'],
107-
'level': 'WARNING'
108-
}
109-
}
110-
}
96+
# # Set up logging to syslog
97+
# LOGGING = {
98+
# 'version': 1,
99+
# 'disable_existing_loggers': False,
100+
# 'handlers': {
101+
# 'syslog': {
102+
# 'class': 'logging.handlers.SysLogHandler',
103+
# 'address': '/dev/log'
104+
# }
105+
# },
106+
# 'loggers': {
107+
# 'django': {
108+
# 'handlers': ['syslog'],
109+
# 'level': 'WARNING'
110+
# }
111+
# }
112+
# }
111113

112114
DEBUG = False
113115

0 commit comments

Comments
 (0)