# Examples

Complete signatures that use only what the engine supports today. Each one
validates as written; paste it into the Signatures library, adjust the
paths and words to your target, and scan a target you are authorised to
test. The built-in signatures in `backend/templates` are further
examples.

## Error-based SQL injection

A payload list of quote characters against common parameters, with a
negative matcher for a page that always mentions SQL.

```yaml
id: example-sqli-error
name: SQL injection (database error)
severity: high
description: A quote character in a parameter produces a database error.
tags:
  - sqli
  - injection
info:
  cwe-id: CWE-89
  remediation: Use parameterised queries for every database access.

requests:
  - method: GET
    path:
      - "/?id={{payload}}"
      - "/search?q={{payload}}"
    attack: batteringram
    payloads:
      payload:
        - "'"
        - "\""

    matchers-condition: and
    matchers:
      - type: regex
        regex:
          - "SQL syntax.*?MySQL"
          - "PostgreSQL.*?ERROR"
          - "\\bORA-\\d{5}"
          - "SQLite3?::|SQLITE_ERROR"
      - type: word
        negative: true
        words:
          - "SQL tutorial"

    extractors:
      - type: regex
        name: error
        group: 0
        regex:
          - "(SQL syntax|PostgreSQL|ORA-|SQLite)[^<\\n]{0,120}"
```

Because the block has payloads and `?name=` paths, parameters found by the
crawler are fuzzed too ([injection paths](./requests.md#injection-paths)).

## Exposed Git metadata

Two paths, a status check and a word that only a Git config contains.

```yaml
id: example-git-config
name: Exposed Git configuration
severity: medium
tags:
  - exposure
info:
  cwe-id: CWE-538
  remediation: Block access to version control folders on the web server.

stop-at-first-match: true

requests:
  - method: GET
    path:
      - "/.git/config"
      - "{{RootURL}}/.git/config"
    stop-at-first-match: true

    matchers-condition: and
    matchers:
      - type: status
        status:
          - 200
      - type: word
        words:
          - "[core]"
          - "repositoryformatversion"
        condition: and
```

## Version disclosure in headers

A header extractor records the advertised software as evidence.

```yaml
id: example-server-banner
name: Server version disclosed in headers
severity: info
tags:
  - exposure
  - headers

requests:
  - method: GET
    path:
      - "/"

    matchers:
      - type: regex
        part: header
        regex:
          - "^(server|x-powered-by): [^\\n]*\\d+\\.\\d+"

    extractors:
      - type: kval
        name: banner
        kval:
          - server
          - x-powered-by
```

Header names in the `header` part are lowercase, which is why the pattern
uses lowercase names.

## Open redirect

The payload is a full URL in a redirect parameter. With redirect
following off (the scan default), the `location` header shows where the
target sends the browser.

```yaml
id: example-open-redirect
name: Open redirect
severity: medium
tags:
  - redirect
info:
  cwe-id: CWE-601
  remediation: Allow only relative or allow-listed redirect targets.

requests:
  - method: GET
    path:
      - "/?next={{payload}}"
      - "/login?redirect={{payload}}"
    payloads:
      payload:
        - "https://redirect-check.example/"
        - "//redirect-check.example/"

    matchers-condition: and
    matchers:
      - type: status
        status:
          - 301
          - 302
          - 303
          - 307
          - 308
      - type: regex
        part: header
        regex:
          - "^location: (https?:)?//redirect-check\\.example"
```

Regex patterns run in multiline mode, so `^` anchors at the start of each
header line.

## Default credentials

Pitchfork pairs each user name with its password, and a JSON extractor
keeps the issued token as evidence.

```yaml
id: example-default-login
name: Default credentials accepted
severity: high
tags:
  - auth
info:
  cwe-id: CWE-1392
  remediation: Remove default accounts or force a password change on first use.

requests:
  - method: POST
    path:
      - "/api/login"
    headers:
      Content-Type: application/json
    body: '{"username": "{{user}}", "password": "{{pass}}"}'
    attack: pitchfork
    payloads:
      user:
        - admin
        - root
      pass:
        - admin
        - toor

    matchers-condition: and
    matchers:
      - type: status
        status:
          - 200
      - type: word
        words:
          - "access_token"

    extractors:
      - type: json
        name: token
        json:
          - "access_token"
```

Logging in changes state on the target. Run signatures like this one only
where the program allows authentication testing.
