Last active
January 16, 2025 05:47
-
-
Save aliinreallife/52ab42a6797623bc0a38f901ca897683 to your computer and use it in GitHub Desktop.
This script toggles your network's DNS settings between Shecan DNS (for bypassing restrictions) and the default automatic settings. It detects your active network adapter, updates the DNS configurationt. Simple, fast, and user-friendly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal enabledelayedexpansion | |
| REM Set the CMD window title | |
| title Shecan Toggler | |
| REM Check for admin privileges and self-elevate if needed | |
| >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
| if '%errorlevel%' NEQ '0' ( | |
| echo Requesting administrative privileges... | |
| goto UACPrompt | |
| ) else ( goto gotAdmin ) | |
| :UACPrompt | |
| echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
| set params = %*:"="" | |
| echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
| "%temp%\getadmin.vbs" | |
| del "%temp%\getadmin.vbs" | |
| exit /B | |
| :gotAdmin | |
| pushd "%CD%" | |
| CD /D "%~dp0" | |
| cls | |
| echo. | |
| echo ###### ## ## ######## ###### ### ## ## | |
| echo ## ## ## ## ## ## ## ## ## ### ## | |
| echo ## ## ## ## ## ## ## #### ## | |
| echo ###### ######### ###### ## ## ## ## ## ## | |
| echo ## ## ## ## ## ######### ## #### | |
| echo ## ## ## ## ## ## ## ## ## ## ### | |
| echo ###### ## ## ######## ###### ## ## ## ## | |
| echo. | |
| rem Check current DNS settings for the adapter | |
| echo ======================================================== | |
| echo Checking DNS settings... | |
| echo ======================================================== | |
| rem Get active network adapters and find the right one to use | |
| set "adapter=" | |
| set "adapterCount=0" | |
| for /f "tokens=*" %%i in ('netsh interface show interface ^| findstr /i "Connected"') do ( | |
| set /a adapterCount+=1 | |
| set "tempAdapter=%%i" | |
| if /i "!tempAdapter!" == "Ethernet" ( | |
| set "adapter=Ethernet" | |
| ) else if "!adapter!"=="" ( | |
| for /f "tokens=4*" %%a in ("%%i") do set "adapter=%%a" | |
| ) | |
| ) | |
| if "!adapter!"=="" ( | |
| echo [!] Error: No active network adapters found | |
| exit /b 1 | |
| ) | |
| echo [*] Using network adapter: !adapter! | |
| echo ======================================================== | |
| rem Check current DNS settings for the selected adapter | |
| for /f "tokens=3*" %%A in ('netsh interface ipv4 show dnsservers "!adapter!" ^| findstr /C:"Statically Configured"') do ( | |
| set "dnsserver=%%A %%B" | |
| ) | |
| if defined dnsserver ( | |
| echo [*] Current DNS Status: CONFIGURED | |
| echo ======================================================== | |
| netsh interface ipv4 set dnsservers name="Ethernet" source=dhcp >nul 2>&1 | |
| if %errorlevel% equ 0 ( | |
| echo [+] DNS server has been switched to DHCP | |
| ) else ( | |
| echo [!] Error: Could not set DNS. Please check network adapter name. | |
| ) | |
| ) else ( | |
| echo [*] Current DNS Status: NOT CONFIGURED | |
| echo ======================================================== | |
| echo [*] Setting up shecan DNS servers... | |
| echo ======================================================== | |
| netsh interface ipv4 set dnsservers name="Ethernet" static 178.22.122.100 primary >nul 2>&1 | |
| if %errorlevel% equ 0 ( | |
| netsh interface ipv4 add dnsservers name="Ethernet" 185.51.200.2 index=2 >nul 2>&1 | |
| echo [+] Primary DNS: 178.22.122.100 | |
| echo [+] Secondary DNS: 185.51.200.2 | |
| ) else ( | |
| echo [!] Error: Could not set DNS. Please check network adapter name. | |
| ) | |
| ) | |
| if defined dnsserver ( | |
| echo ======================================================== | |
| echo [*] Shecan DNS Status: | |
| powershell write-host " - - - - - - - - - - - - - [-] DEACTIVATED - - - - - - - " -f Red -nonewline | |
| echo. | |
| ) else ( | |
| echo ======================================================== | |
| echo [*] Shecan DNS Status: | |
| powershell write-host " - - - - - - - - - - - - - [+] ACTIVATED - - - - - - - - " -f Green -nonewline | |
| echo. | |
| ) | |
| echo ======================================================== | |
| echo. | |
| echo The window will close automatically in 12 seconds... | |
| timeout /t 12 /nobreak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment