hash-attack-techniques
Hash attack playbook. Use when exploiting length extension, MD5/SHA1 collisions, HMAC timing leaks, birthday attacks, or hash-based proof of work in CTF and authorized testing scenarios.
By yaklang · 2,965 installs
npx skills add yaklang/hack-skills --skill hash-attack-techniques
Source repository · Upstream listing
SKILL: Hash Attack Techniques — Expert Cryptanalysis Playbook
AI LOAD INSTRUCTION : Expert hash attack techniques for CTF and security assessments. Covers length extension attacks, MD5/SHA1 collision generation, meet in the middle hash attacks, HMAC timing side channels, birthday attacks, and proof of work solving. Base models often incorrectly apply length extension to HMAC or SHA 3, or fail to distinguish between identical prefix and chosen prefix collisions.
0. RELATED ROUTING
[rsa attack techniques](../rsa attack techniques/SKILL.md) when hash weaknesses affect RSA signature schemes
[symmetric cipher attacks](../symmetric cipher attacks/SKILL.md) when hash is used in key derivation
[classical cipher analysis](../classical cipher analysis/SKILL.md) when analyzing hash like constructions in classical ciphers
Quick attack selection
Scenario Attack Tool
H(secret \ \ msg) known, extend message Length extension HashPump, hash extender
Need two files with same MD5 Identical prefix collision fastcoll
Need specific MD5 prefix match Chosen prefix collision hashclash
Byte by byte HMAC comparison Timing attack Custom script
Find any collision Birthday attack O(2^(n/2))
Proof of work: find hash with leading zeros Brute force hashcat, Python
1. LENGTH EXTENSION ATTACK
1.1 Vulnerable vs Non Vulnerable
Hash Vulnerable Why
MD5 Yes Merkle Damgard construction
SHA 1 Yes Merkle Damgard construction
SHA 256 Yes Merkle Damgard construction
SHA 512 Yes Merkle Damgard construction
SHA 3 / Keccak No Sponge construction
HMAC No Double hashing prevents extension
SHA 256 truncated No (if truncated) Missing internal state bits
BLAKE2 No Different construction
1.2 Attack Mechanism
1.3 Padding Calculation (MD5/SHA)
1.4 Tool Usage
1.5 Python Implementation
2. MD5 COLLISION ATTACKS
2.1 Identical Prefix Collision (fastcoll)
Two messages with same prefix but different content, producing identical MD5.
2.2 Chosen Prefix Collision (hashclash)
Two messages with different chosen prefixes, appended with computed suffixes to collide.
2.3 UniColl (Single Block Near Collision)
Produces two messages differing in a single byte within one MD5 block, with same hash.
2.4 Collision Applications
Application Technique Impact
Certificate forgery Chosen prefix Rogue CA certificate (proven in 2008)
Binary substitution Identical prefix + conditional Two executables, same MD5, different behavior
PDF collision UniColl Two PDFs showing different content
Git commit collision Chosen prefix (SHAttered for SHA1) Two commits with same hash
CTF: bypass MD5 check fastcoll Two different inputs accepted as same
2.5 CTF MD5 Collision Tricks
3. SHA 1 COLLISION
3.1 SHAttered Attack (2017)
First practical SHA 1 collision: two PDF files with same SHA 1.
Complexity: ~2^63 SHA 1 computations
Cost: ~$110K on GPU clusters (2017 prices)
Tool: shattered.io provides the collision PDFs
3.2 SHA 1 Chosen Prefix Collision (2020)
Complexity: ~2^63.4 computations
Practical for attacking PGP/GnuPG key servers
Demonstrates SHA 1 is broken for collision resistance
3.3 Impact
4. BIRTHDAY ATTACK
4.1 Generic Birthday Bound
4.2 Birthday Attack Implementation
5. HMAC TIMING ATTACK
5.1 Vulnerable Comparison
5.2 Attack Strategy
5.3 Constant Time Comparison (Defense)
6. MEET IN THE MIDDLE (HASH)
6.1 Concept
Split hash computation into two halves, precompute one, match against the other.
7. HASH PROOF OF WORK
7.1 Common CTF PoW Formats
7.2 GPU Accelerated PoW
8. RAINBOW TABLES & SALTING
8.1 Rainbow Table Attack
8.2 Salt Defeats Rainbow Tables
8.3 Modern Password Hashing
Algorithm Salt Iterations Memory Hard Recommended
MD5 No 1 No Never
SHA 256 No 1 No Never for passwords
bcrypt Yes Configurable No Yes
scrypt Yes Configurable Yes Yes
Argon2 Yes Configurable Yes Best choice
PBKDF2 Yes Configurable No Acceptable
9. DECISION TREE
10. TOOLS
Tool Purpose Usage
HashPump Length extension attack hashpump s MAC d data k secret len a extension
hash extender Length extension (multiple algorithms) hash extender data D secret L append E sig MAC
fastcoll MD5 identical prefix collision fastcoll p prefix o out1 out2
hashclash MD5 chosen prefix collision hashclash prefix1 prefix2
hashcat Password/hash cracking (GPU) hashcat m MODE a ATTACK hash wordlist
John the Ripper Password cracking (CPU/GPU) john wordlist=rockyou.txt hashes.txt
CyberChef Quick hash computation and encoding Web based