Table of Contents
- Nuclei YAML Syntax Documentation
- Environment & CLI Variables Support
- JSON and XPath Extractors
- Elasticsearch Exporter
- JSONSchema Support for Nuclei Syntax
- More features for HTTP Protocol
- New Global Variables
- Unified Attack mode support
- Stop At First Match
- Metadata attribute
- Scan optimization
- Template validation enhancement
Authors
Nuclei YAML Syntax Documentation
A common problem with YAML syntax is figuring out all the supported fields and their relevant documentation. With Nuclei, this has always been a barrier of entry for people new to the project.
This Automatically Generated Documentation for Nuclei YAML Syntax is a step in this direction, making the Nuclei Syntax easier for people to understand and get working with. The documentation is generated using yamldoc-go, which is based on the amazing work of talos-system people.
A link to the documentation is provided below. It contains all the fields in the syntax, along with descriptions and examples.
The documentation is generated from code on each release, so you can be sure that it will always be up-to-date with the latest engine features.
Environment & CLI Variables Support
This addition allows using values from Environment Variable inside a template with an optional flag -env-vars
. When enabled, all the values in env are available for use in a template.
yaml
1requests:2- method: GET3path:4- "{{BaseURL}}"5headers:6Content-Type: '{{ENV_TEST}}'
In the above example, the ENV_TEST
string will be replaced with the environment variable value of ENV_TEST.
It has also been made possible to specify these variables from CLI. This can be done using the -var key=value
flag syntax. The above example ENV_TEST
can be replicated from CLI with the -var ENV_TEST=example
flag.
This feature also allows us to create templates that conduct authenticated actions without hardcoding keys or credentials.
JSON and XPath Extractors
Two new extractor types have been added to nuclei - json
and xpath
.
JSON extractor allows using JQ-style syntax to extract items from json responses. An example of using JSON extractor to extract IDs from Gitlab project ids is provided below.
yaml
1extractors:2- type: json3part: body4json:5- '.[] | .id'
XPath extractor allows using XPath expressions to extract items from HTML responses. An optional attribute to extract can also be provided.
yaml
1extractors:2- type: xpath3part: body4attribute: href5xpath:6- "/html/body/div/p[2]/a"
Elasticsearch Exporter
It is now possible to export results directly from nuclei to Elasticsearch. This can be used for result visualization as well as data storage. The below-provided configuration file can be used with nuclei to export data to Elasticsearch.
yaml
1elasticsearch:2# IP for elasticsearch instance3ip: 127.0.0.14# Port is the port of elasticsearch instance5port: 92006# IndexName is the name of the elasticsearch index7index-name: nuclei8# SSL enables ssl for elasticsearch connection9# ssl: false10# SSLVerification disables SSL verification for elasticsearch11# ssl-verification: false12# Username for the elasticsearch instance13# username: test14# Pasword is the password for elasticsearch instance15# password: test
Running nuclei with nuclei -rc config.yaml -t <templates> -l <list>
sends the found results to Elasticsearch, which can now be visualized with Kibana and other solutions.
JSONSchema Support for Nuclei Syntax
An automatically generated json-schema for the Nuclei YAML Syntax has been added to the repository as well. The link is provided below -
This schema can be used as a starting point for Nuclei Intellisense support. A more detailed Blog Post regarding all Editor integrations will come soon; however, until then, you can follow the medium post here to set up Nuclei YAML JSONSchema in your editor. The link provided is for VSCode; however, it should be similar for other editors.
More features for HTTP Protocol
New Global Variables
A list of new variables has been added to Nuclei HTTP Module, generated from the provided URL, and can be used anywhere within the request block. An example is provided below, including new variables -
https://example.com:443/foo/bar.php
Variable | Value |
---|---|
{{BaseURL}} | https://example.com:443/foo/bar.php |
{{RootURL}} | https://example.com:443 |
{{Hostname}} | example.com:443 |
{{Host}} | example.com |
{{Port}} | 443 |
{{Path}} | /foo |
{{File}} | bar.php |
{{Scheme}} | https |
Unified Attack mode support
The nuclei Attack module where the engine tries a combination of payload values and helper functions is now available for use in the Base HTTP request. Earlier, these could only be used in conjunction with Raw HTTP requests.
yaml
1id: basic-http-payload-helpers-example23info:4name: Test HTTP Payload Template5author: pdteam6severity: info78requests:9- method: GET10path:11- "{{BaseURL}}/{{path}}"12headers:13hello: "{{md5('Hello')}}"14payloads:15path:16- abc17- dsa18attack: sniper1920matchers:21- type: status22status:23- 200
Stop At First Match
stop-at-first-match
is now supported in the template for HTTP requests. What this means is, if there are multiple requests, nuclei will stop sending requests as soon as it gets a match. This is useful in cases like brute-forcing, etc., where you want to stop after finding the first match. Previously, it was supported by a CLI flag that applied to all templates, and now it can be defined within a template, allowing it to be used in particular cases.
yaml
1id: test-stop-at-first-match23info:4name: test-stop-at-first-match5author: pdteam6severity: info78requests:9- method: GET10path:11- "{{BaseURL}}/php.php"12- "{{BaseURL}}/phpinfo.php"13- "{{BaseURL}}/info.php"14- "{{BaseURL}}/infophp.php"15- "{{BaseURL}}/php_info.php"16- "{{BaseURL}}/test.php"17- "{{BaseURL}}/i.php"18- "{{BaseURL}}/asdf.php"1920stop-at-first-match: true21matchers:22- type: word23words:24- "PHP Extension"25- "PHP Version"26condition: and
Metadata attribute
A new info
field has been added called metadata
which can be used to provide extra metadata information in the template. This also means dynamic key: value fields now can be defined within the metadata
block rather than outside of it, and the templates with additional fields in the earlier format will still work but will not be processed in the JSON output.
yaml
1info:2name: Name # static field3author: test # static field4severity: info # static field5description: Description # static optional field6remediation: Remediation # static optional field7reference: https://example.com # static optional field8tags: cve,xss # static optional field9metadata:10os: linux # dynamic optional field11vendor: jira # dynamic optional field
Scan optimization
Nuclei now track errors occurring for each Host, and if it exceeds a certain threshold defined by the max-host-error
flag, the host is skipped from the scan. This saves a lot of time by not trying further template scans on unresponsive or continuously failing hosts.
Template validation enhancement
Nuclei engine now has stronger validation for loaded templates and displays the number of templates loaded with the invalid format, including errors and warnings; also, the validate
flag has been upgraded to detect and report the error information to help with template fixing.
Numerous small crashes and issues have been fixed to make the overall experience smoother and better. The codebase has also been refactored to introduce new ideas to make it scalable and maintainable for the future.
GitHub issues closed in this release can be found here, and the complete changelog of the release is available on the GitHub release page.