Jury System for attack-defence ctf game (ctf-scoreboard). Or you can use it for training.
1.1K
Jury System for attack-defense ctf game (ctf-scoreboard). Also you can use it for training.

Requirements:
Create a folder with your game:
$ mkdir ~/my-first-game
$ cd ~/my-first-game
Create a ~/my-first-game/docker-compose.yml file with the following content:
version: '3'
services:
ctf01d_jury:
container_name: ctf01d_jury_my_game
image: sea5kg/ctf01d:latest
volumes:
- "./data:/usr/share/ctf01d"
environment:
CTF01D_WORKDIR: "/usr/share/ctf01d"
CTF01D_USER: 1000 # automatically will be changed rights to folder and files.
CTF01D_PORT: 8080
expose:
- "8080"
ports:
- "8080:8080"
# restart: always
networks:
- ctf01d_net
networks:
ctf01d_net:
driver: bridge
First start:
$ docker-compose up
After successful start, you will see logs similar to the following:
ctf01d_jury_1 | 2021-05-17 03:05:29.680, 0x00007f10cd69b700 [WARN] Checker: another_some example_service2 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.680, 0x00007f10cd69b700 [INFO] Checker: another_some example_service2 : Elapsed milliseconds: 106ms
ctf01d_jury_1 | 2021-05-17 03:05:29.684, 0x00007f10ce69d700 [WARN] Checker: another_some example_service1 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.684, 0x00007f10cde9c700 [WARN] Checker: so_some example_service1 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.685, 0x00007f10cde9c700 [INFO] Checker: so_some example_service1 : Elapsed milliseconds: 105ms
ctf01d_jury_1 | 2021-05-17 03:05:29.685, 0x00007f10cce9a700 [WARN] Checker: so_some example_service2 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.685, 0x00007f10cce9a700 [INFO] Checker: so_some example_service2 : Elapsed milliseconds: 109ms
ctf01d_jury_1 | 2021-05-17 03:05:29.685, 0x00007f10ce69d700 [INFO] Checker: another_some example_service1 : Elapsed milliseconds: 110ms
ctf01d_jury_1 | 2021-05-17 03:05:29.685, 0x00007f10bf7fe700 [WARN] Checker: another_some example_service3 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.686, 0x00007f10bf7fe700 [INFO] Checker: another_some example_service3 : Elapsed milliseconds: 110ms
ctf01d_jury_1 | 2021-05-17 03:05:29.690, 0x00007f10bdffb700 [WARN] Checker: so_some example_service3 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.690, 0x00007f10bdffb700 [INFO] Checker: so_some example_service3 : Elapsed milliseconds: 111ms
ctf01d_jury_1 | 2021-05-17 03:05:29.694, 0x00007f10bcff9700 [WARN] Checker: another_some example_service4 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.694, 0x00007f10bcff9700 [INFO] Checker: another_some example_service4 : Elapsed milliseconds: 108ms
ctf01d_jury_1 | 2021-05-17 03:05:29.694, 0x00007f10affff700 [WARN] Checker: so_some example_service4 : => service is down
ctf01d_jury_1 | 2021-05-17 03:05:29.695, 0x00007f10affff700 [INFO] Checker: so_some example_service4 : Elapsed milliseconds: 107ms
And you can also find dashboard on http://localhost:8080/
So now press Ctrl+C to stop docker-compose.
Change config file:
$ sudo chown $USER:$USER data
$ sudo chown $USER:$USER data/config.yml
Edit via any editor data/config.yml
And start ctf01d again:
$ docker-compose up
Uncomment:
# restart: always
And start like a daemon:
$ docker-compose up -d
url: http://{HOST}:{PORT}/
Where
Where
Example of sending a flag (via curl):
$ curl http://192.168.1.10:8080/flag?teamid=keva&flag=c01d4567-e89b-12d3-a456-426600000010
http-code responses:
Example of sending a flag (via python):
r = requests.get("http://192.168.1.10:8080/flag?teamid=keva&flag=c01d4567-e89b-12d3-a456-426600000010")
if r.status_code == 200:
print("OK (flag accepted) ", r.text)
sys.exit(0)
elif r.status_code == 403:
print("FAIL " + flag + " " + r.text)
sys.exit(0)
elif r.status_code == 400:
print("FAIL Request incorrect. " + r.text + "\n" + flag)
sys.exit(1)
else:
print("FAIL Something went wrong. " + str(r.status_code) + ", response"+ r.text)
Flag format description:
Flag example: c01d1fd2-133a-4713-9587-1f6a00000001
c01d...random-data-flag.....time
^ prefix ^ timestamp is the last 8 digits
always c01d (how many seconds have passed
since the start of the game)
http://{HOST}:{PORT}/flag - send flaghttp://{HOST}:{PORT}/api/v1/game - info about the gamehttp://{HOST}:{PORT}/api/v1/game/current-time - info about the gamehttp://{HOST}:{PORT}/api/v1/teams - list of teamshttp://{HOST}:{PORT}/api/v1/services - list of serviceshttp://{HOST}:{PORT}/api/v1/scoreboard - scoreboard table teams-serviceshttp://{HOST}:{PORT}/team-logo/{TEAMID} - team logoshttp://{HOST}:{PORT}/api/v1/my-ip - client ipflag_lifetime_in_seconds:
flag_cost_in_points:
EN:
Only the defense flag from the service is counted if:
RU:
Засчитываются только тот флаг защиты с сервиса, если:
EN:
The attack flag counts if:
RU:
Засчитывается флаг атаки, если:
Attack Flag Cost Calculation System
basic_flag_points = 1.0
motivation = 1.0
if victim_place_in_scoreboard > thief_place_in_scoreboard:
motivation -= (victim_place_in_scoreboard - thief_place_in_scoreboard) / (m_nTeamCount - 1);
attack_points_by_service1 = basic_flag_points * motivation
Team points are counted as:
team_points = team_points + SLA_1 * (service1_defense_points + service1_attack_points)
team_points = team_points + SLA_2 * (service2_defense_points + service2_attack_points)
...
team_points = team_points + SLA_N * (serviceN_defense_points + serviceN_attack_points)
$ sudo apt install git-core
$ cd ~
$ git clone http://github.com/sea5kg/ctf01d.git ctf01d.git
$ nano ~/ctf01d.git/data_sample/config.yml
Config files (see comments in file):
~/ctf01d.git/data_sample/config.yml - one configc++ webserver
database
C source code as an amalgamation
json
datetime
Icons
Content type
Image
Digest
sha256:3091dee18…
Size
163.8 MB
Last updated
3 months ago
docker pull sea5kg/ctf01d