How to implement batch processing to prevent arp spoofing and automatically bind gateways
This article is about how to implement batch processing to prevent arp spoofing and automatically bind gateways. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Put the following code. Save as doarp.bat and add to autorun.
The code is as follows:
@ echo OFF
If% ~ n0==arp exit
If% ~ n0==Arp exit
If% ~ n0==ARP exit
Echo is getting native 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%
Echo operation completed!
Exit
A detailed description is attached below:
This script is an anti-ARP attack. Add native ip, mac and gateway ip and mac programs manually
If% ~ n0==arp exit
If% ~ n0==Arp exit
If% ~ n0==ARP exit / / decide to quit if it has been infected
Echo is getting native 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 prompted above, get native IP and mac. Arp-s% IP%% MAC% adds native ip/mac to the corresponding table of 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 is the ip/mac address of the gateway, where arp-s% GateIP%% GateMAC% loads the ip and mac of the gateway into the local corresponding table.
Thank you for reading! On "how to achieve anti-arp spoofing and automatic binding gateway batch processing" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!