> For the complete documentation index, see [llms.txt](https://0xyogesh.gitbook.io/exploitnotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xyogesh.gitbook.io/exploitnotes/writeups/hacksmarter/hunter.md). Agents can also search and read this documentation through its [MCP server](https://0xyogesh.gitbook.io/exploitnotes/~gitbook/mcp).

# Hunter

## Overview

Target: `<machine-ip>` Scope: External login/password-reset portal ("HackSmarter Portal") Goal: Identify a valid username from a wordlist of OSINT-sourced candidates, where the application's login and reset forms return identical content for both valid and invalid usernames.

### Recon

#### Port scan

```bash
rustscan -a <machine-ip> --ulimit 5000
nmap -sC -sV <machine-ip> -p 22,80 -oN nmap-hunter
```

```
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.13
80/tcp open  http    Werkzeug httpd 3.1.4 (Python 3.10.12)
```

The HTTP service is a Flask application served via Werkzeug's development server - notable because Werkzeug's dev server is single-threaded by default, a detail that becomes relevant later when deciding how to automate timing measurements.

#### Application fingerprint

```bash
curl -s http://<machine-ip>/
```

A simple Bootstrap-styled login form (`/login`, POST) with a "Forgot password?" link pointing to `/reset`. Both endpoints accept `username` as a form field.

### Attempt 1: Content-based differentiation on `/login`

The obvious first move is checking whether the login response differs for a valid vs. invalid username (a very common mistake - e.g. "user not found" vs "incorrect password").

```bash
curl -s -X POST http://<machine-ip>/login -d 'username=test&password=test'
```

The response was identical (same 1993-byte body, same status) regardless of username. Confirmed with several more usernames - no content-based signal on `/login`.

### Attempt 2: `ffuf` content-length fuzzing on `/login`

With a 301-entry OSINT username wordlist in hand, the next step was fuzzing with a filter on the known baseline response size:

```bash
ffuf -w usernames.txt:FUZZ -X POST -d 'username=FUZZ&password=wrongpassword123' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -u http://<machine-ip>/login \
  -fs 1993
```

Every single result was filtered out - all 301 usernames returned the exact same 1993-byte response. No content-length signal either.

### Attempt 3: Timing analysis on `/login`

Since content gave nothing, the next hypothesis was a timing side-channel - a common pattern where the backend does extra work (e.g. a real bcrypt comparison) only when the username exists, while non-existent usernames short-circuit early.

An initial concurrent `ffuf` run (48 req/sec) against `/login` suggested two candidates (`tommy`, `tim`) with roughly double the response time of the rest of the pack. However, this did not hold up:

* A controlled sequential rerun (`curl` loop, 3 samples) was inconsistent.
* A larger sequential run (20 samples, min/median) showed `tommy`/`tim` as *faster* than a known-fake username, not slower.
* Adding more known-fake controls (`randomuser1`, `fakeperson2`, `nobody999`) broke the pattern entirely - `nobody999` had the lowest minimum time of the whole set.

**Conclusion:** the apparent signal on `/login` was noise from the original concurrent fuzzing run, not a real timing side-channel. `/login` appears genuinely hardened against both content and timing-based enumeration.

**Lesson carried forward:** concurrent request timing is unreliable, especially against a single-threaded dev server - requests queue server-side, and whichever happens to land near another request picks up artificial delay. All further timing analysis was done sequentially, one request at a time, using **minimum** response time (not mean) as the primary statistic, since network noise can only add delay, never remove it - the minimum across many samples is the most honest approximation of true processing time.

A header/cookie diff between a candidate and a known-fake username was also checked and came back empty (only the `Date` header differed):

```bash
curl -s -i -X POST http://<machine-ip>/login -d 'username=tommy&password=wrongpass123' > a.txt
curl -s -i -X POST http://<machine-ip>/login -d 'username=nobody999&password=wrongpass123' > b.txt
diff a.txt b.txt
```

### Attempt 4: Pivot to `/reset`

`/login` was abandoned in favor of `/reset`, on the theory that a password-reset flow is more likely to do meaningful extra backend work for valid accounts (token generation, DB writes, simulated email dispatch) than a login form does.

Content-based checks were repeated first and again came back empty:

```bash
curl -s -X POST http://<machine-ip>/reset -d 'username=definitelynotarealuser12345' | md5sum
curl -s -X POST http://<machine-ip>/reset -d 'username=admin' | md5sum
# identical hashes
```

### Timing analysis on `/reset`

#### Tooling

Two complementary approaches were used:

**1. `ffuf` with the `-ft` (filter-by-time) flag** - the fast, quick-triage option. `-ft` filters results by time-to-first-byte in milliseconds and supports `<`/`>` comparison operators:

```bash
ffuf -w usernames.txt:FUZZ -X POST -d 'username=FUZZ' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -u http://<machine-ip>/reset \
  -ft '<800'
```

This filters out every response under 800ms, leaving only slow (potentially valid) usernames in the output. It's fast but single-shot per candidate, so it's best used as a quick first pass rather than a rigorous confirmation - a single slow sample can be noise from network jitter or server contention.

**2. A custom Python script (`reset_timing.py`)** for rigorous, large-sample confirmation. Key design points:

* **Sequential requests only**, never concurrent - the target's single-threaded Werkzeug dev server would otherwise queue concurrent requests and corrupt the timing data.
* **Two-phase mode** (`--screen`): a fast first pass with a small sample size (e.g. 5 requests/user) across the entire wordlist to flag outliers, followed by a precise second pass with a much larger sample size (e.g. 50 requests/user) on only the handful of flagged candidates. This cuts total runtime by roughly 10x compared to running a large sample against all 301 usernames up front - the naive full approach (301 × 50 requests at \~0.6s each) would take 2.5–3 hours; the two-phase approach finishes in well under an hour.
* Reports **min, p10, median, and mean** per username - min is the most reliable statistic for isolating true processing-time differences from network noise.

```bash
python3 reset_timing.py -u http://<machine-ip>/reset -w usernames.txt --screen 5 -n 50 --top 15 -o reset_results.csv
```

#### Results

Phase 1 (5 requests × 301 usernames) flagged 30 candidates (15 fastest + 15 slowest by min time) for the precise pass. Phase 2 (50 requests × 30 candidates) gave a clean, unambiguous result:

| Username                 | min time    | Δ vs. baseline median (0.5408s) |
| ------------------------ | ----------- | ------------------------------- |
| **\<redacted-username>** | **1.3712s** | **+0.8304s**                    |
| hector                   | 0.6146s     | +0.0738s                        |
| jack                     | 0.5905s     | +0.0497s                        |
| ...rest of pack...       | 0.51s–0.61s | ±0.08s                          |

Every username except `<redacted-username>` clustered tightly between \~0.51s and \~0.61s - a spread of roughly 0.1 seconds consistent with normal network jitter. `<redacted-username>`, by contrast, sat at **1.37s**, nearly **2.5x** the baseline, and this held consistently across two fully independent measurement passes (the initial screen: 1.433s min; the precise 50-sample pass: 1.371s min).

#### Confirmation

A final isolated run comparing `<redacted-username>` against two definite non-existent usernames over 30 sequential requests each confirmed the finding cleanly and reproducibly, with `<redacted-username>` consistently 0.7–0.9 seconds slower at minimum.

As a last, single-command confirmation, `ffuf -ft` was rerun against the full wordlist with the threshold raised from `<800` to `<900`:

```bash
ffuf -w usernames.txt:FUZZ -X POST -d 'username=FUZZ' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -u http://<machine-ip>/reset \
  -ft '<900'
```

At `-ft '<800'`, a handful of extra names appeared alongside `<redacted-username>` (`micheal`, `jay`, `calvin`, `tom`, `jim`) - an artifact of ffuf's 40 concurrent threads queuing against the target's single-threaded dev server, occasionally inflating an unrelated request's duration past the 800ms mark by coincidence. Raising the threshold to `<900` cleared that noise, since `<redacted-username>`'s genuine signal (consistently 1.2–1.5s) sits well above it while queuing-induced noise stays below it. Across two repeated runs at `<900`, **`<redacted-username>` was the sole result both times** - a clean, single-command, fully reproducible confirmation.

### Root Cause

The `/reset` endpoint returns **identical response content** (body, headers, status code) regardless of whether the submitted username exists. However, response **time** differs significantly between valid and invalid usernames - almost certainly because the backend performs meaningful extra work only for accounts that exist (e.g. looking up the account record, generating a reset token, writing it to storage, and/or attempting to dispatch a reset email), while a nonexistent username allows the request to short-circuit immediately after a failed lookup.

This is a classic **username enumeration via timing side-channel**: the response body gives nothing away, but the measurable processing-time gap is large enough to reliably distinguish valid from invalid accounts with a modest number of samples.

### Finding: Valid Username

**`<redacted-username>`** is a valid username on the HackSmarter Portal.

### Remediation

* Ensure the `/reset` endpoint performs constant-time work regardless of username validity - e.g. always perform a dummy hash/token-generation operation of equivalent cost for nonexistent usernames, rather than short-circuiting early.
* Alternatively, decouple the expensive work (token generation, email dispatch) from the HTTP response entirely by queuing it asynchronously, so the client-facing response time is constant regardless of outcome.
* Return a generic, identically-timed response for all `/reset` submissions ("If an account with that username exists, a reset link has been sent") - this is the standard mitigation and was already correctly implemented for *response content*, but not for *response timing*.

### Tooling Notes / Lessons Learned

* **Concurrent timing measurements are unreliable**, especially against single-threaded backends (common with Flask dev servers) - queuing effects produce false positives. Always validate an initial concurrent-scan signal with a sequential, controlled rerun before trusting it.
* **Use minimum time, not mean**, as the primary statistic when hunting for timing side-channels - network noise only ever adds latency, so the minimum across many samples best approximates true server-side processing time.
* **`ffuf -ft`** is a genuinely useful built-in flag for quick timing-based triage. A single threshold value isn't always right the first try - concurrent threads can inflate occasional unrelated results past a too-tight cutoff, so it's worth re-running at a slightly higher threshold to see if the candidate pool collapses to a stable, repeatable result (as it did here, going from `<800` to `<900`) before trusting the output.
* A **two-phase screen-then-confirm approach** (few samples across the full list, then many samples on the short list of outliers) is far more time-efficient than brute-forcing a large sample size across an entire wordlist, while preserving the statistical confidence needed for a reliable finding.
