Last active
June 1, 2022 18:39
-
-
Save iam-py-test/5b52cbfaf49d959996aea5331f396052 to your computer and use it in GitHub Desktop.
Just the code from https://msrc-blog.microsoft.com/2022/05/30/guidance-for-cve-2022-30190-microsoft-support-diagnostic-tool-vulnerability/
This file contains 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 | |
echo Disabling the MSDT URL Protocol as to avoid CVE-2022-30190 | |
echo Code taken from https://arstechnica.com/information-technology/2022/05/code-execution-0day-in-windows-has-been-under-active-exploit-for-7-weeks/, but the original code is from https://msrc-blog.microsoft.com/2022/05/30/guidance-for-cve-2022-30190-microsoft-support-diagnostic-tool-vulnerability/ | |
echo Script made by https://github.com/iam-py-test | |
echo THIS THIS BETA SOFTWARE! Use with caution! If you want to be safe, create a system restore point before running this script | |
rem Stolen from https://stackoverflow.com/a/10052222 | |
:: BatchGotAdmin | |
:------------------------------------- | |
REM --> Check for permissions | |
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( | |
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" | |
) ELSE ( | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
) | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Please allow the UAC prompt for this script to work | |
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" | |
:-------------------------------------- | |
echo Are you sure you want to disable the MSDT URL Protocol? | |
pause | |
rem We assume the user is ok... | |
echo Backing up registry... | |
mkdir C:\ms-msdt-backup > nul | |
reg export HKEY_CLASSES_ROOT C:\ms-msdt-backup\backup.reg > nul | |
reg export HKEY_CLASSES_ROOT\ms-msdt C:\ms-msdt-backup\ms-msdt.reg | |
echo Press enter to continue | |
pause > nul | |
echo Making changes... | |
reg delete HKEY_CLASSES_ROOT\ms-msdt /f | |
echo Done! | |
echo To undo, merge the ms-msdt.reg file in C:\ms-msdt-backup\ | |
echo Do not delete C:\ms-msdt-backup\ if you want to be able to undo this change! | |
echo Only merge backup.reg if ms-msdt.reg does not work and problems occur! | |
pause > nul |
This file contains 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 | |
echo This will restore the ms-msdt.reg backup made by the original script and re-enable the MSDT URL Protocol. This ONLY will work if you disabled it via my original script | |
echo Script made by https://github.com/iam-py-test | |
echo THIS THIS BETA SOFTWARE! Use with caution! If you want to be safe, create a system restore point before running this script | |
rem Stolen from https://stackoverflow.com/a/10052222 | |
:: BatchGotAdmin | |
:------------------------------------- | |
REM --> Check for permissions | |
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( | |
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" | |
) ELSE ( | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
) | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Please allow the UAC prompt for this script to work | |
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" | |
:-------------------------------------- | |
echo Are you sure you want to re-enable the protocol? | |
pause | |
if exist C:\ms-msdt-backup\ms-msdt.reg ( | |
reg import C:\ms-msdt-backup\ms-msdt.reg | |
echo The key should have been restored | |
) else ( | |
echo Backup not found | |
pause > nul | |
exit 1 | |
) | |
reg import C:\ms-msdt-backup\ms-msdt.reg | |
echo The key should have been restored | |
set /p delete="Delete backup? (y/n) " | |
if %delete%==y ( | |
del /s /q C:\ms-msdt-backup\* | |
rmdir C:\ms-msdt-backup | |
) | |
pause > nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment