> 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/troubleshooting/troubleshooting-payloads.md).

# Troubleshooting payloads

When developing a payload (or deploying a new payload which may require configuration or tweaking), it can sometimes be difficult to identify the reason it is not activating as expected.

There are several ways to debug a payload:

### Running payloads in Arming & Configuration mode

Payloads can often be run interactively in Arming & Configuration mode via the web UI terminal, or via a SSH connection.

To run a payload interactively from a terminal, simply launch the payload script via `bash`:

```bash
root@squirrel:~# /bin/bash /root/payloads/switch1/payload
```

This method is the simplest when your payload does not require an offline mode - remember, if you change the `NETMODE` in your payload, you may lose network access to the Packet Squirrel!

While debugging, you may be able to comment out the `NETMODE` line in a payload.  Remember to restore it when you're done!

### Enabling SSH and the web UI in a payload

SSH and the web UI can be enabled in any payload mode where the Packet Squirrel has a network connection (`NAT`, `BRIDGE`, and `JAIL`) with the commands `START_SSH` and `START_UI`.  Once SSH or the web UI has been started, you can connect to your Packet Squirrel and examine the state or re-run the payload.

### Logging commands to a file

The output of commands can be sent to a file (see the chapter on [Redirecting output ](/packet-squirrel-mark-ii/advanced-payloads/redirecting-output.md)for more information).  This can help diagnose errors in a payload that can not be debugged interactively.

Remember that files in `/tmp` are not preserved over a reboot - but you can log to `/root/`, for example:

```bash
mkdir -p /root/payload_logs

command1 2>&1 >> /root/payload_logs/payload_debug.txt
command2 2>&1 >> /root/payload_logs/payload_debug.txt
```

{% hint style="info" %}
Remember to use `>>` to add to the end of the log file instead of replacing it!
{% endhint %}


---

# 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/troubleshooting/troubleshooting-payloads.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.
