sudo apt update
sudo apt install -y \
nginx \
redis-server \
docker.io \
nftables \
mysql-server \
gitsudo systemctl enable docker
sudo systemctl start docker
sudo systemctl enable redis
sudo systemctl start redis
sudo systemctl enable nginx
sudo systemctl enable nftables
sudo systemctl start nftableswget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# Follow the installation prompts
# Restart your shell or: source ~/.bashrcconda env create -f env.yml
conda activate xctf-platformmysql -u root -p
CREATE DATABASE xctf;
EXIT;
python manage.py migrateEdit /etc/redis/redis.conf and set a password:
requirepass your-redis-password
Restart Redis:
sudo systemctl restart redisMake sure to update REDIS_PASSWORD in your .env file.
Run the setup script to generate supervisor, uWSGI, and nginx configurations:
./setup-config.sh
# Create .env file
cp .env.example .env
nano .env # Edit with your production valuespython manage.py collectstatic --noinputsupervisord -c supervisord.conf
supervisorctl -c supervisord.conf start all
supervisorctl -c supervisord.conf status-
Create a challenge directory in
$CHALLENGES_DIR:$CHALLENGES_DIR/my-challenge/ ├── challenge/ │ └── (your challenge files) ├── Dockerfile └── metadata.json -
Create
metadata.json:{ "name": "My Challenge", "category": "Web", "points": 100, "flag": "FLAG_VALUE", "static": false, "tcp_ports": [8000] } -
Create
Dockerfilethat exposes port 8000 (required):FROM python:3.10-slim WORKDIR /app COPY challenge ./ EXPOSE 8000 CMD ["python", "app.py"]
-
Build and register the challenge:
python manage.py setup_challenges --challenge-name my-challenge
- Each challenge must expose its main server at port 8000 in the container
- Challenges can access their port mappings via
/data/.xctf_port_mappings.jsonin the container
Refer to this sample challenge for more details.
Access the admin panel at /admin (requires admin account).
Features:
- Edit challenge metadata
- Ban/unban users
- Send notifications to users
- Manage active Docker containers
- Redeploy challenges (refreshes all active sandboxes)
Admin accounts must be created directly in the database:
python manage.py shell
>>> from user_auth.models import User
>>> admin, _ = User.objects.get_or_create(username='admin', email='admin@example.com', is_admin=True, verified=True)
>>> admin.set_password('your-password')
>>> admin.save()The platform uses the following configuration files (generated by setup-config.sh):
- supervisord.conf
- gunicorn_config.py
- nginx.conf
- .env.example
- flower_env.sh
The platform runs the following services:
- django-server: uWSGI Flask application
- celery-beat: Celery scheduler
- celery-worker-*: Celery worker processes (4 workers by default)
- flower: Celery monitoring dashboard
- Currently, nftables entries are used to restrict who can access what ports. This helps blocking a user from interferring with other user's sandbox containers. But it has a subtle flaw -- 2 or more users can have same IPs if they are behind a VPN or under same NAT.
- Only one IP per user is valid at a time. If a user logs in from a new IP, any active sandbox ports access is transferred from old IP to thio new IP, and previous session(s) of user is invalidated.
- Explore alternatives for port access restriction with minimal user and challenge maker effort.
- SSL certificate installed and working
- All environment variables set correctly
- Database migrations applied
- Static files collected
- Admin user created
- Health check endpoint responding
- User registration and login working
- Email verification working
- Challenges accessible
- Admin panel accessible
- Logs being written correctly
- Firewall rules configured
- Rate limiting working
- All services running (check
supervisorctl -c supervisord.conf statusin conda environment)