CTF Arsenal
Boot2Root/Password & Credential Attacks

Hash Identification & Cracking

Concept

Cracking recovers a plaintext password from its hash by guessing candidates (wordlist or brute-force) and comparing hash outputs. The hash format must be identified correctly first, since John/Hashcat need to know which algorithm to apply.

When to Use

  • You've extracted a password hash from a database dump, /etc/shadow, a config file, or a file's metadata.

Workflow

  1. 1
    Identify the hash format

    Length, prefix, charset give strong hints.

  2. 2
    Choose wordlist and tool

    rockyou.txt is the default CTF wordlist.

  3. 3
    Run the cracking tool

    John for CPU/varied formats, Hashcat for GPU speed.

  4. 4
    Validate the recovered password

    Try it against the actual service (SSH, login form).

Commands

hashid 'HASH_VALUE'
hashid '5f4dcc3b5aa765d61d8327deb882cf99'

Guesses possible hash algorithms based on length/format.

When to use: First step when you don't know what type of hash you have.

Expected output:

[+] MD5
[+] MD4
[+] NTLM

Look for: Multiple candidates are normal for short hex hashes — context (source system) narrows it down.

Next step: Pick the most contextually likely format and attempt a crack.

john --wordlist=FILE_PATH HASH_FILE
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

Runs John the Ripper against the hash file using the given wordlist.

  • --wordlist= — Path to the wordlist to try.

When to use: Default cracking attempt for most CTF hash formats (John auto-detects many formats from the hash string itself).

Expected output:

password123     (user)

Look for: A cracked line showing the plaintext next to the username/hash.

Next step: Use john --show hash.txt to re-display cracked results later.

hashcat -m MODE -a 0 HASH_FILE FILE_PATH
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt

Runs Hashcat in wordlist-attack mode against the given hash file using the GPU (much faster than John for large jobs).

  • -m MODE — Hash-type mode number (e.g. 0 = MD5, 1000 = NTLM, 1800 = sha512crypt). Look up the exact mode for your format.
  • -a 0 — Attack mode 0 = straight wordlist attack.

When to use: When John is too slow, or a GPU is available and the job is large.

Expected output:

5f4dcc3b5aa765d61d8327deb882cf99:password

Look for: hash:plaintext pairs in the output / hashcat --show.

Next step: Try the recovered password against the relevant service/account.

zip2john FILE_PATH > hash.txt / ssh2john FILE_PATH > hash.txt
ssh2john id_rsa > hash.txt

Converts a protected file format (zip, ssh key, etc.) into a John-crackable hash representation.

When to use: When you have a password-protected archive or an encrypted SSH private key, not a raw hash.

Expected output:

id_rsa:$sshng$1$...

Look for: A valid hash line produced; then feed it to john normally.

Next step: john --wordlist=rockyou.txt hash.txt, then use the cracked passphrase to decrypt the key.

Tools

John the Ripper

Versatile offline password cracker supporting many hash/file formats via *2john helper scripts.

When to use: Default first choice; broad format support, CPU-based.

sudo apt install john
john --wordlist=WORDLIST hash.txt

Example workflow: Convert file to hash with *2john -> crack with rockyou -> john --show to view.

Hashcat

GPU-accelerated password cracker; much faster at scale.

When to use: Large hash sets, slow algorithms (bcrypt), or when you need rule-based/mask attacks.

sudo apt install hashcat
hashcat -m MODE -a 0 hash.txt wordlist.txt

Example workflow: Identify mode number -> wordlist attack -> fall back to rule-based attack (-r rules/best64.rule) if plain wordlist fails.

Findings & Interpretation

Interesting

  • Weak/common passwords cracking instantly against rockyou
  • Reused passwords across multiple services found during the same engagement

False Positives

  • A hash that never cracks against rockyou isn't proof the password is 'unguessable' — try rule-based mutations before giving up

How to Validate

  • Always confirm a 'cracked' password actually authenticates against the real target, not just that the hash comparison matched

Next Step

  • Try the recovered credential against every other discovered service (credential reuse is extremely common in CTFs).

Troubleshooting

John reports 'No password hashes loaded'.

Likely cause: Wrong hash file format, or John didn't auto-detect the hash type correctly.

Verify: Open the hash file and confirm it matches the expected *2john output format exactly (no extra whitespace/encoding issues).

Fix: Specify the format explicitly: john --format=FORMAT_NAME hash.txt.

Recovery: Re-generate the hash file with the correct *2john script for the file type.

Avoid repeating: Always inspect the hash file content before running John, rather than assuming conversion succeeded silently.