> For the complete documentation index, see [llms.txt](https://documentation.hak5.org/packet-squirrel-mark-ii/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.hak5.org/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel.md).

# DuckyScript for Packet Squirrel

DuckyScript is the payload language of Hak5 gear.

Originating on the [Hak5 USB Rubber Ducky](https://shop.hak5.org/products/usb-rubber-ducky) as a standalone language, the Packet Squirrel uses DuckyScript commands to bring the ethos of easy-to-use actions to the payload language.

DuckyScript commands are always in all capital letters to distinguish them from other system or script language commands.  Typically, they take a small number of options (or sometimes no options at all).

Payloads can be constructed of DuckyScript commands alone, or combined with the power of `bash` scripting and system commands to create fully custom, advanced actions.

{% hint style="warning" %}
While the Packet Squirrel supports multiple languages for payloads (such as Python), all example use of the DuckyScript commands will be shown using a `bash` based payload.  For other, custom payloads, the DuckyScript commands should be executed as system commands.
{% endhint %}

Ducky Script commands for the Packet Squirrel include:

<table><thead><tr><th width="208">Command</th><th data-type="content-ref">Documentation</th><th>Description</th></tr></thead><tbody><tr><td><code>BUTTON</code></td><td><a href="/pages/G3UYbrlR11TT4P2u2zpv">/pages/G3UYbrlR11TT4P2u2zpv</a></td><td>Pauses the payload for the specified number of seconds or until the button is pressed.</td></tr><tr><td><code>C2EXFIL</code></td><td><a href="/pages/8xkATLK4LtsnPFt85yL0">/pages/8xkATLK4LtsnPFt85yL0</a></td><td>Send a file via Cloud C²</td></tr><tr><td><code>C2NOTIFY</code></td><td><a href="/pages/rkGEtvtBBcyIpHqD9fMs">/pages/rkGEtvtBBcyIpHqD9fMs</a></td><td>Send a notification via Cloud C²</td></tr><tr><td><code>C2WATCHDIR</code></td><td><a href="/pages/R2Z6ebsqRfEjQNi4c4OP">/pages/R2Z6ebsqRfEjQNi4c4OP</a></td><td>Watch for new files in a directory and automatically send them to Cloud C²</td></tr><tr><td><code>DYNAMICPROXY</code></td><td><a href="/pages/9Xs2yLtRbZ9yedc9HIdG">/pages/9Xs2yLtRbZ9yedc9HIdG</a></td><td>Create a dynamic man-in-the-middle TCP proxy to intercept traffic in <code>NAT</code> and <code>BRIDGE</code> modes.</td></tr><tr><td><code>KILLPORT</code></td><td><a href="/pages/BXkImcXidJJIxotH5wXQ">/pages/BXkImcXidJJIxotH5wXQ</a></td><td>Kill any traffic seen on one or several ports by injecting TCP RST packets.</td></tr><tr><td><code>KILLSTREAM</code></td><td><a href="/pages/TggQHjUFfyylQqBtj3mH">/pages/TggQHjUFfyylQqBtj3mH</a></td><td>Kill any streams on or several ports by injecting TCP RST packets.</td></tr><tr><td><code>LED</code></td><td><a href="/pages/NoIrssGRIxRz6Qs4UHmR">/pages/NoIrssGRIxRz6Qs4UHmR</a></td><td>Control the RGB LED on the front of the Packet Squirrel; parameters include color and pattern.</td></tr><tr><td><code>MATCHPORT</code></td><td><a href="/pages/vPvG9rhUMP6HuwAS1YdX">/pages/vPvG9rhUMP6HuwAS1YdX</a></td><td>Pause the payload until traffic is matched on one or more ports. </td></tr><tr><td><code>MATCHSTREAM</code></td><td><a href="/pages/LZRwoGXI2YSpHjssBL3w">/pages/LZRwoGXI2YSpHjssBL3w</a></td><td>Pause the payload until traffic matching a regular expression is seen.</td></tr><tr><td><code>NETMODE</code></td><td><a href="/pages/JGCSatGwouSUXyjEoJA6">/pages/JGCSatGwouSUXyjEoJA6</a></td><td>Set the <a href="/pages/zFzr2IVlRxC5gZW5JXj2">network mode</a> of the Packet Squirrel.</td></tr><tr><td><code>SELFDESTRUCT</code></td><td><a href="/pages/VWMMxHmyzemwoRrVV0nQ">/pages/VWMMxHmyzemwoRrVV0nQ</a></td><td>Wipe the Packet Squirrel internal storage and attached USB, and reboot into lockdown mode with transparent bridging only.</td></tr><tr><td><code>SSH_START</code></td><td><a href="/pages/e5QcJh7HPGwGbPEEWPMg">/pages/e5QcJh7HPGwGbPEEWPMg</a></td><td>Launch the SSH server</td></tr><tr><td><code>SSH_STOP</code></td><td><a href="/pages/qedKUZwqeBzeCAQMOQhb">/pages/qedKUZwqeBzeCAQMOQhb</a></td><td>Stop the SSH server</td></tr><tr><td><code>SPOOFDNS</code></td><td><a href="/pages/4bqruKJeS65FgCnwj2aj">/pages/4bqruKJeS65FgCnwj2aj</a></td><td>Overwrite DNS queries</td></tr><tr><td><code>SWITCH</code></td><td><a href="/pages/6l4fnYxBwGdjvUTM1bAD">/pages/6l4fnYxBwGdjvUTM1bAD</a></td><td>Reports the current switch position. <br>(<em>This is NOT necessarily the payload currently running, if the switch was moved after boot!</em>)</td></tr><tr><td><code>UI_START</code></td><td><a href="/pages/v0WlGg7CjJhP2nlAVqmx">/pages/v0WlGg7CjJhP2nlAVqmx</a></td><td>Launch the Packet Squirrel web UI</td></tr><tr><td><code>UI_STOP</code></td><td><a href="/pages/ifDU9a4EH8TdDw2jyqk2">/pages/ifDU9a4EH8TdDw2jyqk2</a></td><td>Stop the Packet Squirrel web UI</td></tr><tr><td><code>USB_FREE</code></td><td><a href="/pages/SaZYpb5ntgDQbxu5b8Vp">/pages/SaZYpb5ntgDQbxu5b8Vp</a></td><td>Return how much USB storage is available, in bytes</td></tr><tr><td><code>USB_STORAGE</code></td><td><a href="/pages/jXz7qxVrnggpPVrY1x0S">/pages/jXz7qxVrnggpPVrY1x0S</a></td><td>Detect if USB storage is present</td></tr><tr><td><code>USB_WAIT</code></td><td><a href="/pages/ZQIWxeN4XqHXbB8iIM0u">/pages/ZQIWxeN4XqHXbB8iIM0u</a></td><td>Wait until USB storage is attached</td></tr></tbody></table>

## A simple payload

As an extremely simple demo of payload capabilities, this payload sets the LED color, waits for a button press, then changes the LED color:

```bash
#!/bin/bash

# Title: Basic demo one
#
# Description: A simple payload that waits for a button to be pressed

# Set the netmode to NAT, otherwise there is no connectivity at all
NETMODE NAT

# Set the LED to blinking cyan
LED C SINGLE

# Wait forever until the button is tapped
BUTTON

# Set the LED to blink blue in a triple pattern
LED B TRIPLE
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.hak5.org/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
