Password Attacks with Hydra, John the Ripper, and Hashcat
Learn how attackers guess and crack passwords, practise Hydra, John the Ripper, and Hashcat in an isolated lab, and build defences that make credential theft expensive.
By the end, you’ll be able to…
- Distinguish online guessing, password spraying, credential stuffing, and offline cracking.
- Use Hydra safely against lab SSH and HTTP form logins while respecting lockout and rate limits.
- Identify common hash formats and run dictionary, rule, and mask attacks with John the Ripper and Hashcat.
- Explain modern password storage and authentication defences, including Argon2id, bcrypt, MFA, passkeys, and breached-password checks.
- Handle credentials lawfully, preserve evidence, and report findings without exposing secrets.
01Passwords Are a Design Problem, Not Just a User Problem
Passwords remain the front door to a remarkable number of systems. They protect email, virtual private networks, administrative consoles, databases, and the local accounts that exist on almost every operating system. A password is a shared secret: the user knows it, and the service stores something derived from it so it can check the next login. When that secret is weak, reused, phished, or stored with a fast hash, an attacker does not need a software vulnerability to get in.
Password attacks split into two worlds. In an online attack, the attacker sends guesses to a live authentication service. Every attempt costs a network round trip and may be slowed by rate limits, account lockout, multi-factor authentication, CAPTCHA, or alerting. Online attacks are noisy and can lock out real users, which is why spraying is often preferred to blind brute force. In an offline attack, the attacker already has password hashes from a backup, a database dump, or a captured challenge. The service is no longer involved. The attacker can test guesses as fast as their hardware allows, quietly and without touching the victim's network.
The difference matters for defence. Rate limits and lockout help online, but they do nothing once hashes are stolen. Strong password hashing, unique salts, and multi-factor authentication reduce the value of a stolen database. It also matters for ethics. Password guessing is intrusive and illegal without authorisation. This lesson uses only synthetic lab accounts and hashes you create in an isolated environment. Never point Hydra at a public service, and never crack hashes that belong to real people.
02Online Attacks: Brute Force, Spraying, and Stuffing
Brute force, spraying, and credential stuffing are often used interchangeably, but they describe different strategies. Brute force tries many passwords against one account, or systematically walks a keyspace. Password spraying tries a small number of common passwords, such as a seasonal pattern or a company name, across many accounts. Spraying is designed to stay under per-account lockout thresholds and to find the one user who chose the predictable password. Credential stuffing replays username and password pairs from an earlier breach. It is not guessing; it is exploiting reuse. A fourth category, default credentials, is even simpler: a device or application still accepts the factory login.
Hydra is a command-line online guessing tool. The important flags are -l for a single username, -L for a username list, -p for a single password, -P for a password list, -t for parallel tasks, -f to stop after the first success, -V to display attempts, and -s to choose a non-default port. Keep -t low in a lab because high concurrency can overload a service or trigger defences. For SSH, the target syntax is simple. For a web form, Hydra needs the form path, the field names, and a string that appears on a failed login. The placeholders ^USER^ and ^PASS^ are replaced at runtime. If the form uses a CSRF token, JavaScript, or JSON, Hydra may not work without custom handling; use the application's test harness or a small script instead of forcing the tool.
Defenders should assume that online guessing will happen. Per-account lockout is useful but can be abused to deny access, so pair it with rate limiting, exponential backoff, and risk-based challenges rather than a permanent lock. Monitor failed logins per account, per source address, per subnet, and per user agent. Spraying is specifically designed to evade a per-account threshold, so a detection that only counts failures for one user will miss it. Look for a small number of failures across many accounts from one source, a burst of 401 or 429 responses, successful logins after failures, impossible travel, new devices, and authentication attempts against disabled or nonexistent accounts. Alert on the pattern, not on a single failed password.
# Lab only: synthetic accounts and a target you own.# SSH: one user, a short lab wordlist, low concurrency.hydra -l student -P /usr/share/wordlists/lab-passwords.txt \ ssh://10.10.10.50 -t 4 -f -V# HTTP form: confirm the field names and failure message in the lab first.hydra -l student -P /usr/share/wordlists/lab-passwords.txt \ 10.10.10.50 http-post-form \ "/login:username=^USER^&password=^PASS^:F=Invalid username or password" \ -t 4 -f -V -o hydra-http.txt# If the form uses a CSRF token or JSON, Hydra needs custom handling.# Use the application's test harness or a small script instead of guessing.Hydra v9.5 starting [22][ssh] host: 10.10.10.50 login: student password: LabPass2026! 1 of 1 target successfully completed, 1 valid password found
03Offline Cracking: John the Ripper and Hashcat
Offline cracking starts with identifying the hash. A 32-character hexadecimal string could be an MD5 hash or an NTLM hash; the context decides. Modular crypt formats are easier: $1$ is md5crypt, $2a$ or $2b$ is bcrypt, $5$ is sha256crypt, and $6$ is sha512crypt. Hashcat names the common targets with mode numbers: 0 for MD5, 1000 for NTLM, 1800 for sha512crypt, and 3200 for bcrypt. John the Ripper uses format names such as raw-md5, nt, sha512crypt, and bcrypt. Use the wrong format and the tool will either reject the hash or waste time on the wrong algorithm.
Hashcat separates the hash type from the attack mode. The -m option selects the hash mode and -a selects the attack. Mode 0 is a straight dictionary, mode 3 is a mask, mode 6 is a hybrid word plus mask, and mode 7 is a mask plus word. Rules transform dictionary words, for example by appending a year or changing case, and often recover more passwords than a plain wordlist. A mask describes a pattern such as one uppercase letter, four lowercase letters, and three digits. Start with a dictionary, add rules, then use a targeted mask based on what you know about the lab account. Do not start with an enormous keyspace; measure the guess rate first.
rockyou.txt is a famous wordlist of roughly fourteen million passwords from a 2009 breach. Many Linux distributions ship it compressed at /usr/share/wordlists/rockyou.txt.gz; decompress it with gunzip or read it with zcat. It is useful because it reflects real human choices, not because it is magic. Modern passwords, long passphrases, and random manager-generated strings will not appear in it. SecLists and organisation-specific wordlists can supplement it. The real limits are entropy and hash cost. A salted bcrypt hash with a reasonable cost factor may allow only thousands of guesses per second, while an unsalted MD5 or NTLM hash can allow billions per second on a modern GPU.
GPU cracking is about parallel arithmetic. A graphics card can test many candidate hashes at once, but it needs correct drivers, enough video memory for the wordlist or mask, and adequate cooling. Hashcat benchmarks with -b and can set a workload profile with -w. Laptops thermal-throttle, cloud GPUs cost money, and a slow hash can make even a large rig look ordinary. Record the benchmark, the exact command, the wordlist or rule file, the start and end time, and the recovered result. The potfile stores recovered hashes; use a case-specific potfile path so different labs do not contaminate each other. Never include a recovered password in a public report without redaction.
# Lab hashes only, one per line. Record the source and a hash of the file.john --list=formats | tr ',' '\n' | grep -Ei 'raw-md5|nt|sha512crypt|bcrypt'# John: dictionary, then rules, then show results.john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt lab-md5.txtjohn --format=raw-md5 --rules --wordlist=/usr/share/wordlists/rockyou.txt lab-md5.txtjohn --show --format=raw-md5 lab-md5.txt# Hashcat: benchmark, dictionary, rules, then a targeted mask.hashcat -b -m 1000hashcat -m 1000 -a 0 lab-ntlm.txt /usr/share/wordlists/rockyou.txt -o recovered.txthashcat -m 1000 -a 0 lab-ntlm.txt /usr/share/wordlists/rockyou.txt \ -r /usr/share/hashcat/rules/best64.rulehashcat -m 1000 -a 3 lab-ntlm.txt '?u?l?l?l?l?d?d?d' --incrementhashcat -m 1800 -a 0 lab-sha512.txt /usr/share/wordlists/rockyou.txthashcat -m 3200 -a 0 lab-bcrypt.txt /usr/share/wordlists/rockyou.txthashcat -m 1000 lab-ntlm.txt --showlab-md5.txt:Summer2025! lab-ntlm.txt:Winter2026! Session..........: hashcat Speed.#1.........: 12.4 GH/s (NTLM) Recovered........: 1/1 (100.00%) Digests
04Defences That Make Guessing Expensive
Defences should make the attacker's economics worse at every layer. Multi-factor authentication is the highest-value control for online attacks because a guessed or stuffed password is no longer enough. Push-based MFA can be defeated by fatigue or adversary-in-the-middle phishing, so prefer phishing-resistant methods such as FIDO2 security keys and passkeys for administrators and high-risk users. Number matching, device context, conditional access, and short session lifetimes reduce the value of a stolen session. SMS codes are better than nothing but are vulnerable to interception and SIM swapping.
Password storage is a separate control. Use a modern, memory-hard algorithm such as Argon2id, or bcrypt with a carefully tuned cost factor. Both use unique salts and are deliberately slow. Do not use MD5, SHA-1, or a single round of SHA-256 for passwords. A server-side pepper stored outside the database adds defence if the database alone is stolen, but it must be managed carefully. Rehash on successful login when you raise the cost factor, and set a maximum password length that the algorithm can handle safely. Password composition rules are less important than length, breached-password screening, and a password manager.
Operational controls complete the picture. Enforce rate limits and backoff, alert on spraying patterns, disable legacy authentication protocols, revoke sessions after a suspected compromise, and notify users about new devices or unusual sign-ins. Check new passwords against a breached-password service using a privacy-preserving range query rather than sending the full password. Measure how many accounts still use weak or reused passwords, how quickly MFA is enforced, and how many alerts convert into real incidents. A password policy that users work around is worse than a shorter, honest policy backed by MFA and monitoring.
The ideas worth keeping.
- Online and offline attacks have different constraints; rate limits help online but not after hashes are stolen.
- Spraying and credential stuffing evade common lockout controls, so detection must look across accounts and sources.
- Hashcat hash modes and attack modes determine what you can test; record the wordlist, rules, hardware, and results.
- MFA or passkeys, Argon2id or bcrypt, monitoring, and breached-password checks make guessing expensive.
Make it yours.
Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.
Exercise 1: Build a lab hash-cracking plan
You have three lab hashes: an MD5, an NTLM, and a bcrypt hash, each from a test account you created. Describe the order you would test them, the Hashcat modes, and why bcrypt takes longer. Include the commands and the evidence you would record.
Explore a worked solution
Identify each hash first: MD5 uses mode 0, NTLM uses mode 1000, and bcrypt uses mode 3200. Start with MD5 because it is fast and unsalted, using a dictionary and then rules. Move to NTLM with the same wordlist and rules, then add a small targeted mask if the lab account uses a predictable pattern. Test bcrypt last with a short, targeted wordlist because its cost factor makes each guess expensive. Benchmark each mode with hashcat -b, record the command, wordlist or rule file, start and end time, hardware, and recovered result in a case-specific potfile. Store the hash file securely and redact any recovered password from the report. Use synthetic passwords only.The plan follows the cost of the target. Fast unsalted hashes fall first; deliberately slow hashes may not fall at all within a reasonable budget. Recording the method makes the finding reproducible.
Exercise 2: Defend a login endpoint
A web application has 200,000 users, no MFA, bcrypt password hashing, and no rate limiting. Attackers are spraying the password Spring2026! across many accounts. List five controls in priority order and explain one trade-off for each.
Explore a worked solution
1. Add rate limiting and exponential backoff per account, source address, and network, with alerting on spraying patterns. Trade-off: shared NAT and office networks can create false positives. 2. Enforce MFA, and prefer passkeys or FIDO2 for administrators and high-risk users. Trade-off: enrolment friction and support load. 3. Screen new passwords against breached-password lists and block the most common choices. Trade-off: users may need help choosing a compliant password. 4. Add risk-based challenges and temporary lockout instead of permanent lockout. Trade-off: attackers can still cause short denial of service. 5. Monitor identity logs, revoke sessions after suspicious success, and notify affected users. Trade-off: alert volume requires tuning. Keep bcrypt and review its cost factor, but do not treat hashing as a substitute for MFA.The controls address the online attack first, then reduce the value of a guessed password, then improve detection. Each control has an operational cost that must be managed.
What stayed with you?
Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.
Keep exploring.
The official references behind this lesson, when you want a second angle or the full details.
One lesson closer.
Reading is a start. Trying it yourself makes the connection.