GO KALI FREE
IntermediateSecurity

Rainbow Tables: Precomputed Password Cracking Explained

Learn how rainbow tables work, their trade-offs between time and memory, when they are effective, and why salting renders them useless.

#Rainbow Tables#Password Cracking#Cryptography#Hash Tables#Time-Memory Tradeoff

The Tables That Broke Windows Passwords in Seconds

In the early 2000s, Windows LAN Manager hashes were the standard for storing Windows passwords — and they were catastrophically weak. LM hashes split passwords into two 7-character halves, used no salt, and employed a flawed hash algorithm. Security researchers Philippe Oechslin introduced rainbow tables in 2003, and suddenly any Windows password under 14 characters could be cracked in seconds. A single 2.6 GB table could crack 99.9% of all Windows XP passwords.

Rainbow tables are precomputed tables used for reversing cryptographic hash functions, primarily for cracking password hashes. They represent a time-memory trade-off: they use more memory than simple lookup tables but significantly less time than brute force attacks.

Prerequisites

Before studying rainbow tables, you should understand:

  • **Hashes Explained** — How hash functions work
  • **Dictionary Attacks** — Wordlist-based cracking
  • **Brute Force Fundamentals** — Exhaustive search concepts
  • **Cryptography Basics** — One-way functions
  • The Time-Memory Trade-Off

    Simple Lookup Table

    Store hash for every possible password
    Storage: 26^8 * 32 bytes = ~20 TB (for 8-char lowercase)
    Time: O(1)
    

    Brute Force (No Table)

    No precomputation
    Storage: 0
    Time: 26^8 = 208 billion hash computations
    

    Rainbow Table

    Store chains of hashes (compressed representation)
    Storage: Significantly less than full table
    Time: More than O(1) but much less than brute force
    

    How Rainbow Tables Work

    Chain Creation

    Rainbow tables use reduction functions (R) and hash functions (H) to create chains:

    # Simplified rainbow chain concept
    # P = Plaintext password
    # H = Hash function
    # R = Reduction function (maps hash back to possible password)
    
    Chain: P1 -> H(P1) -> R(H(P1)) -> H(R(H(P1))) -> ...
    
    # Store only: first plaintext, last hash
    # Start: password
    # Reduce: Create next possible password from hash
    # Hash: Hash the new password
    # Repeat N times
    # Store chain endpoints
    

    Chain Lookup Process

    def rainbow_lookup(target_hash, rainbow_table):
        # Apply R and H alternately to target hash
        # For each chain, check if reduced value matches an endpoint
        # If match: regenerate chain from start point
    
        current = target_hash
    
        for i in range(chain_length):
            # Reduce hash to possible password
            possible = reduce(current)
    
            # Check if possible matches any chain endpoint
            if possible in rainbow_table.endpoints:
                start = rainbow_table.starts[possible]
                # Regenerate chain from start
                result = regenerate_chain(start, target_hash)
                if result:
                    return result
    
            # Hash the possible password for next iteration
            current = hash(possible)
    
        return None
    

    Why "Rainbow"?

    The name comes from using different reduction functions (one per column in the table), creating a "rainbow" of colors when visualized. This approach eliminates chain merges and collisions that would occur with a single reduction function.

    Rainbow Table Generators

    Using rcracki_mt

    # Generate rainbow tables
    rtgen hash md5 numeric 1 7 0 21000 33554432 0
    
    # Parameters:
    # hash: Hash algorithm
    # md5: Hash type
    # numeric: Character set
    # 1 7: Min/Max password length
    # 0: Starting index
    # 21000: Chain length
    # 33554432: Number of chains
    
    # Sort tables after generation
    rtsort *.rt
    
    # Crack hashes
    rcracki_mt *.rt -h 482c811da5d5b4bc6d497ffa98491e38
    

    Using RainbowCrack

    # Generate tables
    rtgen md5 loweralpha-numeric 1 8 0 3800 33554432 0
    
    # Sort
    rtsort ./md5_loweralpha-numeric#1-8_0_3800x33554432_0.rt
    
    # Crack
    rcrack . *.rt -l hashes.txt
    

    Precomputed Rainbow Tables

    Publicly Available Tables

    # RainbowCrack Project
    # Free rainbow tables for:
    # - LM (Windows LAN Manager)
    # - NTLM
    # - MD5
    # - SHA1
    
    # Ophcrack Tables
    # Specialized for Windows LM hashes
    # XP Free Fast: 99.9% success for XP passwords
    # Vista Free: 99.9% success for alphanumeric
    

    Table Sizes and Coverage

    | Hash Type | Keyspace | Table Size | Success Rate |

    |-----------|----------|------------|--------------|

    | LM (1-7 chars) | 69^7 | 2.6 GB | 99.9% |

    | NTLM (1-7 alphanum) | 36^7 | 36 GB | 99.9% |

    | MD5 (1-7 loweralpha) | 26^7 | 28 GB | 99% |

    | MD5 (1-8 alphanum) | 62^8 | Very large | Limited |

    Why Salting Defeats Rainbow Tables

    The Salt Problem

    # Without salt
    hash("password123") = same hash every time
    # One rainbow table works for ALL users
    
    # With salt
    hash("password123" + "random_salt_a") = hash_a
    hash("password123" + "random_salt_b") = hash_b
    # Each salt requires a NEW rainbow table
    

    Salt Space Explosion

    Password: "password"
    Without salt: 1 hash value
    With 32-bit salt: 2^32 = 4 billion hash values
    With 128-bit salt: 2^128 hash values
    
    To crack salted passwords with rainbow tables:
    - Need separate table for every possible salt value
    - 2^128 tables = computationally infeasible
    

    Modern Relevance

    Are Rainbow Tables Still Useful?

    Rainbow tables remain effective for:

  • **Unsalted legacy systems** — Older Windows (LM hashes), legacy applications
  • **Fixed-salt systems** — Some embedded systems use hardcoded salts
  • **Limited keyspace attacks** — Short passwords (1-7 chars) in certain character sets
  • **NTLM hashes** — Still relevant for Windows environments
  • Where They Fail

  • **Salted hashes** — Modern systems (Linux, web apps) use per-user salts
  • **Slow hashes** — bcrypt, Argon2 (intentionally slow, chains take too long)
  • **Large keyspace** — Long passwords (12+ chars) require enormous tables
  • **Unique protocols** — WPA2, Kerberos use inputs beyond simple passwords
  • Real-World Examples

    Ophcrack and Windows XP: Ophcrack's rainbow tables could crack 99.9% of Windows XP passwords in seconds, making LM hashes a critical vulnerability.

    WPA2 Rainbow Tables: Precomputed tables for common WPA2 passphrases exist (e.g., RainbowCrack's WPA tables), though each table covers limited keyspace.

    Common Mistakes

    Using rainbow tables for salted hashes: Rainbow tables waste time on salted hashes. Use dictionary attacks instead.

    Wrong table selection: Different character sets and lengths require different tables. Match table to expected password format.

    Assuming 100% success: Rainbow tables have a success rate based on coverage. Not all passwords will be found.

    Best Practices

  • **Use rainbow tables only for unsalted hashes** — LM, NTLM, unsalted MD5/SHA1
  • **Match table parameters** — Character set and length must match expected passwords
  • **Verify coverage** — Check table success rate before relying on results
  • **Combine with other methods** — Dictionary attacks often complement rainbow tables
  • **Use modern tools instead** — Hashcat with GPUs is often faster than rainbow table lookups
  • Related Tools

  • **Ophcrack** — Windows password cracker using rainbow tables
  • **RainbowCrack** — Rainbow table generation and lookup
  • **rcracki_mt** — Multi-threaded rainbow table cracker
  • **rtgen** — Rainbow table generator
  • **rtsort** — Rainbow table sorter
  • Related Articles

  • Hashes Explained
  • Dictionary Attacks
  • Brute Force Fundamentals
  • Hashcat Guide
  • Summary

    Rainbow tables precompute hash chains to enable fast password cracking with a time-memory trade-off. They are effective for unsalted hashes like LM and NTLM but are completely defeated by modern salting practices. For most modern systems, GPU-based dictionary attacks (Hashcat) are more practical.

    Knowledge Check

  • What problem do rainbow tables solve?
  • How does salting defeat rainbow tables?
  • What is the time-memory trade-off?
  • Why are rainbow tables ineffective against bcrypt?
  • In what scenarios are rainbow tables still useful?
  • Frequently Asked Questions

    What are rainbow tables?

    Rainbow tables are precomputed tables of hash chains that reverse cryptographic hash functions for password cracking. They represent a time-memory trade-off — using more storage than simple lookups but requiring far less computation than brute force attacks.

    How do rainbow tables work?

    Rainbow tables store only the endpoints of hash chains rather than every possible hash. To crack a password, the lookup process regenerates the chain from each endpoint and checks for matches. Different reduction functions at each step prevent chain collisions.

    How does salting defeat rainbow tables?

    Salting prepends a unique random value to each password before hashing. This means identical passwords produce different hashes, requiring a separate rainbow table for every possible salt value. With 128-bit salts, the table space becomes computationally infeasible.

    What is the time-memory trade-off?

    The time-memory trade-off balances computation against storage. Brute force uses no storage but maximum computation. Simple lookup tables use maximum storage but instant lookup. Rainbow tables optimize the middle ground by compressing chains to reduce storage while adding moderate computation.

    Are rainbow tables still useful today?

    Rainbow tables remain effective for unsalted hashes like legacy Windows LM hashes and some NTLM implementations. However, they are useless against salted hashes (Linux, modern web apps) and slow hashes like [bcrypt](/articles/hashes-explained). GPU-based dictionary attacks are generally more practical.

    Why are rainbow tables ineffective against bcrypt?

    Bcrypt is intentionally slow — each hash takes 100+ milliseconds. Regenerating rainbow chains through bcrypt would take impractically long. The time-memory trade-off collapses when the hash function itself is computationally expensive, making brute force or dictionary attacks equally slow.

    What hash types can rainbow tables crack?

    Precomputed tables exist for LM, NTLM, MD5, and SHA-1. LM tables can crack 99.9% of Windows XP passwords. NTLM tables cover 1-7 character alphanumeric passwords. Free tables are available from the RainbowCrack and Ophcrack projects.

    What tools use rainbow tables?

    Ophcrack is the most popular rainbow table cracker, especially for Windows passwords. RainbowCrack generates and cracks tables. rcracki_mt provides multi-threaded cracking. The `rtgen` utility generates custom tables for specific hash types and character sets.

    How big are rainbow table files?

    Table size depends on hash type, character set, and keyspace. LM tables for 1-7 char passwords are about 2.6 GB. NTLM alphanumeric tables for 1-7 chars are about 36 GB. MD5 lowercase tables for 1-8 chars are very large and often impractical.

    Should I use rainbow tables or Hashcat?

    For unsalted hashes, rainbow tables can be faster for small keyspaces. For everything else, [Hashcat](/articles/hashcat-guide) with GPU acceleration is more flexible and practical. Hashcat handles salted hashes, complex rules, and modern hash types that rainbow tables cannot address.