diff --git a/README.md b/README.md index 9fa81ed..0d07ecd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ https://gist.github.com/KuromeSan/56d8b724c0696b54f9f81994ae3591d1 Unfortunately, I only found patchers for the timebomb that were written in .NET. Now I definitely don't want to pollute my system with .NET Framework and the patcher above didn't even work properly on Windows XP. -So I decided to write my own little patcher that is just a tiny executable wihout any dependencies. +So I decided to write my own little patcher that is just a tiny executable without any dependencies. It is based on the work mentioned above. # How to use? @@ -16,11 +16,7 @@ Depending on whether you are on x86 or x64 System, download flashpatch_x86.exe o If you just want to look in the default locations and patch Flash installation there, simply run the .exe If you want to scan a certain directory or patch a specifig file, specify it as a commandline parameter. -# What to do with Internet Explorer 11? -It may be that you need to re-register Flash in order to get Flash working with IE11 -Open cmd.exe Shell (on 64bit OS in 64bit Mode) as Administrator and: - -``` -regsvr32 %systemroot%\SysWOW64\Macromed\Flash\flash.ocx -regsvr32 %systemroot%\System32\Macromed\Flash\flash.ocx -``` +# How to reinstall flash after KB4577586 removed it? +On Windows 7 and below, just download and install it from the sites mentioned [here](https://gist.github.com/KuromeSan/56d8b724c0696b54f9f81994ae3591d1#finally) +On Windows 10, you need to download the latest Flash player from KB4580325 and reinstall its contents. +For this, download reinst_flash_w10.cmd to the same directory as the flashpatch_???.exe files and run it, it downloads mentioned updated flash version and copies it to System directory again. diff --git a/flashpatch.c b/flashpatch.c index ad67da1..69a2676 100644 --- a/flashpatch.c +++ b/flashpatch.c @@ -25,24 +25,33 @@ static BOOL PatchFile(char *pszFile); static BOOL ShowError(LPSTR pszError); static BOOL EnablePrivilege (HANDLE hProcess, LPCTSTR lpPrivilegeName); -static int LocateExes(void) +static int ScanFlashFolder(int nFolder) { - char szDir[MAX_PATH], *p; + char szDir[MAX_PATH+16], *p, *pszDir = szDir+9; int nFiles = 0; - printf ("Scanning...\n"); - if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_SYSTEM, FALSE)) + strcpy(szDir, "regsvr32 "); + if (SHGetSpecialFolderPath(NULL, pszDir, nFolder, FALSE)) { - strcat(szDir, "\\Macromed\\Flash"); - nFiles += ScanFolder(szDir); + strcat(pszDir, "\\Macromed\\Flash"); + p = pszDir + strlen(pszDir); + nFiles += ScanFolder(pszDir); + strcpy(p, "\\flash.ocx"); + if (GetFileAttributes(pszDir) != INVALID_FILE_ATTRIBUTES) + WinExec(szDir, SW_HIDE); } + return nFiles; +} +static int LocateExes(void) +{ + char szDir[MAX_PATH], *p; + int nFiles = 0; + + printf ("Scanning...\n"); + nFiles += ScanFlashFolder(CSIDL_SYSTEM); #ifdef _WIN64 - if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_SYSTEMX86, FALSE)) - { - strcat(szDir, "\\Macromed\\Flash"); - nFiles += ScanFolder(szDir); - } + nFiles += ScanFlashFolder(CSIDL_SYSTEMX86); #endif if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_LOCAL_APPDATA, FALSE)) { @@ -127,7 +136,7 @@ static BOOL PatchFile(char *pszFile) HANDLE hFile; BOOL bRet=FALSE; BYTE Timestamp[] = {0x00, 0x00, 0x40, 0x46, 0x3E, 0x6F, 0x77, 0x42}; - BYTE Infinity[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F}; + BYTE Infinity[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F}; PBYTE lpSig, lpMem; printf ("Checking %s....", pszFile); diff --git a/reinst_flash_w10.cmd b/reinst_flash_w10.cmd new file mode 100644 index 0000000..3bfcc46 --- /dev/null +++ b/reinst_flash_w10.cmd @@ -0,0 +1,93 @@ +@echo off +rem +rem Are we even needed? +rem +wmic qfe get hotfixid | find /i "KB4577586" >nul +if errorlevel 0 echo [*] Evil update KB4577586 installed. +if not exist %systemroot%\System32\Macromed\Flash\Flash.ocx goto noflash +if exist %systemroot%\SysWOW64 ( + if not exist %systemroot%\SysWOW64\Macromed\Flash\Flash.ocx goto noflash +) +if "%1"=="/FORCE" goto noflash +echo Flash is still present, are you sure that you want me to run? +echo If so, start me with /FORCE parameter +goto fini + +:noflash +rem Ensure that we are run from 64bit prompt +if "%ProgramFiles(x86)%" == "" goto StartExec +if not exist %SystemRoot%\Sysnative\cmd.exe goto StartExec +%SystemRoot%\Sysnative\cmd.exe /C "%~f0" %* +exit /b +:StartExec +>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" +echo UAC.ShellExecute "%~s0", "%1", "%1", "runas", 1 >> "%temp%\getadmin.vbs" +"%temp%\getadmin.vbs" +exit /B +:gotAdmin +if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) +pushd "%CD%" +CD /D "%~dp0" + +setlocal +set ARCH=amd64 +reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | Find /i "x86" >nul +if not errorlevel 1 set ARCH=wow64 + +if not exist KB4580325.msu ( + echo [*] Downloading update... + bitsadmin /transfer KB4580325.msu /download /priority normal http://download.windowsupdate.com/d/msdownload/update/software/secu/2020/10/windows10.0-kb4580325-x64_b6e8f5b34fd68a4e3c29a540000327f6d0675a7f.msu %CD%\KB4580325.msu + if not exist KB4580325.msu ( + echo [-] Download failed + goto fini + ) +) + +echo [*] Extracting contents... +md ContentMSU +expand KB4580325.msu /F:* .\ContentMSU >nul +cd ContentMSU +md ContentCAB +expand Windows*.cab /F:* .\ContentCAB >nul +cd ContentCAB + +echo [*] Copying Flash.. +cd %ARCH%_adobe* +call :copyflash System32 +if "%ARCH%"=="amd64" ( + cd ..\wow64_adobe* + call :copyflash SysWOW64 + copy /y flashplayercplapp.cpl %systemroot%\SysWOW64\ + copy /y flashplayerapp.exe %systemroot%\SysWOW64\ + set ARCH=x64 +) else ( + copy /y flashplayercplapp.cpl %systemroot%\System32\ + copy /y flashplayerapp.exe %systemroot%\System32\ + set ARCH=x86 +) +cd ..\..\.. +rmdir /s /q ContentMSU +if not exist flashpatch_%ARCH%.exe ( + echo [-] flashpatch_%ARCH%.exe not found! + goto fini +) +flashpatch_%ARCH%.exe +exit /B + +:copyflash +md %systemroot%\%1\Macromed\Flash +md %systemroot%\%1\Macromed\Temp +copy /y flash.ocx %systemroot%\%1\Macromed\Flash\ +copy /y flashutil_activex.dll %systemroot%\%1\Macromed\Flash\ +copy /y flashutil_activex.exe %systemroot%\%1\Macromed\Flash\ +copy /y activex.vch %systemroot%\%1\Macromed\Flash\ +exit /B + +:fini +pause