# Khaos Credential Discovery

> Discover valid credentials on login forms via brute force and default credential lists with CSRF token handling.

- Skill: `henriqqw/khaos-credential-discovery` (Agent Skill)
- Install (CLI): `npx get-skill add henriqqw/khaos-credential-discovery`
- Raw SKILL.md: https://api.skillmd.com/api/skills/henriqqw/khaos-credential-discovery/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- Author: henriqqw (https://skillmd.com/u/henriqqw)
- Updated: 2026-11-18
- Page: https://skillmd.com/skills/henriqqw/khaos-credential-discovery

---


# 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

1. **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

2. **Extract CSRF token** — Most frameworks rotate tokens per request. Retrieve the login page first, extract the token, then include it in every authentication attempt:
   ```python
   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.

3. **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.

4. **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
   ```

5. **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:
   ```python
   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
   ```

6. **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)

