Welcome to the PyCon 2024 Capture the Flag game! This environment uses PostgreSQL and CipherStash to encrypt data in use. The database has been initialized with Encrypt Query Language (EQL) and seeded with the encrypted flag. The Python applications uses the eqlpy library to interact with the EQL payloads.
- Docker installed and running
- Docker Compose installed
- Python 3.x for interacting with the application
- Keys provided at the CipherStash booth
This environment includes:
- PostgreSQL database: Runs on
localhost:5432
. - CipherStash Proxy: Intercepts database traffic to handle encryption and decryption, running on
localhost:6432
.
To successfully query and decrypt data:
- All database traffic must go through the CipherStash Proxy.
- Use the provided encryption keys to access decrypted results.
You can view the previously executed SQL commands to initialize the database here.
git clone https://github.com/cipherstash/pyconau2024-ctf.git
cd pyconau2024-ctf
Run the following command to start PostgreSQL and the CipherStash Proxy:
docker compose up --build
This will:
- Start the PostgreSQL database (
localhost:5432
) and initialize the database with the seeded data. - Start the CipherStash Proxy (
localhost:6432
).
To run the Python application, run the following command:
# install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# run the app
python main.py
The application will query the database and print the results to the console. If this is the first time running the application, you should see the following output:
Ciphertext: ...
Once you solve the challenge, you should see the following output:
Plaintext: ...
Visit the CipherStash booth to receive your decryption keys.
They will provide you a link to download the contents for your .envrc
file.
- Open the
.envrc
file and update the values with your keys. - Update the Python application to query the database via the Proxy.
- Run the application to query the database and view the plaintext decrypted results.
Once the challenge is solved, submit the flag to this form.
Hint: The flag is the plaintext value of the
key
column in thepycon_cta
table.
- Can’t connect to the database?
- Ensure the Proxy is running (
localhost:6432
). - Check your application’s connection settings.
- Ensure the Proxy is running (
- Decryption issues?
- Verify you’re using the correct keys from the CipherStash booth.
- Ensure database traffic is routed through the Proxy.
For help, visit the CipherStash booth to connect with our team.
Have fun and good luck decrypting the flag! 🚩