Cracking Hashes

The Quiet Arena

Attacking a live login is loud, slow, and risky. Cracking a stolen hash is the opposite: it happens entirely on your hardware, with no one watching, at the full speed of your GPU.

If you can get the hash, this is where you want to be. But first you have to understand why you can’t just reverse it.


Hashing Is Not Encryption


Encryption (two-way)

Encryption scrambles data with a key, and the same process in reverse unscrambles it. It’s a round trip.

  • Symmetric (e.g. AES): one shared key both locks and unlocks. Fast, but both sides must hold the secret.
  • Asymmetric (e.g. RSA): a public key locks, a private key unlocks. No shared secret needed.

If you have the key, you get the plaintext back. Encryption is reversible by design.

Hashing (one-way)

A hash runs input through a one-way function (like MD5, SHA-1, SHA-256) and produces a fixed-length fingerprint.

  • The same input always produces the same hash
  • Different inputs produce (statistically) different hashes
  • There is no key and no reverse function

You cannot decrypt a hash, because it was never encrypted. The only way back is to guess the input and hash it yourself, then check if it matches.

That single fact is the whole basis of password cracking.


How Cracking Actually Works

Since you can’t reverse a hash, you run a loop: guess, hash, compare.


Take each candidate from your wordlist, hash it with the same algorithm as the target, and compare. The instant a candidate’s hash equals the one you stole, you’ve found the password.

Weak passwords fall in milliseconds, because they’re sitting near the top of every wordlist.

The two standard tools:

ToolStrength
HashcatGPU-accelerated, blazing fast, supports most algorithms
John the RipperCPU-based, flexible, handles formats Hashcat sometimes can’t

Learn both. They cover different algorithms and edge cases, and you’ll hit situations where one works and the other doesn’t.


Why Length Beats Complexity

Whether a hash is crackable comes down to two numbers: the keyspace (how many possible passwords there are) and the hash rate (how many guesses per second your hardware can make).

cracking time=keyspacehash rate\text{cracking time} = \frac{\text{keyspace}}{\text{hash rate}}

The keyspace is charset^length. And that exponent is everything.


Hardware sets the hash rate, and a GPU dwarfs a CPU:

AlgorithmCPUGPU
MD5~450 MH/s~68,000 MH/s
SHA-1~300 MH/s~21,500 MH/s
SHA-256~134 MH/s~9,300 MH/s

(MH/s = millions of hashes per second.) A modern GPU chews through billions of guesses a second.


But here’s the key insight. Compare two ways to make a password “stronger”:

  • Add complexity (a bigger character set): grows the keyspace polynomially
  • Add length (more characters): grows the keyspace exponentially

A longer password beats a more complex one, every time:

PasswordCharsetLengthKeyspaceGPU time (SHA-256)
5 chars625~916 millionunder a second
8 chars628~218 trillion~6.5 hours
10 chars6210~839 quadrillion~2.8 years

This is why “longer” beats “more complex”. Adding one character to a password multiplies the work far more than adding a symbol does. A passphrase of common words crushes P@ss1!.


Mutating Wordlists with Rules

Raw wordlists like rockyou.txt are full of weak, policy-failing passwords (password, 123456). Against a target that requires an uppercase letter, a number, and a symbol, those entries are useless as-is.

So you mutate them with rules: small transformations applied to every word.


Rules are built from rule functions. A few common ones:

FunctionEffectpassword becomes
cCapitalize first letterPassword
$1Append 1password1
^3Prepend 33password
$!Append !password!
sa@Substitute a with @p@ssword

Combine them on one line to apply together (c $1 $!Password1!). Put them on separate lines to apply each as its own rule, generating multiple variants per word.

# preview the mutations without cracking
hashcat -r rules.txt --stdout wordlist.txt

The reason this works is human predictability. When forced to add complexity, most people do the same things:

  • Capitalize the first letter (not a random one)
  • Put the number and symbol at the end (...1!)
  • Reuse easy digits (123, 1, birth years, 137)

Good rules encode human laziness. You’re not guessing randomly, you’re modelling exactly how people actually mangle their passwords. Hashcat ships proven rule sets in /usr/share/hashcat/rules/ (like best64.rule) for when you don’t know the policy.


A Cracking Methodology

Cracking is methodical. The reliable order of operations:

  1. Extract the hashes (from a database dump, a file, the OS)
  2. Identify & format them, the algorithm dictates the tool and the mode
  3. Estimate the time, is this even feasible before the engagement ends?
  4. Prepare the wordlist, pick lists and rules to match the likely password policy
  5. Attack the hash

Step two trips people up most. You have to know what kind of hash you’re holding:

hashid '$6$rounds=...'      # identify the hash type
hashcat --help | grep -i sha256   # find the matching mode number

Identification isn’t always certain. A bare 32-character hex string could be MD5, NTLM, or others, they look identical. When in doubt, confirm with a second tool before burning hours on the wrong mode.


Cracking Real Targets

The same methodology cracks more than database dumps.


Password Manager Vaults

Ironically, a cracked password manager hands you every password the victim stored. The vault is one file protected by one master password.

For a KeePass database (.kdbx):

keepass2john Database.kdbx > keepass.hash   # format it
hashcat -m 13400 keepass.hash rockyou.txt -r best64.rule

Crack the master password, open the vault, and the entire credential collection is yours.


SSH Private Key Passphrases

A stolen but encrypted SSH private key (id_rsa) is useless without its passphrase. So crack the passphrase:

ssh2john id_rsa > ssh.hash    # format it

This is also where the “learn both tools” lesson bites. Modern keys often use the aes-256-ctr cipher, which Hashcat can’t handle (it throws a token-length error), but John the Ripper can:

john --wordlist=passwords.txt --rules=myrules ssh.hash

When one tool chokes, reach for the other. A failed crack isn’t always a strong password, sometimes it’s just the wrong tool for that cipher.


Cracking handles hashes you can guess. But Windows authentication has a twist: some of its hashes can be used directly, without cracking at all. That’s the next note.


Practice Boxes