Skip to content

Extractors ​

Extractors pull values out of matched responses: a version string, an error message, a token. Visible extractors are stored with the finding's evidence, next to the request that produced them. Internal extractors keep their value as a variable for later requests instead.

Extractors run only on responses that matched. A block's own extractors replace the signature's top-level extractors for that block.

Extractor fields ​

yaml
extractors:
  - type: regex
    name: server_version
    part: header
    group: 1
    regex:
      - "server: ([^\\r\\n]+)"
FieldDefaultMeaning
typeregexregex, kval, json, xpath or dsl
nameextractor_<index>Key of the values in the evidence, and the variable name when internal
partbodyPart to read, as for matchers; kval always reads headers
internalfalseKeep the first value as a variable instead of adding it to the evidence

An extractor that finds nothing is left out of the evidence.

Regex ​

Every match of every pattern is collected. group selects the capture group, 1 by default; 0 takes the whole match. Empty captures are skipped. Patterns use the same flags as regex matchers (multiline and dot-all).

yaml
- type: regex
  name: error_message
  regex:
    - "(SQL syntax[^<]+)"

Header values (kval) ​

Reads response headers by name, without regard to case. Each listed name contributes its value when the header is present.

yaml
- type: kval
  name: headers
  kval:
    - server
    - x-powered-by

kval reads headers only; it does not read cookies or body fields.

JSON ​

Parses the chosen part as JSON and follows each dot-separated path. Path segments are object keys or list indexes.

yaml
- type: json
  name: user
  json:
    - "data.user.email"
    - "data.items.0.id"

A value that is a list contributes each element; other values are converted to text. A body that is not JSON yields nothing. Wildcards, filters and other query syntax are not supported.

XPath ​

Parses the chosen part as HTML and evaluates each XPath expression. For elements we take their direct text; for attribute and text queries, the string itself.

yaml
- type: xpath
  name: generator
  xpath:
    - "//meta[@name='generator']/@content"
    - "//title"

Content that cannot be parsed yields nothing.

DSL ​

type: dsl with a dsl list passes validation, but the scan does not evaluate DSL extractors yet: they always yield nothing. Use a regex, JSON or XPath extractor instead, and DSL expressions in matchers.

Internal extractors ​

With internal: true and a name, the first value found becomes a variable of that name for every later request of the signature. Internal values are not added to the evidence. Internal extractors are honoured on request blocks; at the top level of a signature they are skipped.

yaml
extractors:
  - type: regex
    name: csrf
    internal: true
    regex:
      - 'name="csrf_token" value="([^"]+)"'

See Requests for a complete chain.