# Payload attacks

A payload attack sends the same request block many times with different
values in its placeholders. The block lists its values under `payloads`,
one list per placeholder name, and `attack` says how the lists are
combined. Every combination is sent to every path of the block.

## Payload lists

```yaml
requests:
  - method: GET
    path:
      - "/?q={{payload}}"
      - "/search?term={{payload}}"

    payloads:
      payload:
        - "'"
        - "\""
        - "`"

    matchers:
      - type: regex
        regex:
          - "SQL syntax.*?MySQL"
```

`payloads` maps a placeholder name to a list of values written in the
signature. Each value is placed wherever that name appears in the paths,
headers and body. Payload values are text; they are not encoded for you,
so use a function such as `url_encode` where the position needs it.
Target context names and function calls inside a payload value are filled
in when the request is built; references to other variables are not.

Payloads apply to blocks built from `path`; a block's `raw` requests are
ignored when it has payloads.

Instead of a list, a placeholder can name a collection of the payload
library as `collection:<id>`:

```yaml
    payloads:
      user: collection:12
      password:
        - "admin"
        - "changeme"
```

When a scan starts, each referenced collection is read once and its
values (the first 5,000; the scan log says when a collection is larger)
take the place of the reference. A scan reaches its own vault's
collections and the global ones. A signature whose reference points at a
missing, archived or other vault's collection is skipped and the scan log
names it; it never runs with an empty list. Reading payloads from a file
is not supported.

## Attack modes

| `attack` | Requests per path | Combination |
|---|---|---|
| `batteringram` (default) | length of the first list | One value at a time, placed in every placeholder |
| `pitchfork` | length of the shortest list | The n-th value of every list together |
| `clusterbomb` | product of all list lengths | Every combination of values |

### Batteringram

Takes the values of the first list only, and sets every payload name to
the same value. Use it with one list, or when the same value belongs in
several positions.

```yaml
attack: batteringram
payloads:
  payload:
    - "../../etc/passwd"
    - "..%2f..%2fetc%2fpasswd"
```

### Pitchfork

Walks the lists side by side: the first request uses the first value of
each list, the second the second, and so on. It stops at the end of the
shortest list.

```yaml
attack: pitchfork
payloads:
  username:
    - admin
    - root
  password:
    - admin
    - toor
```

This sends `admin` / `admin` and `root` / `toor`.

### Clusterbomb

Sends every combination of the lists. The number of requests grows fast:
three lists of ten values are a thousand requests per path.

```yaml
attack: clusterbomb
payloads:
  username:
    - admin
    - test
  password:
    - admin
    - password
    - "123456"
```

This sends six requests per path.

## Concurrency and evidence

All requests of a payload block are prepared first and sent concurrently,
bounded by the scan's `http.concurrency` setting, then judged in order.
Each matching response becomes one result, recorded with the payload value
(batteringram) or the map of values (pitchfork, clusterbomb) that produced
it, so the finding's evidence shows which input triggered it.

`stop-at-first-match` does not cut a payload block short, because its
requests are already in flight; it still prevents later blocks from
running. See [Requests](./requests.md#stopping-early).

## Scope and load

Every payload request is checked against the vault's scope like any other
scan request. Large clusterbomb attacks are slow and visible to the
target; prefer a short list of precise values over exhaustive ones, and
keep wide fuzzing for Intruder, where you can watch and stop an attack as
it runs.
