nuclei
nuclei copied to clipboard
Conditional request execution support in template
Please describe your feature request:
Currently, conditional request / template execution is possible with workflows (sub-templates) which is useful for complex chains but not practical for quick and basic check in same template as such similar support needs to be extended in the template as well.
Describe the use case of this feature:
Writing a multi step template that needs to executed if previous request/matcher returns true to avoid sending unwanted additional requests in failed condition.
Here is an example template with conditional request execution using if annotation to confirm request execution only when previous match returns true.
id: basic-raw-example
info:
name: Test RAW Template
author: pdteam
severity: info
requests:
- raw:
- |
GET /req1 HTTP/1.1
Host: {{Hostname}}
Origin: {{BaseURL}}
Connection: close
matchers:
- type: status
status:
- 200
- raw:
- |
if: matcher_status_1 == true
GET /req2 HTTP/1.1
Host: {{Hostname}}
Origin: {{BaseURL}}
- |
GET /req3 HTTP/1.1
Host: {{Hostname}}
Origin: {{BaseURL}}
- |
GET /req4 HTTP/1.1
Host: {{Hostname}}
Origin: {{BaseURL}}
matchers-condition: and
matchers:
- type: status
status:
- 200
- type: word
words:
- "Test1"
Reference:
- https://github.com/projectdiscovery/nuclei/issues/2100
- https://github.com/projectdiscovery/nuclei/discussions/2016
- https://github.com/projectdiscovery/nuclei/issues/1879
- https://github.com/projectdiscovery/nuclei/issues/7