> ## Documentation Index
> Fetch the complete documentation index at: https://0-x.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Password Cracking

This page focuses on turning a captured hash into a plaintext password. Every other page in this section, links back here rather than repeating command flags on every page.

> **Identify First**
>
> Cracking the wrong mode wastes time silently, hashcat and john just report no matches. Confirm the format before running anything.

> **Wordlist vs Mask**
>
> A wordlist (optionally mutated with rules) covers "probably a real word," a mask attack covers "I know the structure" (company name + 4 digits, etc.). Pick based on what you actually know about the target.

***

## Identifying the Hash

```bash theme={null}
hashid -j <hash>        # candidate John the Ripper format(s)
hashid -m <hash>        # candidate hashcat mode number(s)
```

[name-that-hash](https://github.com/HashPals/Name-That-Hash) is a more actively maintained alternative, worth trying when `hashid` comes back empty or not correct:

```bash theme={null}
nth --text '<hash>'
```

> [!TIP]
>
> [openwall's sample hashes](https://openwall.info/wiki/john/sample-hashes) and [pentestmonkey's John hash-format cheat sheet](https://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats) are the fastest way to eyeball-confirm a format against a known example when the identifier tools disagree or guess wrong.

***

## Weak/Unsalted Hashes: Try an Online Lookup First

MD5, SHA1, and NTLM are fast to compute and have no salt, which means the same plaintext always produces the same hash, so these specific hashes get precomputed and published in huge lookup databases. If the hash is one of these, checking it against a database takes seconds and is free, no GPU time spent, worth doing before reaching for cracking tool at all. A salted hash (bcrypt, sha512crypt, anything with a salt visible in the hash string) will never hit in these, every user's hash is unique even for the same password, so skip straight to the next section for those.

<table>
  <colgroup>
    <col width="164" />

    <col width="528" />
  </colgroup>

  <thead>
    <tr>
      <th>Site</th>
      <th>Covers</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>[CrackStation](https://crackstation.net/)</td>
      <td>MD5, SHA1, SHA256, SHA512, NTLM, MySQL, and more; largest free precomputed table (\~15 billion entries)</td>
    </tr>

    <tr>
      <td>[Hashes.com](https://hashes.com/en/decrypt/hash)</td>
      <td>Same idea, a different (and sometimes complementary) database, worth checking as a second source</td>
    </tr>
  </tbody>
</table>

***

## Hashcat

Hashcat is GPU-accelerated and the right default choice whenever a GPU is available, orders of magnitude faster than John on anything but CPU-only boxes.

```bash theme={null}
hashcat -m <mode> -a 0 <hash_file> <wordlist>     # -a 0: straight wordlist attack
hashcat -m <mode> -a 0 <hash_file> <wordlist> -r /usr/share/hashcat/rules/best64.rule   # with mutation rules
hashcat -m <mode> -a 3 <hash_file> '?u?l?l?l?l?d?d'   # -a 3: mask attack, see below
```

```bash theme={null}
hashcat --show <hash_file>      # show already-cracked results from the potfile without re-running
hashcat -I                       # list available OpenCL/CUDA devices
hashcat -b                       # benchmark, useful for estimating how long a full crack will take
```

### Common Hash Modes

<table>
  <colgroup>
    <col width="100" />

    <col width="400" />
  </colgroup>

  <thead>
    <tr>
      <th>Mode</th>
      <th>Hash Type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>0</td>
      <td>MD5</td>
    </tr>

    <tr>
      <td>100</td>
      <td>SHA1</td>
    </tr>

    <tr>
      <td>1400</td>
      <td>SHA256</td>
    </tr>

    <tr>
      <td>1700</td>
      <td>SHA512</td>
    </tr>

    <tr>
      <td>1000</td>
      <td>NTLM</td>
    </tr>

    <tr>
      <td>5600</td>
      <td>NetNTLMv2</td>
    </tr>

    <tr>
      <td>1800</td>
      <td>sha512crypt (modern Linux `/etc/shadow`)</td>
    </tr>

    <tr>
      <td>3200</td>
      <td>bcrypt</td>
    </tr>

    <tr>
      <td>13100</td>
      <td>Kerberos 5 TGS-REP (Kerberoasting)</td>
    </tr>

    <tr>
      <td>18200</td>
      <td>Kerberos 5 AS-REP (AS-REP Roasting)</td>
    </tr>

    <tr>
      <td>22000</td>
      <td>WPA-PBKDF2 (WPA/WPA2 handshake)</td>
    </tr>
  </tbody>
</table>

[Full mode list / example hashes](https://hashcat.net/wiki/doku.php?id=example_hashes) for anything not covered above.

### Mask Attack (`-a 3`)

Use when the password's structure is known or guessable (a fixed prefix, a date suffix) rather than wasting time on a full wordlist.

<table>
  <colgroup>
    <col width="100" />

    <col width="239" />
  </colgroup>

  <thead>
    <tr>
      <th>Symbol</th>
      <th>Charset</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`?l`</td>
      <td>lowercase a-z</td>
    </tr>

    <tr>
      <td>`?u`</td>
      <td>uppercase A-Z</td>
    </tr>

    <tr>
      <td>`?d`</td>
      <td>digits 0-9</td>
    </tr>

    <tr>
      <td>`?h`</td>
      <td>lowercase hex</td>
    </tr>

    <tr>
      <td>`?H`</td>
      <td>uppercase hex</td>
    </tr>

    <tr>
      <td>`?a`</td>
      <td>all of `?l?u?d?s` combined</td>
    </tr>

    <tr>
      <td>`?b`</td>
      <td>every byte, 0x00-0xff</td>
    </tr>

    <tr>
      <td>`?s`</td>
      <td>printable symbols</td>
    </tr>
  </tbody>
</table>

```bash theme={null}
hashcat -a 3 -m 1000 hashes.txt '?u?l?l?l?l?l?d?d?d?d'   # e.g. "Summer2024"-shaped passwords
```

### Generating a Mutated Wordlist Directly

Running a rule file against a base wordlist and saving the output (rather than feeding it live into hashcat) is useful when the same mutated list will be reused against multiple hash sets.

```bash theme={null}
hashcat --force password.list -r /usr/share/hashcat/rules/best64.rule --stdout | sort -u > mutated.list
```

> [!TIP]
>
> [OneRuleToRuleThemAll](https://github.com/NotSoSecure/password_cracking_rules) is a far more thorough rule set than `best64`, worth switching to once a quick pass with `best64` comes up empty.

***

## John the Ripper

Still the right tool for anything hashcat doesn't directly support, file-format hashes (SSH keys, Office documents, archives).

```bash theme={null}
john --wordlist=<wordlist> <hash_file>
john --format=<format> --wordlist=<wordlist> <hash_file>   # force a format when auto-detection guesses wrong
john --incremental <hash_file>                               # brute force without a wordlist
john --single <hash_file>                                     # mutates account/field info already in the hash file itself
john <hash_file> --show                                        # show already-cracked results
john --list=formats                                              # list every supported format
```

```bash theme={null}
locate *2john*          # list every extraction script John ships with
```

### Extracting Hashes from Common File Types

Each of these follows the same pattern: extract a crackable hash from the file, run it through John, then show the result.

| File Type | Extraction |
| - | - |
| SSH private key | `ssh2john.py id_rsa > ssh.hash` |
| PDF | `pdf2john.py file.pdf > pdf.hash` |
| Office (docx/xlsx) | `office2john.py file.docx > office.hash` |
| ZIP | `zip2john file.zip > zip.hash` |
| BitLocker | `bitlocker2john -i backup.vhd > backup.hashes` (then `grep "bitlocker\$0"` to isolate the right line) |
| Kerberos ticket (.kirbi) | `python2.7 kirbi2john.py ticket.kirbi` |

```bash theme={null}
john --wordlist=rockyou.txt ssh.hash
john ssh.hash --show
```

***

## Cracking an Encrypted Archive by Brute Force

When no `*2john` extractor fits (a password-protected `.gz`/`.tar.gz`, for example), trying every password directly against the decompressor works just as well, just slower.

```bash theme={null}
for pw in $(cat rockyou.txt); do openssl enc -aes-256-cbc -d -in archive.gz -k "$pw" 2>/dev/null | tar xz && echo "FOUND: $pw" && break; done
```

***

## Quick Reference Tools

> **[CrackStation](https://crackstation.net/)**
>
> Free online hash lookup against a huge precomputed wordlist, worth trying before spending GPU time on a common hash.

> **[name-that-hash](https://github.com/HashPals/Name-That-Hash)**
>
> More actively maintained hash identifier than hashid.

> **[OneRuleToRuleThemAll](https://github.com/NotSoSecure/password_cracking_rules)**
>
> The rule set to reach for once best64 comes up empty.

> **[Hashcat Example Hashes](https://hashcat.net/wiki/doku.php?id=example_hashes)**
>
> Full mode list with a real example of each hash type.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.