SoFunction
Updated on 2025-04-08

Batch processing that prevents arp spoofing Automatically binds the gateway batch processing

Put the following code. Save as added to auto-run.
Copy the codeThe code is as follows:

@echo OFF
if %~n0==arp exit
if %~n0==Arp exit
if %~n0==ARP exit
echo is getting local information...
: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 is getting gateway information...
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%
The echo operation is completed!!!
exit

Detailed instructions are attached below:
This script is an anti-ARP attack, manually adding native IP, mac, gateway IP, and mac programs

if %~n0==arp exit
if %~n0==Arp exit
if %~n0==ARP exit //Judge if it has been infected and exit

echo is getting local information...
: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%
//As mentioned above, get the native IP and mac. where arp -s %IP% %MAC% is to add the native IP/mac to the corresponding table of the native IP/mac.

echo is getting gateway information...
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%
//This section is to obtain the ip/mac address of the gateway, where arp -s %GateIP% %GateMAC% loads the ip and mac of the gateway to the corresponding table of the local machine.