A cryptographic challenge combining Brainfuck esoteric programming with MD5 collision exploitation
Try the Challenge β’ View Source β’ Hall Of Fame β’ Report Bug
This challenge is inspired by a classic [g]old challenge from SmashTheStack, reimagined with a modern web interface. The goal is to create two different Brainfuck programs that:
- Produce different outputs when executed
- Have identical MD5 hashes (MD5 collision)
- File 1 must output:
Rock N Roll - File 2 must output:
Hack N Roll - Both files must have the same MD5 hash
Sounds impossible? That's the beauty of MD5 collision attacks! π
Visit collision.hacknroll.academy to test your solution without any installation!
# Clone the repository
git clone https://github.com/maycon/bf-md5-collision.git
cd bf-md5-collision
# Start with Docker Compose
docker compose up
# Access the challenge at http://localhost:8000# Clone the repository
git clone https://github.com/maycon/bf-md5-collision.git
cd bf-md5-collision
# Install dependencies with uv (recommended)
uv sync
# Or with pip
pip install -r requirements.txt
# Run the application
python src/main.pyThe challenge uses a custom Brainfuck interpreter that supports:
- 30,000 memory cells (standard)
- 8-bit cell values (0-255 with wraparound)
- All standard Brainfuck commands:
><+-.,[]
MD5 is a cryptographic hash function that's vulnerable to collision attacks. This means it's possible to find two different inputs that produce the same hash output. This challenge leverages that weakness!
You need to craft two Brainfuck programs that:
- Execute correctly (no syntax errors)
- Generate specific, different outputs
- Share the same MD5 hash
Hint: Think about how MD5 collision attack techniques (like the Chosen-Prefix Collision) can be applied to Brainfuck bytecode! π€
bf-md5-collision/
βββ src/
β βββ main.py # Flask application and Brainfuck interpreter
β βββ flag.py # Flag configuration
β βββ static/
β β βββ style.css # UI styling
β βββ templates/
β βββ upload.html # Main challenge interface
βββ bf/
β βββ rock.bf # Example: outputs "Rock N Roll"
β βββ hack.bf # Example: outputs "Hack N Roll"
βββ Dockerfile # Container configuration
βββ compose.yaml # Docker Compose setup
βββ pyproject.toml # Python dependencies
βββ README.md # This file
Spoiler Alert: Skip this section if you want to solve it yourself!
Click to reveal solution strategy
Modern MD5 collision techniques allow us to generate two files with:
- A common prefix
- Different collision blocks
- Optional suffixes
- Identify collision bytes: Generate an MD5 collision block
- Craft valid Brainfuck: Ensure collision bytes are valid BF commands or comments
- Add suffix logic: After the collision block, add code that:
- Detects which version it is
- Outputs the correct string accordingly
- HashClash: Academic tool for MD5 collisions
- FastColl: Faster collision generator
- UniColl: Universal collision technique
For a detailed walkthrough, see SOLUTION.md
- Python 3.12+
- uv (recommended) or pip
- Docker (optional)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies in development mode
uv sync --dev
# Run with auto-reload
python src/main.py# Run unit tests
pytest
# Run with coverage
pytest --cov=src- Modern UI: Clean, responsive interface with syntax highlighting
- Real-time Validation: Instant feedback on your submissions
- Source Code View: Transparent - view the challenge source code
- Docker Support: Easy deployment with multi-stage builds
- Production Ready: Gunicorn WSGI server with worker configuration
Top Solvers (ranked by smallest total file size):
Awaiting first submission - be the first!
View Hall of Fame β | Submit Your Solution β
Solved the challenge? Add your name to the Hall of Fame by submitting a Pull Request!
Contributions are welcome! Whether it's:
- π Bug fixes
- β¨ New features
- π Documentation improvements
- π¨ UI enhancements
Please read CONTRIBUTING.md for guidelines.
This challenge is based on the [g]old challenge from SmashTheStack, a pioneering wargaming platform that inspired countless security enthusiasts.
- Platform: SmashTheStack
- Name: [g]old
- Concept: MD5 collision exploitation in a constrained environment
- Author: Maycon
- Year: 2024
- Enhancements: Modern web interface, Docker deployment, improved UX
This project is licensed under the MIT License - see the LICENSE file for details.
- Live Demo: collision.hacknroll.academy
- GitHub: maycon/bf-md5-collision
- Report Issues: GitHub Issues
This challenge teaches:
- Cryptographic Weaknesses: Understanding MD5 collision attacks
- Esoteric Programming: Working with Brainfuck
- Binary Manipulation: Crafting specific byte sequences
- Security Concepts: Hash function vulnerabilities
Perfect for:
- CTF competitions
- Security training
- Programming challenges
- Educational demonstrations
Made with β€οΈ by the security community
Remember: This is for educational purposes only!
β Star this repo if you found it interesting! β