The original code is as follows. I know there are a lot of things for detecting the local area network now, but I just like to P, and it feels different to use my own things. Hehe (mainly because I can modify and improve it in time):
[ Last edited by zw19750516 on 2008-3-16 at 02:57 PM ]
@echo off&color 9f&setlocal EnableDelayedExpansion
title LAN Quick Detection Tool
echo.
echo.
echo ************************** LAN Quick Detection Tool **************************
echo *----------------------------------------------------------------------*
echo * This tool integrates functions of detecting the local machine's network card, detecting the gateway, and finding all online computers in the LAN. In particular, when there are active ARP trojans in the LAN, it can quickly find out the problematic computers. To prevent errors with dual network cards, this tool also adds the function of users entering IPs by themselves. Please create text documents (.txt) named gateway and use in the folder where the tool is located before using this tool. Enter the IP and MAC address of the LAN gateway in gateway in sequence. Note that there should be no space between the IP and MAC. Enter the IP addresses of all computers in the LAN and the departments or people using them in use in sequence. Enter one group per line and note to add a ":" after the IP. This is to determine the end character of the string when finding the IP (this will not find IPs ending with "*#" and "*$#" when finding IPs ending with "#", such as 1 21 181). *
echo *----------------------------------------------------------------------*
echo * Note: Please temporarily close all applications when detecting the LAN. Many black windows will pop up during the detection, which are running the ping test commands. Just wait for one minute, and all the pop-up windows will close by themselves. *
echo *----------------------------------------------------------------------*
echo ************************************************************************
pause
cls&mode con lines=15
set u=■■■■■■■■■■■■■■■■■■■■■■■■■
set a=0
for /l %%i in (1,1,20) do call :show %%i
cls
echo.&echo.&echo.&echo.
echo The program is initializing...
echo ┌─────────────────────────┐
echo %u%100%%
echo └─────────────────────────┘
ping /n 3 127.1 >nul
if exist l*.txt del l*.txt
if exist mac*.txt del mac*.txt
if exist jiance.txt del jiance.txt
______________________________________________
rem Ping test for the local machine's network card
cls
echo.&echo.&echo.&echo.
set/p lan= Please enter the LAN segment (the input format is 192.168.1., press Enter directly to default to 192.168.1.):
if "%lan%"=="" goto p1
goto p2
:p1
set lan=192.168.1.
:p2
cls
echo.&echo.&echo.&echo.
set/p ip= Please enter the last digit of the local machine's LAN IP address (press Enter directly to default to 255):
if "%ip%"=="" goto p3
ping %lan%%ip% -n 2 >nul
if errorlevel 2 goto wrong1
if errorlevel 1 goto wrong1
goto show1
:p3
ping %lan%255 -n 2 >nul
if errorlevel 2 goto wrong1
if errorlevel 1 goto wrong1
:show1
cls
echo.&echo.&echo.&echo.
echo ====================================
echo ****************************** Network card is unobstructed!*******************************
echo ====================================
ping -n 3 127.1 >nul
______________________________________________
rem Ping test for the gateway
cls&arp -d 2>nul
echo.&echo.&echo.&echo.
set/p pi= Please enter the last digit of the LAN gateway IP address (press Enter directly to default to 1):
if "%pi%"=="" goto p4
ping %lan%%pi% -n 2 >nul
if errorlevel 2 goto wrong2
if errorlevel 1 goto wrong2
goto select1
:p4
ping %lan%1 -n 2 >nul
if errorlevel 2 goto wrong2
if errorlevel 1 goto wrong2
goto select1
______________________________________________
rem Ping test for the LAN to find all online computers
:ping
echo. >lb.txt
echo. >>lb.txt
echo ==================================== >>lb.txt
echo ************************ The following computers in the LAN are online! ************************ >>lb.txt
echo ==================================== >>lb.txt
for /l %%i in (0,1,255) do start ping -n 1 %lan%%%i
for /f "skip=3 tokens=*" %%k in ('arp -a') do echo %%k >>mac.txt
for /f "tokens=1" %%j in ('findstr /c:"dynamic" mac.txt') do (
findstr /c:"%%j:" use.txt >>lb.txt
)
cls&mode con lines=30&type lb.txt | more
pause
______________________________________________
rem Detect if there is ARP spoofing in the LAN
cls&fc gateway.txt jiance.txt
if errorlevel 2 goto find
if errorlevel 1 goto find
goto show2
______________________________________________
rem Find the computers infected with the trojan
:find
cls
echo. >ld.txt
echo. >>ld.txt
echo ==================================== >>ld.txt
echo ********************* The above computers in the LAN are infected with ARP trojans!********************* >>ld.txt
echo ==================================== >>ld.txt
for /f "skip=3 tokens=2" %%i in (la.txt) do findstr /c:"%%i" mac.txt >>lc.txt
for /f "tokens=1" %%i in (lc.txt) do findstr /c:"%%i:" use.txt >>ld.txt
type ld.txt | more
pause
______________________________________________
:end
cls&mode con lines=15
echo.&echo.&echo.&echo.
echo ====================================
echo ************************* Detection completed, press any key to exit!**************************
echo ====================================
pause >nul
del l*.txt jiance.txt mac*.txt&goto :eof
:show2
cls&mode con lines=15
echo.&echo.&echo.&echo.
echo ====================================
echo ***************** After detection, there is no ARP spoofing in the LAN, and the network is secure! ******************
echo ====================================
pause
goto end
:select1
cls
echo.&echo.&echo.&echo.
echo ====================================
echo ***************************** Gateway is unobstructed!********************************
echo ====================================
ping -n 2 127.1 >nul&arp -a >la.txt
cls&for /f "skip=3 tokens=1,2" %%i in ('arp -a') do echo %%i%%j >>jiance.txt
:select2
cls
echo.&echo.&echo.&echo.
set/p select2= Do you want to ping test the LAN? (1. Ping test 2. Do not ping test)
if "%select2%"=="1" goto ping
if "%select2%"=="2" goto end
cls
echo.&echo.&echo.&echo.
echo ====================================
echo ***************************** Incorrect input!********************************
echo ====================================
ping -n 2 127.1 >nul&goto select2
:wrong1
cls
echo.&echo.&echo.&echo.
echo ====================================
echo ************************** Network card is not unobstructed, unable to detect!*************************
echo ====================================
ping -n 3 127.1 >nul&goto :eof
:wrong2
cls
echo.&echo.&echo.&echo.
echo ====================================
echo ************************** Network is not unobstructed, unable to detect!*************************
echo ====================================
ping -n 3 127.1 >nul&goto :eof
:show
cls
set /a a+=4
echo.&echo.&echo.&echo.
echo The program is initializing...
echo ┌─────────────────────────┐
echo !u:~,%1!%a%%%&ping /n 1 127.1 >nul
echo └─────────────────────────┘
goto :eof[ Last edited by zw19750516 on 2008-3-16 at 02:57 PM ]
