Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize batch processing to prevent arp virus

Shulou Source: shulou.com Published: 2022-06-03 07:51:12 11月15日 Update

This article mainly introduces how to achieve batch processing to prevent arp virus, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

The code is as follows:

@ echo off

:::

Native and gateway IP and MAC address binding batch programs:

:::

Arp-d

Read native Mac address

If exist ipconfig.txt del ipconfig.txt

Ipconfig / all > ipconfig.txt

If exist phyaddr.txt del phyaddr.txt

Find "Physical Address" ipconfig.txt > phyaddr.txt

For / f "skip=2 tokens=12"% M in (phyaddr.txt) do set Mac=%%M

Read native ip address

If exist IPAddr.txt del IPaddr.txt

Find "IP Address" ipconfig.txt > IPAddr.txt

For / f "skip=2 tokens=15"% I in (IPAddr.txt) do set IP=%%I

Bind native IP address and MAC address

Arp-s% IP%% Mac%

Read gateway address

If exist GateIP.txt del GateIP.txt

Find "Default Gateway" ipconfig.txt > GateIP.txt

For / f "skip=2 tokens=13" G in (GateIP.txt) do set GateIP=%%G

: get the gateway MAC address

Ping 192.168.0.1-n 1

Read gateway Mac address

If exist GateMac.txt del GateMac.txt

Arp-a% GateIP% > GateMac.txt

For / f "skip=3 tokens=2"% H in (GateMac.txt) do set GateMac=%%H

Bind gateways Mac and IP

Arp-s% GateIP%% GateMac%

Del GateIP.txt

Del GateMac.txt

Del IPAddr.txt

Del ipconfig.txt

Del phyaddr.txt

Exit

Thank you for reading this article carefully. I hope the article "how to achieve batch processing to prevent arp virus" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Address gateway article native machine virus code value interest at the same time more friends knowledge programs editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Apple vpn macOS