Shell

(告诉你什么才是Shell编程一)Shell防范ARP攻击

2019-08-08  本文已影响0人  我是李小胖
#!/bin/bash
declare gw=`route -n | grep -e '^0.0.0.0'`
declare gwname=`echo $gw | grep -oe '\w*$'`
declare gwip=`echo $gw | grep -oe '[0-9]\{2,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'`
declare gwmac=`arp -n | grep -e $gwip | grep -oe '[0-9A-F]\{2\}:[0-9A-F]\{2\}:[0-9A-F]\{2\}:[0-9A-
F]\{2\}:[0-9A-F]\{2\}:[0-9A-F]\{2\}'`
echo "switch $gwname arp: $gwip - $gwmac to static"
arp -s $gwip $gwmac
echo "done, off arp reuqest .."
ifconfig $gwname -arp
echo "all done."
上一篇下一篇

猜你喜欢

热点阅读