Types
Multiple matchers can be specified in a request. There are basically 7 types of matchers:Matcher Type | Part Matched |
---|---|
status | Integer Comparisons of Part |
size | Content Length of Part |
word | Part for a protocol |
regex | Part for a protocol |
binary | Part for a protocol |
dsl | Part for a protocol |
xpath | Part for a protocol |
Response Part | Description | Example |
---|---|---|
content_length | Content-Length Header | content_length >= 1024 |
status_code | Response Status Code | status_code==200 |
all_headers | Unique string containing all headers | len(all_headers) |
body | Body as string | len(body) |
header_name | Lowercase header name with - converted to _ | len(user_agent) |
raw | Headers + Response | len(raw) |
Conditions
Multiple words and regexes can be specified in a single matcher and can be configured with different conditions like AND and OR. When no condition is specified, OR is used as the default.- AND - Using AND conditions allows matching of all the words from the list of words for the matcher. Only then will the request be marked as successful when all the words have been matched.
- OR - Using OR conditions allows matching of a single word from the list of matcher. The request will be marked as successful when even one of the word is matched for the matcher.
Matched Parts
Multiple parts of the response can also be matched for the request, default matched part isbody
if not defined.
Example matchers for HTTP response body using the AND condition:
Negative Matchers
All types of matchers also support negative conditions, mostly useful when you look for a match with an exclusions. This can be used by addingnegative: true
in the matchers block.
Here is an example syntax using negative
condition, this will return all the URLs not having PHPSESSID
in the response header.
Multiple Matchers
Multiple matchers can be used in a single template to fingerprint multiple conditions with a single request. Here is an example of syntax for multiple matchers.Matchers Condition
While using multiple matchers the default condition is to follow OR operation in between all the matchers, AND operation can be used to make sure return the result if all matchers returns true.Internal Matchers
When writing multi-protocol orflow
based templates, there might be a case where we need to validate/match first request then proceed to next request and a good example of this is CVE-2023-6553
In this template, we are first checking if target is actual using Backup Migration
plugin using matchers and if true then proceed to next request with help of flow
But this will print two results, one for each request match since we are using the first request matchers as a pre-condition to proceed to next request we can mark it as internal using internal: true
in the matchers block.
Global Matchers
Global matchers are essentiallymatchers
that apply globally across all HTTP responses received from running other templates. This makes them super useful for things like passive detection, fingerprinting, spotting errors, WAF detection, identifying unusual behaviors, or even catching secrets and information leaks. By setting global-matchers
to true, you’re enabling the template to automatically match events triggered by other templates without having to configure them individually.
- Global matchers only work with HTTP-protocol-based templates.
- When global matchers are enabled, no requests defined in the template will be sent.
- This feature is not limited to
matchers
; you can also defineextractors
in a global matchers template.
global-matchers
set to true. It looks for specific patterns, like an asymmetric private key or a Slack webhook, across all HTTP requests. Now, when you run this template along with others, the global matcher will automatically check for those patterns in all HTTP responses. You don’t have to set up individual matchers in every single template for it to work.
To run it, use a command like this:
Global matchers are NOT applied by default. You need to explicitly enable them using the
-enable-global-matchers
/-egm
flag or programmatically via nuclei.EnableGlobalMatchersTemplates
if you’re working with the Nuclei SDK.