This repository now supports generating CTF (Capture The Flag) versions of all binaries with randomized secrets.
The CTF generation system modifies the hardcoded secrets in the source code before compilation to create randomized versions suitable for CTF competitions. The format for CTF secrets is:
this is the secret in <language> : <random_hex_string>
For example:
this is the secret in C : d99bd60f17a05054this is the secret in Golang : 88b6c82d957d74c6
Use the generate_ctf_secrets.sh script:
# Generate CTF secrets and modify source files
./generate_ctf_secrets.sh generate
# Restore original source files
./generate_ctf_secrets.sh restoreThe quickbuild.sh script automatically generates both regular and CTF versions:
# Build both regular and CTF versions (default)
./quickbuild.sh
# Build only regular versions
GENERATE_CTF=no ./quickbuild.shThis creates binaries with the following naming convention:
- Regular:
wrongsecrets-<language>[-platform] - CTF:
wrongsecrets-<language>[-platform]-ctf
All GitHub Actions workflows automatically generate both regular and CTF versions of binaries. The CTF versions are included in the uploaded artifacts alongside the regular versions.
CTF generation works for all supported languages:
- C
- C++
- Go/Golang
- Rust
- .NET/C#
- Swift
Run the test suite to verify CTF generation is working:
./test_ctf_generation.shThis tests:
- ✓ CTF secrets are properly generated with random values
- ✓ CTF binaries compile and run correctly
- ✓ Original files are properly restored
- ✓ Original binaries continue to work as expected
The CTF generation works by:
- Creating backup copies of original source files (
.originalextension) - Replacing hardcoded secret strings with randomized CTF format strings
- Updating character arrays and other representations of secrets
- Compiling the modified sources
- Restoring original files after compilation
The script handles various secret representations:
- Simple string literals
- Character arrays
- Multi-line definitions
- Language-specific patterns
You can verify CTF binaries work correctly:
# Generate CTF versions
./generate_ctf_secrets.sh generate
# Compile a CTF binary
gcc c/main.c -o wrongsecrets-c-ctf
# Test it outputs CTF secret
./wrongsecrets-c-ctf spoil
# Should output: this is the secret in C : <random_hex>
# Restore originals
./generate_ctf_secrets.sh restore