LeDragoX / Win-Debloat-Tools

Re-imagining Windows like a minimal OS install, already debloated with minimal impact for most functionality.
MIT License
4.82k stars 245 forks source link

.NET crypto got killed, and maybe some app with crypto library too. #130

Closed Bang1338 closed 1 month ago

Bang1338 commented 8 months ago

Describe the Bug

In Optimize-Security.ps1, or maybe somewhere else. after Enabling .NET strong cryptography and other crypto related stuff, some installer like Discord failed to install.

image

How can this issue be reproduced?

Just press apply tweak in the GUI.

Expected behavior?

N/A

Operating System

Windows 10

Operating System Version

20H2

Logs

WDT: no log Discord (log from error):

...
1896> 2023-10-15 20:45:09> Program: Starting Squirrel Updater: --install .
1896> 2023-10-15 20:45:10> Program: Starting install, writing to C:\Users\Admin\AppData\Local\SquirrelTemp
1896> 2023-10-15 20:45:10> Program: About to install to: C:\Users\Admin\AppData\Local\Discord
1896> 2023-10-15 20:45:10> Program: Install path C:\Users\Admin\AppData\Local\Discord already exists, burning it to the ground
1896> 2023-10-15 20:45:10> IEnableLogger: Failed to remove existing directory on full install, is the app still running???: System.Security.Cryptography.CryptographicException: The keyset is not defined.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv)
   at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters)
   at System.Security.Cryptography.Utils.get_StaticProvHandle()
   at System.IO.Path.GetRandomFileName()
   at Squirrel.Utility.<DeleteDirectory>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.Utility.<LogIfThrows>d__37.MoveNext()
1896> 2023-10-15 20:45:10> Unhandled exception: System.AggregateException: One or more errors occurred. ---> System.Security.Cryptography.CryptographicException: The keyset is not defined.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv)
   at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters)
   at System.Security.Cryptography.Utils.get_StaticProvHandle()
   at System.IO.Path.GetRandomFileName()
   at Squirrel.Utility.<DeleteDirectory>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.Utility.<LogIfThrows>d__37.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.Update.Program.<Install>d__5.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Squirrel.Update.Program.executeCommandLine(String[] args)
   at Squirrel.Update.Program.main(String[] args)
---> (Inner Exception #0) System.Security.Cryptography.CryptographicException: The keyset is not defined.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv)
   at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters)
   at System.Security.Cryptography.Utils.get_StaticProvHandle()
   at System.IO.Path.GetRandomFileName()
   at Squirrel.Utility.<DeleteDirectory>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.Utility.<LogIfThrows>d__37.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.Update.Program.<Install>d__5.MoveNext()<---

UPDATE BUG 16-10-23 4:00PM

Any .NET app that using crypto library also got killed. Example checksum.exe from choco

image

UPDATE BUG 16-10-23 4:07PM

Some C++ app also crashed. Including Kaspersky Plus which almost killed my PC and KPM image

Same thing with Zoom x86 installer (but work for x64) Image bellow is x86 installer image

UPDATE BUG 17-10-23 8:50PM

Starting Cobalt Strike 4.9 (Java) also crash image

UPDATE BUG 17-10-23 9:35PM

I'm not sure why, but I think Crypto API got a problem by tweak.

Update issues 15-11-23 16:12PM

Windows 10, not Windows 11, oops. Also, sadly that I manually fix without you and caused BSod, restore point also overwritten

Rest In Peace, 128GB SSD, which had incoming Discord bot. image

Bang1338 commented 8 months ago

^ typo mistake V some update :/

LeDragoX commented 7 months ago

Okay, this seems to cause more trouble than help. I'm removing this from the script, but for newer versions. All users still need to remove it manually, with this command on PowerShell:

Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto"
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto"