Capture The Flag (CTF) challenges focused on exploiting game logic vulnerabilities:
Card Trading Game: A multiplayer card trading game where players need to obtain duplicate name cards to capture the flag. The challenge involves exploiting faulty logic in the card gifting system.
Dice Guessing Game: A dice prediction game where players need to correctly guess 10 rolls in a row. The challenge involves analyzing and predicting the output of a Linear Congruential Generator (LCG). Most likely via brute force but can also done intelligently using incremental modulo backtracking.
- Docker
- Git
# Using HTTPS
git clone https://github.com/ruelalarcon/game_logic_exploits_ctf.git
cd game_logic_exploits_ctf
# Or using SSH
git clone git@github.com:ruelalarcon/game_logic_exploits_ctf.git
cd game_logic_exploits_ctf
Create a .env
file in the root directory with the following variables:
SESSION_SECRET=your_random_secret
DICEGAME_FLAG=your_flag_here
CARDGAME_FLAG=your_flag_here
Build and start the container:
docker compose up -d
The application will be available on port 3000 by default.
To run the application on a different port, modify the ports
section in docker-compose.yml
:
services:
app:
# ... other configuration ...
ports:
- "8080:3000" # Change 8080 to your desired port
The repository includes solution scripts for both challenges.
First, cd
into the solutions directory:
cd solutions
These require Python 3.7+ and the following dependencies:
pip install -r requirements.txt
python cardgame_solution.py
The script will:
- Create two accounts
- Exploit the race condition in the gifting system
- Obtain duplicate name cards
- Retrieve the flag
Note: By default, this solution connects to
localhost:3000
. If you've changed the port or are running on a different host, modify theHOST
andPORT
variables in the script.
First, change the "history" array at the top of the file to your dice roll history array.
python dicegame_solution.py
The script will:
- Use the provided roll history to determine the RNG state
- Calculate the next 10 rolls
- Print the predictions for manual entry
If you're using Nginx as a reverse proxy, ensure your configuration includes WebSocket support:
location / {
proxy_pass http://localhost:3000; # Change port if needed
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
- Players can trade cards with each other
- Each account gets a unique "name card" on registration
- The goal is to obtain two identical name cards
- The gift handling is given as a hint
- Vulnerability: Race condition in the card gifting system
- Solution: Exploit the race condition by sending multiple gift requests during the artificial delay
- Players must correctly guess 10 dice rolls in a row
- The game uses a Linear Congruential Generator (LCG) for randomness
- The RNG implementation is "accidentally" leaked
- Vulnerability: Predictable random number generation
- Solution: Analyze the roll history to determine the LCG state and predict future rolls
This was designed by Ruel Nathaniel Alarcon for the USASK Cybersecurity Club's meeting/presentation on Advanced Game Exploitation.