Skip to content
Merged
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
26 changes: 22 additions & 4 deletions templates/protocols/headless.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,38 @@

### script

Script runs a JS code on the current browser page. At the simplest level, you can just provide a `code` argument with the JS snippet you want to execute, and it will be run on the page.
Script runs a JavaScript code on the current browser page. At the simplest level, you can just provide a `code` argument with the JS snippet you want to execute, and it will be run on the page.

```yaml
action: script
args:
code: alert(document.domain)
code: () => alert(document.domain)
```

<Warning>
The <code>code</code> property strictly requires a function reference. Direct expressions or values are invalid and will not work. Always use a function.

**Incorrect:**
```yaml
action: script
args:
code: alert(document.domain) # ❌ This is NOT a function reference
```

**Correct:**
```yaml
action: script
args:
code: () => alert(document.domain) # ✅ This is a function reference
```
</Warning>

Suppose you want to run a matcher on a JS object to inspect its value. This type of data extraction use cases are also supported with nuclei headless. As an example, let's say the application sets an object called `window.random-object` with a value, and you want to match on that value.

```yaml
- action: script
args:
code: window.random-object
code: () => window.random-object
name: script-name
...
matchers:
Expand All @@ -61,7 +79,7 @@
```yaml
- action: script
args:
code: (function() { window.alert=function(){} })()
code: () => (function() { window.alert=function(){} })()
hook: true
```

Expand All @@ -78,7 +96,7 @@
xpath: /html/body/div[1]/div[3]/form/div[2]/div[1]/div[1]/div/div[2]/input
```

Nuclei supports a variety of selector types, including but not limited to XPath, Regex, CSS, etc. For more information about selectors, see [here](#selectors).

Check warning on line 99 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L99

Did you really mean 'XPath'?

### rightclick

Expand Down Expand Up @@ -160,7 +178,7 @@
value: /root/test/payload.txt
```

### waitfcp

Check warning on line 181 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L181

Did you really mean 'waitfcp'?

WaitFCP waits for the first piece of meaningful content, such as text or an image, indicating that the page is becoming useful.

Expand All @@ -168,7 +186,7 @@
action: waitfcp
```

### waitfmp

Check warning on line 189 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L189

Did you really mean 'waitfmp'?

WaitFMP waits for the First Meaningful Paint event, allowing users to proceed when content is visually ready.

Expand All @@ -178,13 +196,13 @@

### waitdom

WaitDOM waits for the `DOMContentLoaded` event, indicating that the HTML has been loaded and parsed, but without waiting for stylesheets, images, and subframes to finish loading.

Check warning on line 199 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L199

Did you really mean 'subframes'?

```yaml
action: waitdom
```

### waitload

Check warning on line 205 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L205

Did you really mean 'waitload'?

WaitLoad waits the entire page, including dependent resources like stylesheets and images, has been fully loaded.

Expand All @@ -192,7 +210,7 @@
action: waitload
```

### waitidle

Check warning on line 213 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L213

Did you really mean 'waitidle'?

WaitIdle waits until the page completely stopped making network requests and reaches a network idle state, indicating that all resources have been loaded.

Expand All @@ -200,7 +218,7 @@
action: waitidle
```

### waitstable

Check warning on line 221 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L221

Did you really mean 'waitstable'?

WaitStable waits until the page is stable for *N* duration *(default is `1s`)*.

Expand All @@ -210,7 +228,7 @@
duration: 5s
```

### waitdialog

Check warning on line 231 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L231

Did you really mean 'waitdialog'?

WaitDialog will wait for a JavaScript dialog (`alert`, `confirm`, `prompt`, or `onbeforeunload`) to be initialized and then automatically accept it.

Expand All @@ -224,18 +242,18 @@
This action is useful for detecting triggered XSS payloads with a high level of accuracy and a low rate of false positives.

<Note>
The `name` property MUST be explicitly defined to ensure the output variable is available for later use by `matchers` or `extractors` wihtin your template. See the example [here](/templates/protocols/headless-examples#xss-detection).

Check warning on line 245 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L245

Did you really mean 'wihtin'?
</Note>

**Output variables:**

* **NAME** _(boolean)_, indicator of JavaScript dialog triggered.
* **NAME_type** _(string)_, dialog type (`alert`, `confirm`, `prompt`, or `onbeforeunload`).

Check warning on line 251 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L251

Did you really mean 'NAME_type'?
* **NAME_message** _(string)_, displayed message dialog.

Check warning on line 252 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L252

Did you really mean 'NAME_message'?

### getresource

GetResource returns the src attribute for an element.

Check warning on line 256 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L256

Did you really mean 'src'?

```yaml
action: getresource
Expand All @@ -249,7 +267,7 @@

Extract extracts either the Text for an HTML Node, or an attribute as specified by the user.

The below code will extract the Text for the given XPath Selector Element, which can then also be matched upon by name `extracted-value` with matchers and extractors.

Check warning on line 270 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L270

Did you really mean 'XPath'?

Check warning on line 270 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L270

Did you really mean 'matchers'?

```yaml
action: extract
Expand All @@ -271,7 +289,7 @@
attribute: href
```

### setmethod

Check warning on line 292 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L292

Did you really mean 'setmethod'?

SetMethod overrides the method for the request.

Expand All @@ -282,7 +300,7 @@
method: DELETE
```

### addheader

Check warning on line 303 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L303

Did you really mean 'addheader'?

AddHeader adds a header to the requests / responses. This does not overwrite any pre-existing headers.

Expand All @@ -294,7 +312,7 @@
value: "default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"
```

### setheader

Check warning on line 315 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L315

Did you really mean 'setheader'?

SetHeader sets a header in the requests / responses.

Expand All @@ -317,7 +335,7 @@
key: Content-Security-Policy
```

### setbody

Check warning on line 338 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L338

Did you really mean 'setbody'?

SetBody sets the body for a request / response.

Expand All @@ -328,7 +346,7 @@
body: '{"success":"ok"}'
```

### waitevent

Check warning on line 349 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L349

Did you really mean 'waitevent'?

WaitEvent waits for an event to trigger on the page.

Expand Down Expand Up @@ -379,14 +397,14 @@
| Selector | Description |
|----------------------|-----------------------------------------------------|
| `r` / `regex` | Element matches CSS Selector and Text Matches Regex |
| `x` / `xpath` | Element matches XPath selector |

Check warning on line 400 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L400

Did you really mean 'XPath'?
| `js` | Return elements from a JS function |
| `search` | Search for a query (can be text, XPATH, CSS) |
| `selector` (default) | Element matches CSS Selector |

## Matchers / Extractor Parts

Check warning on line 405 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L405

Did you really mean 'Matchers'?

Valid `part` values supported by **Headless** protocol for Matchers / Extractor are -

Check warning on line 407 in templates/protocols/headless.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

templates/protocols/headless.mdx#L407

Did you really mean 'Matchers'?

| Value | Description |
|-------------------|---------------------------------|
Expand Down
Loading