Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

nuclei v2.9.5 docs #148

Merged
merged 5 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/templating-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ info:
metadata:
shodan-query: 'vuln:CVE-2021-26855'
```

!!! info "Note"
While creating a template, it's important to include the following mandatory fields: `id`, `name`, `authors` and `severity`.
If these mandatory fields are missing, then Nuclei will not proceed with such templates.
By following these guidelines, you can ensure that your templates are properly formatted and ready to be used with Nuclei.
44 changes: 43 additions & 1 deletion docs/templating-guide/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,46 @@ tcp:
part: data
words:
- "{{a2}}"
```
```

### Constants
In addition to variables, you can also define constants in templates. Constants are similar to variables but have a distinct difference: their values cannot be overridden or changed, even by command-line variables. They are used to declare scalar values that remain fixed throughout the template. Constants are helpful when you want to ensure that a specific value remains unchanged across multiple template executions.

To declare a constant, use the `constants` keyword followed by the constant name and its value. Constants are declared at the template level, just like variables.

Example constants:

```yaml
constants:
p: test
```

In the above example, `p` is a constant with the values `test`

Here's an example template that uses constants:

```yaml
id: constants-example

info:
name: Constants Example
author: pdteam
severity: info

constants:
p: test

http:
- raw:
- |
GET /api/data?param={{p}} HTTP/1.1
Host: {{Hostname}}
matchers:
- type: word
words:
- "OK"
```

If the same variable is passed via CLI, the value remains `test` (`nuclei -V p=anothervalue ...`).

Constants provide a way to ensure that specific values remain constant and cannot be modified, providing consistency and predictability in your templates.