防arp欺骗的批处理(绑定arp)
程序员文章站
2022-04-10 18:54:11
复制代码 代码如下:@echo off arp -d if %~n0==arp exit if %~n0==arp exit if %~n0==arp exit echo...
复制代码 代码如下:
@echo off
arp -d
if %~n0==arp exit
if %~n0==arp exit
if %~n0==arp exit
echo 正在获取本机信息.....
:ip
for /f "skip=13 tokens=15 usebackq " %%i in (`ipconfig /all`) do set ip=%%i && goto mac
:mac
echo ip:%ip%
for /f "skip=13 tokens=12 usebackq " %%i in (`ipconfig /all`) do set mac=%%i && goto gateip
:gateip
echo mac:%mac%
arp -s %ip% %mac%
echo 正在获取网关信息.....
for /f "skip=17 tokens=13 usebackq " %%i in (`ipconfig /all`) do set gateip=%%i && goto gatemac
:gatemac
echo gateip:%gateip%
ping %gateip% -t -n 1
for /f "skip=3 tokens=2 usebackq " %%i in (`arp -a %gateip%`) do set gatemac=%%i && goto start
:start
echo gatemac:%gatemac%
arp -s %gateip% %gatemac%
echo 操作完成!!!
exit
上一篇: 获取文件更新列表 批处理