隨機修改MAC地址批處理


@echo off 
mode con cols=70 lines=20 
title MAC隨機修改工具 
color 3F 
setlocal enabledelayedexpansion 
:start 
cls 
echo                           MAC隨機修改工具 
echo         ---------------------------------------------------- 
echo         本地網卡: 
ipconfig /all|find "Description">%temp%\des.txt 
devcon find pci\*>%temp%\pci.txt 
call :getPCI 1 
call :getMAC 1 
echo         !pci! 
echo         Physical Address:%MAC% 
echo         ---------------------------------------------------- 
 
if "1"=="1" ( 
    call :setMAC 
    
    call :getPCI 2 
    echo         MAC隨機修改成功 
goto end 
    pause 
)  
goto start 
:setMAC 
if not exist MAC.txt ( 
    echo         沒有找到存儲MAC的文件MAC.txt,請在該程序目錄下建立 
    echo         MAC.txt並存儲MAC地址,每一個地址占一行!!! 
    pause>nul 
    goto start 
 
set /a var=0 
for /f %%i in (MAC.txt) do set /a var=!var!+1 
set /a var=!random!%%!var!+1 
set /a tmp=0 
for /f "tokens=1,2 delims= " %%i in (MAC.txt) do ( 
    set /a tmp=!tmp!+1 
    if !tmp!==!var! ( 
        set MAC=%%i 
 
 
 
 
 
 
echo %%i %%j
pause
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001" /v NetworkAddress /d %%i /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007" /v NetworkAddress /d %%i /f
 
netsh interface ip delete dns "本地連接" addr=all
netsh interface ip add dns "本地連接" addr=192.168.116.2
netsh interface ip add address "本地連接" 192.168.116.%%j 255.255.255.0
netsh interface ip add address "本地連接" gateway=192.168.116.2 gwmetric=2
 
goto :eof 
       
   ) 
 
 
goto :eof 
:getPCI 
for /f "tokens=2 delims=:" %%i in (%temp%\des.txt) do ( 
    for /f "tokens=2 delims=&" %%j in ('type "%temp%\pci.txt"^|find "%%i"') do (    
        if %1==1 ( 
            set pci=%%i 
            set pci=!pci:~1,-1! 
            goto :eof 
        ) 
        if %1==2 ( 
            echo         正在禁用網卡... 
            devcon disable *%%j*>nul 
            echo         正在啟用網卡... 
            devcon enable *%%j*>nul 
        ) 
    ) 
goto :eof 
:end 
if exist %temp%\des.txt del %temp%\des.txt 
if exist %temp%\pci.txt del %temp%\pci.txt


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM