Sinisterly
[HC Official] MAC Spoofer 2.0 - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Hacking (https://sinister.ly/Forum-Hacking)
+--- Forum: Hacking Tools (https://sinister.ly/Forum-Hacking-Tools)
+--- Thread: [HC Official] MAC Spoofer 2.0 (/Thread-HC-Official-MAC-Spoofer-2-0)

Pages: 1 2 3 4


[HC Official] MAC Spoofer 2.0 - noize - 05-17-2013

Windows MAC address spoofer
You can find the old version here: 1.0/1.1.

Latest version: 2.1

Change-log:
- ping option (host inside or outside the LAN with IP address or host name (e.g: - www.google.com | noizepc | 127.0.0.1));
- install/uninstall (after installation you can call macspoofer from any script or directory path (shell)).

Source code

Code:
@echo off pushd %~dp0 ::::::::::::::::::::::::: :: Mac Address Spoofer :: ::::::::::::::::::::::::: echo. echo ########################################################################## echo # Noize's Mac Address Spoofer # echo # v2.1 # echo # # echo # Coded by Noize at HackCommunity.com # echo ########################################################################## echo. set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1 echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -p [HOST] ^| -s [KEY] ^| -r [KEY]] echo [-c [CON]] [-n [MAC]] [-v] echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo [IP] Internal IP address to get associated MAC address of echo -p Ping an host with the host name or IP address echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo -c Specify your connection name in order to automatically restart the NIC echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo [MAC]MAC address you want to assume (only with -s) echo -v Verbose mode goto end :arg1 if /i "%arg1%"=="-h" goto help if /i "%arg1%"=="-d" goto ipconfig if /i "%arg1%"=="-a" goto mac if /i "%arg1%"=="-l" goto arp if /i "%arg1%"=="-m" goto assoc if /i "%arg1%"=="-p" goto ping if /i "%arg1%"=="-s" goto spoof if /i "%arg1%"=="-r" goto unspoof if /i "%arg1%"=="--install" goto install if /i "%arg1%"=="--uninst" goto uninst :err echo Syntax error^! goto end :help echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -p [HOST] ^| -s [KEY] ^| -r [KEY]] echo [-c [CON]] [-n [MAC]] [-v] echo [--install [-ow ^| --overwrite] ^| --uninst] echo. echo If no arguments are specified, a brief help message is shown echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo. echo [IP] Internal IP address to get associated MAC address of echo. echo -p Ping an host with the host name or IP address echo. echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo. echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo It should be an identifying word (it might be the whole name too) echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can also create a file called "keyword.txt" in the current directory echo to have macspoofer use its content as default keyword echo You might still specify [KEY] to use a different key from the default one echo -c Specify your connection name in order to automatically restart the NIC echo (Please, note your connection name does not mean your NIC's name) echo If you do not specify it, you will need to restart your NIC manually to echo see any changes in your MAC address echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can make a file called "con.txt" in the current directory to use its echo content as default connection name echo. echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo. echo -n Specify a new MAC address to assume (only with -s) echo. echo [MAC]MAC address you want to assume echo If -n is omitted the MAC address used is 001122334455 echo Please, note that if you enter an invalid MAC address spoofing will fail echo Allowed formats are: echo 001122334455 echo 00:00:00:00:00:00 echo 80-03-10-20-50-10 echo. echo -v Verbose mode echo. echo --install Install macspoofer in the System32 directory. echo. echo After installation, you'll be able to run macspoofer from any path or echo script. An example of a Batch script of yours in whatever directory. echo. echo @echo off echo echo Hello, world! echo echo This is macspoofer's usage: echo echo. ^& macspoofer -h echo echo. ^& echo And this is a ping to localhost: echo macspoofer -p localhost echo exit /b echo. echo Note: you need administrator privileges to install macspoofer. echo. echo -ow, --overwrite Overwrites already existing versions of macspoofer in the echo System32 directory during installation. echo If omitted and there is an already existing copy while echo using "--install" user is asked if he wants to overwrite. echo. echo --uninst Remove macspoofer from the System32 directory. goto end :ipconfig set ipconf=ipconfig if /i "%2"=="-v" set ipconf=ipconfig /all %ipconf% goto end :mac < nul set /p var=Please, wait... set getmac=getmac if /i "%2"=="-v" set getmac=getmac -v %getmac% goto end :arp set arp=arp -a if /i "%2"=="-v" set arp=arp -a -v %arp% goto end :assoc set check= set check=%2 if not defined check goto noize for %%a in (1 2 3 4 5 6 7 8 9 0) do if "%check:~0,1%"=="%%a" goto skipassoc :noize echo Invalid IP address. goto end :skipassoc arp -a %2 goto end :ping set check=%2 if not defined check ( echo No host to ping specified. goto end ) set check= for /f %%k in ('ping %2 ^| find /i "ms"') do set check=%%k if not defined check ( echo Target: %2. echo Ping failed. echo. echo Host is unreachable. goto end ) echo Target: %2. echo Ping successful. echo. echo Host is reachable. goto end :install if exist %windir%\System32\macspoofer.bat goto is_inst copy "%~f0" %windir%\System32\macspoofer.bat 2>nul > nul if not exist %windir%\System32\macspoofer.bat ( echo Failed to install macspoofer. echo Run again the program with administrator privileges. goto end ) echo macspoofer was successfully installed. goto end :is_inst if /i "%2"=="-ow" goto overwrite if /i "%2"=="--overwrite" goto overwrite echo macspoofer is already installed. set overw= set /p overw="Do you want to overwrite the already existing version? (Y/n) " echo. if /i "%overw%"=="n" echo No changes brought. & goto end :overwrite del %windir%\System32\macspoofer.bat /f /q 2>nul > nul if exist %windir%\System32\macspoofer.bat ( echo Failed to update macspoofer. echo Run the program again with administrator privileges. goto end ) copy "%~f0" %windir%\System32\macspoofer.bat 2>nul > nul if not exist %windir%\System32\macspoofer.bat ( echo Failed to update macspoofer: unknown error. echo Latest copy of macspoofer in System32 was deleted during update. echo. echo Please, try again. goto end ) echo macspoofer was successfully updated. goto end :uninst if not exist %windir%\System32\macspoofer.bat ( echo macspoofer is not installed on this computer. goto end ) del %windir%\System32\macspoofer.bat /f /q 2>nul > nul if exist %windir%\System32\macspoofer.bat ( echo Failed to uninstall macspoofer. echo Run the program again with administrator privileges. goto end ) echo macspoofer was successfully uninstalled. goto end :spoof set newmac= if /i "%2"=="-n" set newmac=%3 if /i "%3"=="-n" set newmac=%4 if /i "%4"=="-n" set newmac=%5 if /i "%5"=="-n" set newmac=%6 if /i "%6"=="-n" set newmac=%7 if not defined newmac ( set newmac=001122334455 ) else ( set newmac=%newmac::-=% ) set keyword= set keycheck=%2 if exist keyword.txt for /f "delims=" %%j in ('type keyword.txt') do set keyword=%%j if defined keycheck set keyword=%keycheck% if defined keyword goto skip set /p keyword="Enter a keyword that is part of your NIC's name only: " :skip echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop goto keyloop :quitloop reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /d "%newmac%" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 if not defined con echo Your MAC address was successfully changed. & echo You'll need to manually restart your NIC to see any changes. & goto end ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh1 netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto done1 :skipnetsh1 if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto done1 :spooffailed echo. echo Failed to change your MAC address. echo Run the program again with administrator privileges. goto end :unspoof set keyword=%2 if defined keyword goto isdef :looper set /p keyword="Enter a keyword that is part of your NIC's name: " echo. if not defined key goto looper :isdef echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop2 set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop2 goto keyloop2 :quitloop2 reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" 2>nul > nul if not "%errorlevel%"=="0" echo. & echo This NIC's MAC address has not been spoofed yet. & echo Restore failed. & goto end set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed if not defined con goto skipnic1 ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto skipnic :skipnetsh if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto skipnic :skipnic1 echo MAC and local IP addresses were successfully restored. echo You will need to manually restart your NIC before you can see any changes. goto end :done1 echo MAC was successfully changed. goto end :skipnic echo MAC and local IP addresses were successfully restored. :end popd

Download



Version 2.0

Features and change-log:
- arguments based;
- view detailed local IP and MAC information for current host;
- view MAC and IP addresses of other hosts in the LAN;
- find the MAC address of any host in the LAN from its IP;
- spoof MAC and local IP addresses;
- restore MAC and local IP addresses;
- automatical NIC restart with given connection name for (hopefully) XP and newer versions;
- possibility to set a default NIC for spoofing/restoring and a default connection name to avoid typing them every time (though, if they are specified in the command, default option gets overridden by the specified one);
- it's been coded by noize (probably the most noteworthy feature).

Source code

Code:
@echo off cd %~dp0 ::::::::::::::::::::::::: :: Mac Address Spoofer :: ::::::::::::::::::::::::: echo. echo ########################################################################## echo # Noize's Mac Address Spoofer # echo # v2.0 # echo # # echo # Coded by Noize at HackCommunity.com # echo ########################################################################## echo. set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1 echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -s [KEY] ^| -r [KEY]] [-c [CON]] echo [-n [MAC]] [-v] echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo [IP] Internal IP address to get associated MAC address of echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo -c Specify your connection name in order to automatically restart the NIC echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo [MAC]MAC address you want to assume (only with -s) echo -v Verbose mode goto end :arg1 if /i "%arg1%"=="-h" goto help if /i "%arg1%"=="-d" goto ipconfig if /i "%arg1%"=="-a" goto mac if /i "%arg1%"=="-l" goto arp if /i "%arg1%"=="-m" goto assoc if /i "%arg1%"=="-s" goto spoof if /i "%arg1%"=="-r" goto unspoof :err echo Syntax error^! goto end :help echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -s [KEY] ^| -r [KEY]] [-c [CON]] echo [-n [MAC]] [-v] echo. echo If no arguments are specified, a brief help message is shown echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo. echo [IP] Internal IP address to get associated MAC address of echo. echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo. echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo It should be an identifying word (it might be the whole name too) echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can also create a file called "keyword.txt" in the current directory echo to have macspoofer use its content as default keyword echo You might still specify [KEY] to use a different key from the default one echo -c Specify your connection name in order to automatically restart the NIC echo (Please, note your connection name does not mean your NIC's name) echo If you do not specify it, you will need to restart your NIC manually to echo see any changes in your MAC address echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can make a file called "con.txt" in the current directory to use its echo content as default connection name echo. echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo. echo -n Specify a new MAC address to assume (only with -s) echo. echo [MAC]MAC address you want to assume echo If -n is omitted the MAC address used is 001122334455 echo Please, note that if you enter an invalid MAC address spoofing will fail echo Allowed formats are 001122334455 and 00:00:00:00:00:00 (12 digits) echo. echo -v Verbose mode goto end :ipconfig set ipconf=ipconfig if /i "%2"=="-v" set ipconf=ipconfig /all %ipconf% goto end :mac < nul set /p var=Please, wait... set getmac=getmac if /i "%2"=="-v" set getmac=getmac -v %getmac% goto end :arp set arp=arp -a if /i "%2"=="-v" set arp=arp -a -v %arp% goto end :assoc set check= set check=%2 if not defined check goto noize for %%a in (1 2 3 4 5 6 7 8 9 0) do if "%check:~0,1%"=="%%a" goto skipassoc :noize echo Invalid IP address. goto end :skipassoc arp -a %2 goto end :spoof set newmac= if /i "%2"=="-n" set newmac=%3 if /i "%3"=="-n" set newmac=%4 if /i "%4"=="-n" set newmac=%5 if /i "%5"=="-n" set newmac=%6 if /i "%6"=="-n" set newmac=%7 if not defined newmac ( set newmac=001122334455 ) else ( set newmac=%newmac::=% ) set keyword= set keycheck=%2 if exist keyword.txt for /f "delims=" %%j in ('type keyword.txt') do set keyword=%%j if defined keycheck set keyword=%keycheck% if defined keyword goto skip set /p keyword="Enter a keyword that is part of your NIC's name only: " :skip echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop goto keyloop :quitloop reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /d "%newmac%" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 if not defined con echo Your MAC address was successfully changed. & echo You'll need to manually restart your NIC to see any changes. & goto end ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh1 netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto done1 :skipnetsh1 if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto done1 :spooffailed echo. echo Failed to change your MAC address. echo Run the program again with administrator privileges. goto end :unspoof set keyword=%2 if defined keyword goto isdef :looper set /p keyword="Enter a keyword that is part of your NIC's name: " echo. if not defined key goto looper :isdef echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop2 set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop2 goto keyloop2 :quitloop2 reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" 2>nul > nul if not "%errorlevel%"=="0" echo. & echo This NIC's MAC address has not been spoofed yet. & echo Restore failed. & goto end set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed if not defined con goto skipnic1 ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto skipnic :skipnetsh if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto skipnic :skipnic1 echo MAC and local IP addresses were successfully restored. echo You will need to manually restart your NIC before you can see any changes. goto end :done1 echo MAC was successfully changed. goto end :skipnic echo MAC and local IP addresses were successfully restored. :end

Save the code as macspoofer.bat so that you can use the usage:

Code:
macspoofer [OPTIONS]

Main screen (cmd /k macspoofer):

Code:
. ########################################################################## # Noize's Mac Address Spoofer # # v2.0 # # # # Coded by Noize at HackCommunity.com # ########################################################################## macspoofer [-h | -d | -a | -l | -m [IP] | -s [KEY] | -r [KEY]] [-c [CON]] [-n [MAC]] [-v] -h Show an extended help message -d View detailed IP and MAC information for current host -a View all MAC addresses for current host -l View other MAC and IP addresses on the LAN -m Get MAC address for given local IP (you can't use your own IP) [IP] Internal IP address to get associated MAC address of -s Spoof current MAC and local IP addresses -r Restore original MAC and IP addresses [KEY]Keyword that is part of the NIC's name you want to spoof or restore -c Specify your connection name in order to automatically restart the NIC [CON]Connection name (e.g: Connection to local area network (LAN)) [MAC]MAC address you want to assume (only with -s) -v Verbose mode

This is an open-source free project and you are allowed to re-use the code, edit the code and give away for free the code as long as you give credits.

Any feedback or (especially) bug report is highly appreciated.



Todo list:
- change MAC address of other hosts in the LAN remotely.



[HC Official] MAC Spoofer 2.0 - noize - 05-17-2013

Windows MAC address spoofer
You can find the old version here: 1.0/1.1.

Latest version: 2.1

Change-log:
- ping option (host inside or outside the LAN with IP address or host name (e.g: - www.google.com | noizepc | 127.0.0.1));
- install/uninstall (after installation you can call macspoofer from any script or directory path (shell)).

Source code

Code:
@echo off pushd %~dp0 ::::::::::::::::::::::::: :: Mac Address Spoofer :: ::::::::::::::::::::::::: echo. echo ########################################################################## echo # Noize's Mac Address Spoofer # echo # v2.1 # echo # # echo # Coded by Noize at HackCommunity.com # echo ########################################################################## echo. set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1 echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -p [HOST] ^| -s [KEY] ^| -r [KEY]] echo [-c [CON]] [-n [MAC]] [-v] echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo [IP] Internal IP address to get associated MAC address of echo -p Ping an host with the host name or IP address echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo -c Specify your connection name in order to automatically restart the NIC echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo [MAC]MAC address you want to assume (only with -s) echo -v Verbose mode goto end :arg1 if /i "%arg1%"=="-h" goto help if /i "%arg1%"=="-d" goto ipconfig if /i "%arg1%"=="-a" goto mac if /i "%arg1%"=="-l" goto arp if /i "%arg1%"=="-m" goto assoc if /i "%arg1%"=="-p" goto ping if /i "%arg1%"=="-s" goto spoof if /i "%arg1%"=="-r" goto unspoof if /i "%arg1%"=="--install" goto install if /i "%arg1%"=="--uninst" goto uninst :err echo Syntax error^! goto end :help echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -p [HOST] ^| -s [KEY] ^| -r [KEY]] echo [-c [CON]] [-n [MAC]] [-v] echo [--install [-ow ^| --overwrite] ^| --uninst] echo. echo If no arguments are specified, a brief help message is shown echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo. echo [IP] Internal IP address to get associated MAC address of echo. echo -p Ping an host with the host name or IP address echo. echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo. echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo It should be an identifying word (it might be the whole name too) echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can also create a file called "keyword.txt" in the current directory echo to have macspoofer use its content as default keyword echo You might still specify [KEY] to use a different key from the default one echo -c Specify your connection name in order to automatically restart the NIC echo (Please, note your connection name does not mean your NIC's name) echo If you do not specify it, you will need to restart your NIC manually to echo see any changes in your MAC address echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can make a file called "con.txt" in the current directory to use its echo content as default connection name echo. echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo. echo -n Specify a new MAC address to assume (only with -s) echo. echo [MAC]MAC address you want to assume echo If -n is omitted the MAC address used is 001122334455 echo Please, note that if you enter an invalid MAC address spoofing will fail echo Allowed formats are: echo 001122334455 echo 00:00:00:00:00:00 echo 80-03-10-20-50-10 echo. echo -v Verbose mode echo. echo --install Install macspoofer in the System32 directory. echo. echo After installation, you'll be able to run macspoofer from any path or echo script. An example of a Batch script of yours in whatever directory. echo. echo @echo off echo echo Hello, world! echo echo This is macspoofer's usage: echo echo. ^& macspoofer -h echo echo. ^& echo And this is a ping to localhost: echo macspoofer -p localhost echo exit /b echo. echo Note: you need administrator privileges to install macspoofer. echo. echo -ow, --overwrite Overwrites already existing versions of macspoofer in the echo System32 directory during installation. echo If omitted and there is an already existing copy while echo using "--install" user is asked if he wants to overwrite. echo. echo --uninst Remove macspoofer from the System32 directory. goto end :ipconfig set ipconf=ipconfig if /i "%2"=="-v" set ipconf=ipconfig /all %ipconf% goto end :mac < nul set /p var=Please, wait... set getmac=getmac if /i "%2"=="-v" set getmac=getmac -v %getmac% goto end :arp set arp=arp -a if /i "%2"=="-v" set arp=arp -a -v %arp% goto end :assoc set check= set check=%2 if not defined check goto noize for %%a in (1 2 3 4 5 6 7 8 9 0) do if "%check:~0,1%"=="%%a" goto skipassoc :noize echo Invalid IP address. goto end :skipassoc arp -a %2 goto end :ping set check=%2 if not defined check ( echo No host to ping specified. goto end ) set check= for /f %%k in ('ping %2 ^| find /i "ms"') do set check=%%k if not defined check ( echo Target: %2. echo Ping failed. echo. echo Host is unreachable. goto end ) echo Target: %2. echo Ping successful. echo. echo Host is reachable. goto end :install if exist %windir%\System32\macspoofer.bat goto is_inst copy "%~f0" %windir%\System32\macspoofer.bat 2>nul > nul if not exist %windir%\System32\macspoofer.bat ( echo Failed to install macspoofer. echo Run again the program with administrator privileges. goto end ) echo macspoofer was successfully installed. goto end :is_inst if /i "%2"=="-ow" goto overwrite if /i "%2"=="--overwrite" goto overwrite echo macspoofer is already installed. set overw= set /p overw="Do you want to overwrite the already existing version? (Y/n) " echo. if /i "%overw%"=="n" echo No changes brought. & goto end :overwrite del %windir%\System32\macspoofer.bat /f /q 2>nul > nul if exist %windir%\System32\macspoofer.bat ( echo Failed to update macspoofer. echo Run the program again with administrator privileges. goto end ) copy "%~f0" %windir%\System32\macspoofer.bat 2>nul > nul if not exist %windir%\System32\macspoofer.bat ( echo Failed to update macspoofer: unknown error. echo Latest copy of macspoofer in System32 was deleted during update. echo. echo Please, try again. goto end ) echo macspoofer was successfully updated. goto end :uninst if not exist %windir%\System32\macspoofer.bat ( echo macspoofer is not installed on this computer. goto end ) del %windir%\System32\macspoofer.bat /f /q 2>nul > nul if exist %windir%\System32\macspoofer.bat ( echo Failed to uninstall macspoofer. echo Run the program again with administrator privileges. goto end ) echo macspoofer was successfully uninstalled. goto end :spoof set newmac= if /i "%2"=="-n" set newmac=%3 if /i "%3"=="-n" set newmac=%4 if /i "%4"=="-n" set newmac=%5 if /i "%5"=="-n" set newmac=%6 if /i "%6"=="-n" set newmac=%7 if not defined newmac ( set newmac=001122334455 ) else ( set newmac=%newmac::-=% ) set keyword= set keycheck=%2 if exist keyword.txt for /f "delims=" %%j in ('type keyword.txt') do set keyword=%%j if defined keycheck set keyword=%keycheck% if defined keyword goto skip set /p keyword="Enter a keyword that is part of your NIC's name only: " :skip echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop goto keyloop :quitloop reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /d "%newmac%" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 if not defined con echo Your MAC address was successfully changed. & echo You'll need to manually restart your NIC to see any changes. & goto end ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh1 netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto done1 :skipnetsh1 if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto done1 :spooffailed echo. echo Failed to change your MAC address. echo Run the program again with administrator privileges. goto end :unspoof set keyword=%2 if defined keyword goto isdef :looper set /p keyword="Enter a keyword that is part of your NIC's name: " echo. if not defined key goto looper :isdef echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop2 set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop2 goto keyloop2 :quitloop2 reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" 2>nul > nul if not "%errorlevel%"=="0" echo. & echo This NIC's MAC address has not been spoofed yet. & echo Restore failed. & goto end set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed if not defined con goto skipnic1 ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto skipnic :skipnetsh if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto skipnic :skipnic1 echo MAC and local IP addresses were successfully restored. echo You will need to manually restart your NIC before you can see any changes. goto end :done1 echo MAC was successfully changed. goto end :skipnic echo MAC and local IP addresses were successfully restored. :end popd

Download



Version 2.0

Features and change-log:
- arguments based;
- view detailed local IP and MAC information for current host;
- view MAC and IP addresses of other hosts in the LAN;
- find the MAC address of any host in the LAN from its IP;
- spoof MAC and local IP addresses;
- restore MAC and local IP addresses;
- automatical NIC restart with given connection name for (hopefully) XP and newer versions;
- possibility to set a default NIC for spoofing/restoring and a default connection name to avoid typing them every time (though, if they are specified in the command, default option gets overridden by the specified one);
- it's been coded by noize (probably the most noteworthy feature).

Source code

Code:
@echo off cd %~dp0 ::::::::::::::::::::::::: :: Mac Address Spoofer :: ::::::::::::::::::::::::: echo. echo ########################################################################## echo # Noize's Mac Address Spoofer # echo # v2.0 # echo # # echo # Coded by Noize at HackCommunity.com # echo ########################################################################## echo. set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1 echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -s [KEY] ^| -r [KEY]] [-c [CON]] echo [-n [MAC]] [-v] echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo [IP] Internal IP address to get associated MAC address of echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo -c Specify your connection name in order to automatically restart the NIC echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo [MAC]MAC address you want to assume (only with -s) echo -v Verbose mode goto end :arg1 if /i "%arg1%"=="-h" goto help if /i "%arg1%"=="-d" goto ipconfig if /i "%arg1%"=="-a" goto mac if /i "%arg1%"=="-l" goto arp if /i "%arg1%"=="-m" goto assoc if /i "%arg1%"=="-s" goto spoof if /i "%arg1%"=="-r" goto unspoof :err echo Syntax error^! goto end :help echo macspoofer [-h ^| -d ^| -a ^| -l ^| -m [IP] ^| -s [KEY] ^| -r [KEY]] [-c [CON]] echo [-n [MAC]] [-v] echo. echo If no arguments are specified, a brief help message is shown echo. echo -h Show an extended help message echo -d View detailed IP and MAC information for current host echo -a View all MAC addresses for current host echo -l View other MAC and IP addresses on the LAN echo -m Get MAC address for given local IP (you can't use your own IP) echo. echo [IP] Internal IP address to get associated MAC address of echo. echo -s Spoof current MAC and local IP addresses echo -r Restore original MAC and IP addresses echo. echo [KEY]Keyword that is part of the NIC's name you want to spoof or restore echo It should be an identifying word (it might be the whole name too) echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can also create a file called "keyword.txt" in the current directory echo to have macspoofer use its content as default keyword echo You might still specify [KEY] to use a different key from the default one echo -c Specify your connection name in order to automatically restart the NIC echo (Please, note your connection name does not mean your NIC's name) echo If you do not specify it, you will need to restart your NIC manually to echo see any changes in your MAC address echo To specify more words as argument enclose them in double quotes ("e. g.") echo You can make a file called "con.txt" in the current directory to use its echo content as default connection name echo. echo [CON]Connection name (e.g: Connection to local area network (LAN)) echo. echo -n Specify a new MAC address to assume (only with -s) echo. echo [MAC]MAC address you want to assume echo If -n is omitted the MAC address used is 001122334455 echo Please, note that if you enter an invalid MAC address spoofing will fail echo Allowed formats are 001122334455 and 00:00:00:00:00:00 (12 digits) echo. echo -v Verbose mode goto end :ipconfig set ipconf=ipconfig if /i "%2"=="-v" set ipconf=ipconfig /all %ipconf% goto end :mac < nul set /p var=Please, wait... set getmac=getmac if /i "%2"=="-v" set getmac=getmac -v %getmac% goto end :arp set arp=arp -a if /i "%2"=="-v" set arp=arp -a -v %arp% goto end :assoc set check= set check=%2 if not defined check goto noize for %%a in (1 2 3 4 5 6 7 8 9 0) do if "%check:~0,1%"=="%%a" goto skipassoc :noize echo Invalid IP address. goto end :skipassoc arp -a %2 goto end :spoof set newmac= if /i "%2"=="-n" set newmac=%3 if /i "%3"=="-n" set newmac=%4 if /i "%4"=="-n" set newmac=%5 if /i "%5"=="-n" set newmac=%6 if /i "%6"=="-n" set newmac=%7 if not defined newmac ( set newmac=001122334455 ) else ( set newmac=%newmac::=% ) set keyword= set keycheck=%2 if exist keyword.txt for /f "delims=" %%j in ('type keyword.txt') do set keyword=%%j if defined keycheck set keyword=%keycheck% if defined keyword goto skip set /p keyword="Enter a keyword that is part of your NIC's name only: " :skip echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop goto keyloop :quitloop reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /d "%newmac%" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 if not defined con echo Your MAC address was successfully changed. & echo You'll need to manually restart your NIC to see any changes. & goto end ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh1 netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto done1 :skipnetsh1 if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto done1 :spooffailed echo. echo Failed to change your MAC address. echo Run the program again with administrator privileges. goto end :unspoof set keyword=%2 if defined keyword goto isdef :looper set /p keyword="Enter a keyword that is part of your NIC's name: " echo. if not defined key goto looper :isdef echo. echo Please, wait... reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\ /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if not "%errorlevel%"=="0" echo Couldn't find the NIC with keyword. & goto end set i=0 :keyloop2 set /a i=i+1 if %i% LSS 10 set n=000%i% if %i% GTR 9 set n=00%i% if %i% GTR 99 set n=0%i% if %i% GTR 999 set n=%i% reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n% /v DriverDesc /s | find /i "%keyword%" 2>nul > nul if "%errorlevel%"=="0" goto quitloop2 goto keyloop2 :quitloop2 reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" 2>nul > nul if not "%errorlevel%"=="0" echo. & echo This NIC's MAC address has not been spoofed yet. & echo Restore failed. & goto end set con= if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7 reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\%n%" /v "NetworkAddress" /f 2>nul > nul if not "%errorlevel%"=="0" goto spooffailed if not defined con goto skipnic1 ver | find "XP" > nul if %ERRORLEVEL%==0 goto skipnetsh netsh interface set interface "%con%" admin=DISABLED netsh interface set interface "%con%" admin=ENABLED goto skipnic :skipnetsh if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul echo Const ssfCONTROLS = 3 >> macspooferbynoize.vbs echo sConnectionName = "%con%" >> macspooferbynoize.vbs echo sEnableVerb = "En^&able" >> macspooferbynoize.vbs echo sDisableVerb = "Disa^&ble" >> macspooferbynoize.vbs echo set shellApp = createobject("shell.application") >> macspooferbynoize.vbs echo set oControlPanel = shellApp.Namespace(ssfCONTROLS) >> macspooferbynoize.vbs echo set oNetConnections = nothing >> macspooferbynoize.vbs echo for each folderitem in oControlPanel.items >> macspooferbynoize.vbs echo if folderitem.name = "Network Connections" then >> macspooferbynoize.vbs echo set oNetConnections = folderitem.getfolder: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oNetConnections is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find 'Network Connections'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo set oLanConnection = nothing >> macspooferbynoize.vbs echo for each folderitem in oNetConnections.items >> macspooferbynoize.vbs echo if lcase(folderitem.name) = lcase(sConnectionName) then >> macspooferbynoize.vbs echo set oLanConnection = folderitem: exit for >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if oLanConnection is nothing then >> macspooferbynoize.vbs echo msgbox "Failed to find '" ^& sConnectionName ^& "'." >> macspooferbynoize.vbs echo wscript.quit >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo bEnabled = true >> macspooferbynoize.vbs echo set oEnableVerb = nothing >> macspooferbynoize.vbs echo set oDisableVerb = nothing >> macspooferbynoize.vbs echo for each verb in oLanConnection.verbs >> macspooferbynoize.vbs echo if verb.name = sEnableVerb then >> macspooferbynoize.vbs echo set oEnableVerb = verb >> macspooferbynoize.vbs echo bEnabled = false >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo if verb.name = sDisableVerb then >> macspooferbynoize.vbs echo set oDisableVerb = verb >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo next >> macspooferbynoize.vbs echo if bEnabled then >> macspooferbynoize.vbs echo oDisableVerb.DoIt() >> macspooferbynoize.vbs echo else >> macspooferbynoize.vbs echo oEnableVerb.DoIt >> macspooferbynoize.vbs echo end if >> macspooferbynoize.vbs echo wscript.sleep 500 >> macspooferbynoize.vbs call macspooferbynoize.vbs if exist macspooferbynoize.vbs del macspooferbynoize.vbs /f /q > nul goto skipnic :skipnic1 echo MAC and local IP addresses were successfully restored. echo You will need to manually restart your NIC before you can see any changes. goto end :done1 echo MAC was successfully changed. goto end :skipnic echo MAC and local IP addresses were successfully restored. :end

Save the code as macspoofer.bat so that you can use the usage:

Code:
macspoofer [OPTIONS]

Main screen (cmd /k macspoofer):

Code:
. ########################################################################## # Noize's Mac Address Spoofer # # v2.0 # # # # Coded by Noize at HackCommunity.com # ########################################################################## macspoofer [-h | -d | -a | -l | -m [IP] | -s [KEY] | -r [KEY]] [-c [CON]] [-n [MAC]] [-v] -h Show an extended help message -d View detailed IP and MAC information for current host -a View all MAC addresses for current host -l View other MAC and IP addresses on the LAN -m Get MAC address for given local IP (you can't use your own IP) [IP] Internal IP address to get associated MAC address of -s Spoof current MAC and local IP addresses -r Restore original MAC and IP addresses [KEY]Keyword that is part of the NIC's name you want to spoof or restore -c Specify your connection name in order to automatically restart the NIC [CON]Connection name (e.g: Connection to local area network (LAN)) [MAC]MAC address you want to assume (only with -s) -v Verbose mode

This is an open-source free project and you are allowed to re-use the code, edit the code and give away for free the code as long as you give credits.

Any feedback or (especially) bug report is highly appreciated.



Todo list:
- change MAC address of other hosts in the LAN remotely.



RE: Windows MAC address spoofer | V2.0 - MrGeek - 05-18-2013

Wow ... You are batch guy geek Smile
I am going to test it now .
Thanks a lot


RE: Windows MAC address spoofer | V2.0 - MrGeek - 05-18-2013

Wow ... You are batch guy geek Smile
I am going to test it now .
Thanks a lot


RE: Windows MAC address spoofer | V2.0 - Deque - 05-18-2013

-moved to HC Official Programs-

Looks great. Didn't try it yet, though. But I will later.

I see some repeated code pieces, where you probably can get rid of the repetition, like this:

Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

@ArkPhaze can probably help you better here than I can; I am not a Batch coder, I use Windows rarely.


RE: Windows MAC address spoofer | V2.0 - Deque - 05-18-2013

-moved to HC Official Programs-

Looks great. Didn't try it yet, though. But I will later.

I see some repeated code pieces, where you probably can get rid of the repetition, like this:

Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

@ArkPhaze can probably help you better here than I can; I am not a Batch coder, I use Windows rarely.


RE: Windows MAC address spoofer | V2.0 - ArkPhaze - 05-18-2013

Yeah, I can help a bit...

1. Replace all goto :end's with exit /b and get rid of :end

2. This isn't needed really:
Code:
cd %~dp0

3. You set arg to nothing, and then never use it after this:
Code:
set arg=

4. There's a better way than this:
Code:
set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1

Try this for instance:
Code:
@echo off if [%1] neq [] if "%1" neq "-help" goto :program :helpdoc echo Help requested... pause & exit /b :program echo Program started... pause

Same thing applies to other arguments that you check.

5. Avoid naming block sections the same names as your variables:
Code:
:arg1

That can lead to trouble for debugging if you are writing a big script.

ASSOC is a command as well, so you should be a bit more unique than this:
Code:
:assoc

6. Last thing I would say is to validate the invoked script with the arguments by doing an arg count as a minimum, before you decide to use arg %1 for something %2, %3, and when you need %4 it doesn't exist...

edit: As for what @Deque pointed out:
Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k

You actually don't need type, /f is specific for files too, you just need this:
Code:
if exist "con.txt" for /f "tokens=*" %%k in (con.txt) do set con=%%k

As for those if statements:
Code:
if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

You might be able to check then just shift the arguments. And assign to the same one since shifting is downwards. You aren't dealing with more than 9 arguments though, otherwise I usually create my own pseudo array of arguments...


RE: Windows MAC address spoofer | V2.0 - ArkPhaze - 05-18-2013

Yeah, I can help a bit...

1. Replace all goto :end's with exit /b and get rid of :end

2. This isn't needed really:
Code:
cd %~dp0

3. You set arg to nothing, and then never use it after this:
Code:
set arg=

4. There's a better way than this:
Code:
set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1

Try this for instance:
Code:
@echo off if [%1] neq [] if "%1" neq "-help" goto :program :helpdoc echo Help requested... pause & exit /b :program echo Program started... pause

Same thing applies to other arguments that you check.

5. Avoid naming block sections the same names as your variables:
Code:
:arg1

That can lead to trouble for debugging if you are writing a big script.

ASSOC is a command as well, so you should be a bit more unique than this:
Code:
:assoc

6. Last thing I would say is to validate the invoked script with the arguments by doing an arg count as a minimum, before you decide to use arg %1 for something %2, %3, and when you need %4 it doesn't exist...

edit: As for what @Deque pointed out:
Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k

You actually don't need type, /f is specific for files too, you just need this:
Code:
if exist "con.txt" for /f "tokens=*" %%k in (con.txt) do set con=%%k

As for those if statements:
Code:
if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

You might be able to check then just shift the arguments. And assign to the same one since shifting is downwards. You aren't dealing with more than 9 arguments though, otherwise I usually create my own pseudo array of arguments...


RE: Windows MAC address spoofer | V2.0 - noize - 05-18-2013

(05-18-2013, 08:06 AM)ArkPhaze Wrote: 1. Replace all goto :end's with exit /b and get rid of :end

Well, it's just the same, isn't it? I had really thought about replacing them all with exit /b but I thought it was really no point. I'll do it though if there's some reason why I should better use it, let me know.

Quote:2. This isn't needed really:
Code:
cd %~dp0

Actually, it is. If I run macspoofer as an admin (which thing is needed for the actual spoofing/restoring), System32 will be the current directory, am I wrong? This way I check for the text files with default settings in the file's directory instead.

Quote:3. You set arg to nothing, and then never use it after this:
Code:
set arg=

I had removed the use of arg but forgot to remove that. I'll just edit the code.

Quote:4. There's a better way than this:
Code:
set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1

Try this for instance:
Code:
@echo off if [%1] neq [] if "%1" neq "-help" goto :program :helpdoc echo Help requested... pause & exit /b :program echo Program started... pause

Same thing applies to other arguments that you check.

I did it just because, when dealing with parameters, I found that sometimes this code was doing it:

Code:
if [%1] neq [] if "%1" neq "-help" goto :program

While some other time it was this:

Code:
if [%1] neq [ ] if "%1" neq "-help" goto :program

I chose to then start setting the parameter to a variable and then checking if defined, as

Code:
set var=

or

Code:
set var={space}

both not define var.

Quote:5. Avoid naming block sections the same names as your variables:
Code:
:arg1

That can lead to trouble for debugging if you are writing a big script.

How? I mean, maybe there's really something I didn't consider, I'd like to know about it. But if you just meant that I could get confused with it, well, it's no worry.

Quote:ASSOC is a command as well, so you should be a bit more unique than this:
Code:
:assoc

Yeah, I know that, but it's nowhere an issue.

Quote:6. Last thing I would say is to validate the invoked script with the arguments by doing an arg count as a minimum, before you decide to use arg %1 for something %2, %3, and when you need %4 it doesn't exist...

Well, but there may be even no args or 1, 2, 3, 4, 5 or 6 valid arguments. If you meant that I could check first for the number of args and then not check for those args (like in the code two quotes beneath), well, I think it's kinda pointless.

Quote:edit: As for what @Deque pointed out:
Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k

You actually don't need type, /f is specific for files too, you just need this:
Code:
if exist "con.txt" for /f "tokens=*" %%k in (con.txt) do set con=%%k

Yeah, I know all uses of FOR, but I usually substitute even FOR 'string' with FOR /F 'echo string'. That's the same thing after all, just I find myself more comfortable.

Quote:As for those if statements:
Code:
if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

You might be able to check then just shift the arguments. And assign to the same one since shifting is downwards. You aren't dealing with more than 9 arguments though, otherwise I usually create my own pseudo array of arguments...

You're right. I had a bit of troubles in making all of that block of code shorter using different commands and I then chose to leave it like that. Though, I didn't think of using the SHIFT command for this kind of things. Actually, if I would shift it like that here it would take more code than what that block of code is to take the args back in order (I'm not saying it's too hard, just it's more code than that). Yeah, by shifting all commands until I find for all times this issue comes to me, there wouldn't be the issue.

I'll improve my code later. Thanks.


RE: Windows MAC address spoofer | V2.0 - noize - 05-18-2013

(05-18-2013, 08:06 AM)ArkPhaze Wrote: 1. Replace all goto :end's with exit /b and get rid of :end

Well, it's just the same, isn't it? I had really thought about replacing them all with exit /b but I thought it was really no point. I'll do it though if there's some reason why I should better use it, let me know.

Quote:2. This isn't needed really:
Code:
cd %~dp0

Actually, it is. If I run macspoofer as an admin (which thing is needed for the actual spoofing/restoring), System32 will be the current directory, am I wrong? This way I check for the text files with default settings in the file's directory instead.

Quote:3. You set arg to nothing, and then never use it after this:
Code:
set arg=

I had removed the use of arg but forgot to remove that. I'll just edit the code.

Quote:4. There's a better way than this:
Code:
set arg1=%1 if /i "%arg1%"=="-help" set arg1= if defined arg1 goto arg1

Try this for instance:
Code:
@echo off if [%1] neq [] if "%1" neq "-help" goto :program :helpdoc echo Help requested... pause & exit /b :program echo Program started... pause

Same thing applies to other arguments that you check.

I did it just because, when dealing with parameters, I found that sometimes this code was doing it:

Code:
if [%1] neq [] if "%1" neq "-help" goto :program

While some other time it was this:

Code:
if [%1] neq [ ] if "%1" neq "-help" goto :program

I chose to then start setting the parameter to a variable and then checking if defined, as

Code:
set var=

or

Code:
set var={space}

both not define var.

Quote:5. Avoid naming block sections the same names as your variables:
Code:
:arg1

That can lead to trouble for debugging if you are writing a big script.

How? I mean, maybe there's really something I didn't consider, I'd like to know about it. But if you just meant that I could get confused with it, well, it's no worry.

Quote:ASSOC is a command as well, so you should be a bit more unique than this:
Code:
:assoc

Yeah, I know that, but it's nowhere an issue.

Quote:6. Last thing I would say is to validate the invoked script with the arguments by doing an arg count as a minimum, before you decide to use arg %1 for something %2, %3, and when you need %4 it doesn't exist...

Well, but there may be even no args or 1, 2, 3, 4, 5 or 6 valid arguments. If you meant that I could check first for the number of args and then not check for those args (like in the code two quotes beneath), well, I think it's kinda pointless.

Quote:edit: As for what @Deque pointed out:
Code:
if exist "con.txt" for /f "delims= tokens=*" %%k in ('type con.txt') do set con=%%k

You actually don't need type, /f is specific for files too, you just need this:
Code:
if exist "con.txt" for /f "tokens=*" %%k in (con.txt) do set con=%%k

Yeah, I know all uses of FOR, but I usually substitute even FOR 'string' with FOR /F 'echo string'. That's the same thing after all, just I find myself more comfortable.

Quote:As for those if statements:
Code:
if /i "%2"=="-c" set con=%3 if /i "%3"=="-c" set con=%4 if /i "%4"=="-c" set con=%5 if /i "%5"=="-c" set con=%6 if /i "%6"=="-c" set con=%7

You might be able to check then just shift the arguments. And assign to the same one since shifting is downwards. You aren't dealing with more than 9 arguments though, otherwise I usually create my own pseudo array of arguments...

You're right. I had a bit of troubles in making all of that block of code shorter using different commands and I then chose to leave it like that. Though, I didn't think of using the SHIFT command for this kind of things. Actually, if I would shift it like that here it would take more code than what that block of code is to take the args back in order (I'm not saying it's too hard, just it's more code than that). Yeah, by shifting all commands until I find for all times this issue comes to me, there wouldn't be the issue.

I'll improve my code later. Thanks.