Crypto CTF Workflow
A systematic approach to solving cryptography challenges in CTFs and security tasks.
Quick Triage Checklist
When you encounter a crypto challenge, work through these steps in order:
- Identify what you have: Is it encoding, encryption, hash, signature, or MAC?
- Determine what is controlled: Do you have plaintext/ciphertext, IV/nonce, key, oracle (padding/error/timing), or partial leakage?
- Classify the type:
- Symmetric (AES/CTR/GCM)
- Public-key (RSA/ECC)
- Hash/MAC (SHA/MD5/HMAC)
- Classical (Vigenere/XOR/Caesar)
- Apply highest-probability checks first: Decode layers, known-plaintext XOR, nonce reuse, mode misuse, oracle behavior
- Escalate to advanced methods only when required: Lattices (LLL/Coppersmith), SMT/Z3, side-channels
Step 1: Initial Identification
Check for common encodings first
Many CTF crypto tasks are layered transforms: base encoding + simple substitution + compression. Start by peeling layers:
Try these in order:
- Run the
identify_encoding.sh script on your input
- Check for Base64:
A-Za-z0-9+/= (padding = is common)
- Check for Base32:
A-Z2-7= (often lots of = padding)
- Check for Ascii85/Base85: dense punctuation; sometimes wrapped in
<~ ~>
Check for compression
If output almost parses but looks like garbage, suspect compression:
Look for magic bytes:
- gzip:
1f 8b
- zlib: often
78 01/9c/da
- zip:
50 4b 03 04
- bzip2:
42 5a 68 (BZh)
- xz:
fd 37 7a 58 5a 00
- zstd:
28 b5 2f fd
Use the detect_compression.sh script to check automatically.
Check for hashes
If you have a fixed-length string that looks like a hash:
- Google the hash (surprisingly effective)
- Try online lookup services:
Step 2: Classical Cipher Analysis
Substitution / monoalphabetic
Caesar / ROT / Atbash
Vigenère
Bacon cipher
Often appears as groups of 5 bits or 5 letters:
00111 01101 01010 00000 ...
AABBB ABBAB ABABA AAAAA ...
Morse
.... --- .-.. -.-. .- .-. .- -.-. --- .-.. .-
Runes
Runes are frequently substitution alphabets; search for "futhark cipher" and try mapping tables.
Step 3: Modern Crypto Constructs
Fernet
Typical hint: Two Base64 strings (token + key).
Shamir Secret Sharing
If you see multiple shares and a threshold t is mentioned, it is likely Shamir.
OpenSSL salted formats
CTFs sometimes give openssl enc outputs (header often begins with Salted__).
Bruteforce helpers:
Step 4: Advanced Tools
General toolset
Automated decoding
Online helpers
Practice platforms
Recommended Local Setup
Install these packages for a practical CTF stack:
pip install pycryptodome gmpy2 sympy pwntools z3-solver
Tools to have available:
- Python +
pycryptodome for symmetric primitives and fast prototyping
- SageMath for modular arithmetic, CRT, lattices, and RSA/ECC work
- Z3 for constraint-based challenges (when the crypto reduces to constraints)
Workflow Summary
- Triage: Identify type, classify, determine what's controlled
- Peel layers: Try encodings, check compression, look up hashes
- Classical: Try substitution, Caesar, Vigenère, Bacon, Morse
- Modern: Check Fernet, Shamir, OpenSSL formats
- Advanced: Use RsaCtfTool, lattices, Z3 when needed
- Verify: Test your solution against the challenge requirements
Tips
- Always try the simplest explanation first (encoding before encryption)
- Layered transforms are common - keep peeling until you get plaintext
- Use CyberChef's "Magic" function for quick identification
- When stuck, look for patterns: repeated blocks suggest XOR or ECB mode
- Nonce/IV reuse is a common vulnerability - check for it
- Oracle attacks (padding, timing, error) are powerful when available
- Don't forget to check for compression after decoding
1---2name: crypto-ctf-workflow3description: Use this skill whenever you encounter cryptography challenges, CTF crypto problems, encoded data, hashes, ciphers, or any security-related encryption/decryption tasks. Make sure to use this skill for any crypto CTF challenge, encoded strings, hash analysis, cipher breaking, or when you need to identify and peel layers of encoding/encryption.4metadata:5 source: https://skillmd.com/skills/abelrguezr/crypto-ctf-workflow6---78# Crypto CTF Workflow910A systematic approach to solving cryptography challenges in CTFs and security tasks.1112## Quick Triage Checklist1314When you encounter a crypto challenge, work through these steps in order:15161. **Identify what you have**: Is it encoding, encryption, hash, signature, or MAC?172. **Determine what is controlled**: Do you have plaintext/ciphertext, IV/nonce, key, oracle (padding/error/timing), or partial leakage?183. **Classify the type**:19 - Symmetric (AES/CTR/GCM)20 - Public-key (RSA/ECC)21 - Hash/MAC (SHA/MD5/HMAC)22 - Classical (Vigenere/XOR/Caesar)234. **Apply highest-probability checks first**: Decode layers, known-plaintext XOR, nonce reuse, mode misuse, oracle behavior245. **Escalate to advanced methods only when required**: Lattices (LLL/Coppersmith), SMT/Z3, side-channels2526## Step 1: Initial Identification2728### Check for common encodings first2930Many CTF crypto tasks are layered transforms: base encoding + simple substitution + compression. Start by peeling layers:3132**Try these in order:**331. Run the `identify_encoding.sh` script on your input342. Check for Base64: `A-Za-z0-9+/=` (padding `=` is common)353. Check for Base32: `A-Z2-7=` (often lots of `=` padding)364. Check for Ascii85/Base85: dense punctuation; sometimes wrapped in `<~ ~>`3738### Check for compression3940If output almost parses but looks like garbage, suspect compression:4142**Look for magic bytes:**43- gzip: `1f 8b`44- zlib: often `78 01/9c/da`45- zip: `50 4b 03 04`46- bzip2: `42 5a 68` (`BZh`)47- xz: `fd 37 7a 58 5a 00`48- zstd: `28 b5 2f fd`4950Use the `detect_compression.sh` script to check automatically.5152### Check for hashes5354If you have a fixed-length string that looks like a hash:55561. Google the hash (surprisingly effective)572. Try online lookup services:58 - https://crackstation.net/59 - https://md5decrypt.net/60 - https://hashes.org/search.php61 - https://www.onlinehashcrack.com/62 - https://gpuhash.me/63 - http://hashtoolkit.com/reverse-hash6465## Step 2: Classical Cipher Analysis6667### Substitution / monoalphabetic6869- Use Boxentriq cryptogram solver: https://www.boxentriq.com/code-breaking/cryptogram70- Use quipqiup: https://quipqiup.com/7172### Caesar / ROT / Atbash7374- Use Nayuki auto breaker: https://www.nayuki.io/page/automatic-caesar-cipher-breaker-javascript75- Atbash: http://rumkin.com/tools/cipher/atbash.php7677### Vigenère7879- https://www.dcode.fr/vigenere-cipher80- https://www.guballa.de/vigenere-solver8182### Bacon cipher8384Often appears as groups of 5 bits or 5 letters:85```8600111 01101 01010 00000 ...87AABBB ABBAB ABABA AAAAA ...88```8990### Morse9192```93.... --- .-.. -.-. .- .-. .- -.-. --- .-.. .-94```9596### Runes9798Runes are frequently substitution alphabets; search for "futhark cipher" and try mapping tables.99100## Step 3: Modern Crypto Constructs101102### Fernet103104**Typical hint**: Two Base64 strings (token + key).105106- Decoder/notes: https://asecuritysite.com/encryption/ferdecode107- In Python: `from cryptography.fernet import Fernet`108109### Shamir Secret Sharing110111If you see multiple shares and a threshold `t` is mentioned, it is likely Shamir.112113- Online reconstructor (handy for CTFs): http://christian.gen.co/secrets/114115### OpenSSL salted formats116117CTFs sometimes give `openssl enc` outputs (header often begins with `Salted__`).118119Bruteforce helpers:120- https://github.com/glv2/bruteforce-salted-openssl121- https://github.com/carlospolop/easy_BFopensslCTF122123## Step 4: Advanced Tools124125### General toolset126127- **RsaCtfTool**: https://github.com/Ganapati/RsaCtfTool128- **featherduster**: https://github.com/nccgroup/featherduster129- **cryptovenom**: https://github.com/lockedbyte/cryptovenom130131### Automated decoding132133- **Ciphey**: https://github.com/Ciphey/Ciphey134- **python-codext** (tries many bases/encodings): https://github.com/dhondta/python-codext135136### Online helpers137138- **CyberChef** (magic, decode, convert): https://gchq.github.io/CyberChef/139- **dCode** (ciphers/encodings playground): https://www.dcode.fr/tools-list140- **Boxentriq** (substitution solvers): https://www.boxentriq.com/code-breaking141142### Practice platforms143144- **CryptoHack** (hands-on crypto challenges): https://cryptohack.org/145- **Cryptopals** (classic modern crypto pitfalls): https://cryptopals.com/146147## Recommended Local Setup148149Install these packages for a practical CTF stack:150151```bash152pip install pycryptodome gmpy2 sympy pwntools z3-solver153```154155**Tools to have available:**156- Python + `pycryptodome` for symmetric primitives and fast prototyping157- SageMath for modular arithmetic, CRT, lattices, and RSA/ECC work158- Z3 for constraint-based challenges (when the crypto reduces to constraints)159160## Workflow Summary1611621. **Triage**: Identify type, classify, determine what's controlled1632. **Peel layers**: Try encodings, check compression, look up hashes1643. **Classical**: Try substitution, Caesar, Vigenère, Bacon, Morse1654. **Modern**: Check Fernet, Shamir, OpenSSL formats1665. **Advanced**: Use RsaCtfTool, lattices, Z3 when needed1676. **Verify**: Test your solution against the challenge requirements168169## Tips170171- Always try the simplest explanation first (encoding before encryption)172- Layered transforms are common - keep peeling until you get plaintext173- Use CyberChef's "Magic" function for quick identification174- When stuck, look for patterns: repeated blocks suggest XOR or ECB mode175- Nonce/IV reuse is a common vulnerability - check for it176- Oracle attacks (padding, timing, error) are powerful when available177- Don't forget to check for compression after decoding