> 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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/button.md">BUTTON</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/c2exfil.md">C2EXFIL</a></td><td>Send a file via Cloud C²</td></tr><tr><td><code>C2NOTIFY</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/c2notify.md">C2NOTIFY</a></td><td>Send a notification via Cloud C²</td></tr><tr><td><code>C2WATCHDIR</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/c2watchdir.md">C2WATCHDIR</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/dynamicproxy.md">DYNAMICPROXY</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/killport.md">KILLPORT</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/killstream.md">KILLSTREAM</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/led.md">LED</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/matchport.md">MATCHPORT</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/matchstream.md">MATCHSTREAM</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/netmode.md">NETMODE</a></td><td>Set the <a href="/packet-squirrel-mark-ii/getting-started/networking-and-modes.md">network mode</a> of the Packet Squirrel.</td></tr><tr><td><code>SELFDESTRUCT</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/selfdestruct.md">SELFDESTRUCT</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/ssh_start.md">SSH_START</a></td><td>Launch the SSH server</td></tr><tr><td><code>SSH_STOP</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/ssh_stop.md">SSH_STOP</a></td><td>Stop the SSH server</td></tr><tr><td><code>SPOOFDNS</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/spoofdns.md">SPOOFDNS</a></td><td>Overwrite DNS queries</td></tr><tr><td><code>SWITCH</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/switch.md">SWITCH</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="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/ui_start.md">UI_START</a></td><td>Launch the Packet Squirrel web UI</td></tr><tr><td><code>UI_STOP</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/ui_stop.md">UI_STOP</a></td><td>Stop the Packet Squirrel web UI</td></tr><tr><td><code>USB_FREE</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/usb_free.md">USB_FREE</a></td><td>Return how much USB storage is available, in bytes</td></tr><tr><td><code>USB_STORAGE</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/usb_storage.md">USB_STORAGE</a></td><td>Detect if USB storage is present</td></tr><tr><td><code>USB_WAIT</code></td><td><a href="/packet-squirrel-mark-ii/payload-development/duckyscript-for-packet-squirrel/usb_wait.md">USB_WAIT</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
```
