Engine
To execute the code, a list of language interpreters, which are installed or available on the system environment, is specified. These interpreters can be and not limited tobash sh py python3, go, ps, pwsh, among others, and they are searched sequentially until a suitable one is found. The identifiers for these interpreters should correspond to their respective names or identifiers recognized by the system environment.
Common Interpreters
The following are some of the most commonly used interpreters with the Code protocol:Python
Python is widely available on most systems and can be used with engines such aspy, python, or python3. Python is typically pre-installed on macOS and many Linux distributions.
PowerShell
PowerShell can be used with engines such aspwsh, powershell, or powershell.exe. PowerShell may need to be installed separately depending on your operating system:
- macOS: Install PowerShell on macOS
- Linux: Install PowerShell on Linux
Parts
Validpart values supported by Code protocol for Matchers / Extractor are -
The provided example demonstrates the execution of a bash and python code snippet within the template. The specified engines are searched in the given order, and the code snippet is executed accordingly. Additionally, dynamic template variables are used in the code snippet, which are replaced with their respective values during the execution of the template which shows the flexibility and customization that can be achieved using this protocol.
Args
Args are arguments that are sent to engine while executing the code. For example if we want to bypass execution policy in powershell for specific template this can be done by adding following args to the template.Pattern
Pattern field can be used to customize name / extension of temporary file while executing a code snippet in a templatepattern: "*.ps1" will make sure that name of temporary file given pattern.
Examples
This code example shows a basic response based on DSL.*.ps1
Running Code Templates
By default Nuclei will not execute code templates. To enable code protocol execution,-code flag needs to be explicitly passed to nuclei.
Learn More
For more examples, please refer to example code-templates in integration tests.