防arp欺骗的批处理 自动绑定网关的批处理
(编辑:jimmy 日期: 2024/12/24 浏览:3 次 )
将下面的代码。保存为doarp.bat添加到自动运行即可。
复制代码 代码如下:
@echo OFF
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 IP:%GateIP%
FOR /f "skip=3 tokens=2 usebackq " %%i in (`arp -a %GateIP%`) do Set GateMAC=%%i && GOTO Start
:Start
echo MAC:%GateMAC%
arp -d
arp -s %GateIP% %GateMAC%
echo 操作完成!!!
exit
下面附上详细的说明:
这段脚本是 反ARP攻击,手工添加本机ip、mac和网关ip、mac的程序
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%
//如上面提示的,获取本机IP和mac. 其中arp -s %IP% %MAC% 为将本机ip/mac加入本机ip/mac对应表.
echo 正在获取网关信息.....
FOR /f "skip=17 tokens=13 usebackq " %%i in (`ipconfig /all`) do Set GateIP=%%i && GOTO GateMac
:GateMac
echo IP:%GateIP%
FOR /f "skip=3 tokens=2 usebackq " %%i in (`arp -a %GateIP%`) do Set GateMAC=%%i && GOTO Start
:Start
echo MAC:%GateMAC%
arp -d
arp -s %GateIP% %GateMAC%
//这段是获取网关的ip/mac地址,其中arp -s %GateIP% %GateMAC% 是将网关的ip和mac加载到本机对应表.
复制代码 代码如下:
@echo OFF
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 IP:%GateIP%
FOR /f "skip=3 tokens=2 usebackq " %%i in (`arp -a %GateIP%`) do Set GateMAC=%%i && GOTO Start
:Start
echo MAC:%GateMAC%
arp -d
arp -s %GateIP% %GateMAC%
echo 操作完成!!!
exit
下面附上详细的说明:
这段脚本是 反ARP攻击,手工添加本机ip、mac和网关ip、mac的程序
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%
//如上面提示的,获取本机IP和mac. 其中arp -s %IP% %MAC% 为将本机ip/mac加入本机ip/mac对应表.
echo 正在获取网关信息.....
FOR /f "skip=17 tokens=13 usebackq " %%i in (`ipconfig /all`) do Set GateIP=%%i && GOTO GateMac
:GateMac
echo IP:%GateIP%
FOR /f "skip=3 tokens=2 usebackq " %%i in (`arp -a %GateIP%`) do Set GateMAC=%%i && GOTO Start
:Start
echo MAC:%GateMAC%
arp -d
arp -s %GateIP% %GateMAC%
//这段是获取网关的ip/mac地址,其中arp -s %GateIP% %GateMAC% 是将网关的ip和mac加载到本机对应表.
下一篇:批处理中的预处理实现代码