"""
============================================================================
CTF CHALLENGE SOLUTION SUMMARY: "Nothing Ever Changes"
============================================================================

CHALLENGE: Create image pairs where img1 and img2 have IDENTICAL MD5 hashes
but classify as DIFFERENT digits in a neural network.

============================================================================
CONFIRMED FACTS (After Exhaustive Testing)
============================================================================

✅ Model is 100% deterministic
✅ PIL image loading is 100% deterministic
✅ No bugs in verification logic
✅ No ZIP file tricks work
✅ No PNG parsing quirks found
✅ Preprocessing is deterministic

CONCLUSION: The ONLY solution is MD5 collision attack!

============================================================================
THE SOLUTION: MD5 CHOSEN-PREFIX COLLISION
============================================================================

You must use cryptographic collision tools to create two DIFFERENT PNG files
that have the SAME MD5 hash.

TOOLS NEEDED:
1. HashClash - https://github.com/cr-marcstevens/hashclash
2. Knowledge of chosen-prefix collision attacks
3. PNG format expertise

STEPS:
1. Create adversarial examples that classify as different digits
2. Use HashClash to generate collision blocks
3. Embed collision blocks in PNG ancillary chunks
4. Verify both PNGs have same MD5 but different classifications
5. Repeat for all 10 pairs
6. Package in ZIP and submit

============================================================================
REQUIREMENTS PER PAIR
============================================================================

Pair 00: digit 0 → 1 (55 pixel budget)
Pair 01: digit 1 → 2 (30 pixel budget)
Pair 02: digit 2 → 3 (30 pixel budget)
Pair 03: digit 3 → 4 (65 pixel budget)
Pair 04: digit 4 → 5 (30 pixel budget)
Pair 05: digit 5 → 6 (10 pixel budget) ← HARDEST
Pair 06: digit 6 → 7 (55 pixel budget)
Pair 07: digit 7 → 8 (40 pixel budget)
Pair 08: digit 8 → 9 (40 pixel budget)
Pair 09: digit 9 → 1 (40 pixel budget)

============================================================================
WHY THIS IS HARD
============================================================================

- MD5 chosen-prefix collisions require significant computation
- PNG format must remain valid
- Images must classify correctly
- Need to create 10 successful collision pairs
- Estimated: 400-500 point CTF challenge

============================================================================
QUICK START
============================================================================

# Install HashClash
git clone https://github.com/cr-marcstevens/hashclash.git
cd hashclash && make

# Create adversarial digit images
python create_adversarial_pairs.py

# Generate collisions using HashClash
./hashclash_gen collision_config.txt

# Embed in PNGs
python embed_collision_blocks.py

# Test locally
python test_client.py

# Submit
curl -X POST http://localhost:5001/submit -F "file=@solution.zip"

============================================================================
RESOURCES
============================================================================

Papers:
- "Chosen-Prefix Collisions for MD5 and Applications" (2009) - Marc Stevens
- Marc Stevens' PhD thesis on hash collisions

Tools:
- HashClash: https://github.com/cr-marcstevens/hashclash
- Corkami PNG documentation
- TweakPNG for chunk editing

CTF Writeups:
- Search "MD5 collision CTF"
- "Shattered attack" examples
- PNG collision challenges

============================================================================
THE CLEVER PART
============================================================================

The challenge name "Nothing Ever Changes" is brilliantly ironic:
- SYNTAX doesn't change (bytes/MD5 are identical)
- SEMANTICS change (meaning/classification is different)

This demonstrates:
✓ MD5 is cryptographically broken
✓ File formats have complex structure
✓ Adversarial examples in ML
✓ Gap between representation and interpretation

============================================================================
LOCAL TESTING ENVIRONMENT
============================================================================

Docker container running at: http://localhost:5001

Files created for analysis:
- README.md - Complete setup guide
- ANALYSIS.md - Technical analysis
- SOLUTION_GUIDE.md - Detailed solution approaches
- HOW_TO_SOLVE.md - Step-by-step instructions
- analyze_challenge.py - Testing tool
- test_client.py - Submission client

To test:
  python analyze_challenge.py  # See full requirements
  python test_client.py        # Test submission

============================================================================
FINAL VERDICT
============================================================================

This is a VERY HARD CTF challenge requiring:
- Advanced cryptography knowledge (MD5 collisions)
- File format expertise (PNG structure)
- Machine learning understanding (adversarial examples)
- Significant computation time (collision generation)

Good luck! 🎯🔐🤖

============================================================================
"""

if __name__ == "__main__":
    print(__doc__)
