-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: "Disable always running antimalware service" is wrong. #393
Comments
Update:
And with the powershell command: |
You are completely right. It's a bug. These are great contributions, same value as PRs. Thank you a lot. I'm stuck with two more keys, both are highly undocumented: IsServiceRunning: It is at Seems like value I may be wrong, please check: ServiceStartStates: It is also at This guide tells it to set it to Modifying this keys are hard and require TrustedInstaller privileges, I generate these from privacy.sexy for testing: Set `IsServiceRunning` to `1`
Set `IsServiceRunning` to `0`
Set `ServiceStartStates` to `1`PowerShell -ExecutionPolicy Unrestricted -Command "$command = ' reg add "^""HKLM\SOFTWARE\Microsoft\Windows Defender"^"" /v "^""ServiceStartStates"^"" /t "^""REG_DWORD"^"" /d "^""1"^"" /f'; $trustedInstallerSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $trustedInstallerName = $trustedInstallerSid.Translate([System.Security.Principal.NTAccount]); $streamOutFile = New-TemporaryFile; $batchFile = New-TemporaryFile; try {; $batchFile = Rename-Item $batchFile "^""$($batchFile.BaseName).bat"^"" -PassThru; "^""@echo off`r`n$command`r`nexit 0"^"" | Out-File $batchFile -Encoding ASCII; $taskName = 'privacy.sexy invoke'; schtasks.exe /delete /tn "^""$taskName"^"" /f 2>&1 | Out-Null <# Clean if something went wrong before, suppress any output #>; $taskAction = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument "^""cmd /c `"^""$batchFile`"^"" > $streamOutFile 2>&1"^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $taskAction -Settings $settings -Force -ErrorAction Stop | Out-Null; try {; ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $trustedInstallerName) | Out-Null; $timeOutLimit = (Get-Date).AddMinutes(5); Write-Host "^""Running as $trustedInstallerName"^""; while((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) {; Start-Sleep -Milliseconds 200; if((Get-Date) -gt $timeOutLimit) {; Write-Warning "^""Skipping results, it took so long to execute script."^""; break;; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) {; Write-Error "^""Failed to execute with exit code: $result."^""; }; } finally {; schtasks.exe /delete /tn "^""$taskName"^"" /f | Out-Null <# Outputs only errors #>; }; Get-Content $streamOutFile; } finally {; Remove-Item $streamOutFile, $batchFile; }" Set `ServiceStartStates` to `0` PowerShell -ExecutionPolicy Unrestricted -Command "$command = ' reg add "^""HKLM\SOFTWARE\Microsoft\Windows Defender"^"" /v "^""ServiceStartStates"^"" /t "^""REG_DWORD"^"" /d "^""0"^"" /f'; $trustedInstallerSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $trustedInstallerName = $trustedInstallerSid.Translate([System.Security.Principal.NTAccount]); $streamOutFile = New-TemporaryFile; $batchFile = New-TemporaryFile; try {; $batchFile = Rename-Item $batchFile "^""$($batchFile.BaseName).bat"^"" -PassThru; "^""@echo off`r`n$command`r`nexit 0"^"" | Out-File $batchFile -Encoding ASCII; $taskName = 'privacy.sexy invoke'; schtasks.exe /delete /tn "^""$taskName"^"" /f 2>&1 | Out-Null <# Clean if something went wrong before, suppress any output #>; $taskAction = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument "^""cmd /c `"^""$batchFile`"^"" > $streamOutFile 2>&1"^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $taskAction -Settings $settings -Force -ErrorAction Stop | Out-Null; try {; ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $trustedInstallerName) | Out-Null; $timeOutLimit = (Get-Date).AddMinutes(5); Write-Host "^""Running as $trustedInstallerName"^""; while((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) {; Start-Sleep -Milliseconds 200; if((Get-Date) -gt $timeOutLimit) {; Write-Warning "^""Skipping results, it took so long to execute script."^""; break;; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) {; Write-Error "^""Failed to execute with exit code: $result."^""; }; } finally {; schtasks.exe /delete /tn "^""$taskName"^"" /f | Out-Null <# Outputs only errors #>; }; Get-Content $streamOutFile; } finally {; Remove-Item $streamOutFile, $batchFile; }" They seem to be represent the state of When I search these keys, I see some projects setting them as I could not understand exactly which number is representing what because usually I need some help with investigation/testing. What do you suggest we do with those @femdiya ? Alternative I. Set to |
@undergroundwires Update: Now I get it: Secondly, I personally think (and from a human-readablity point), " Third, I used Windows Sandbox to confirm this behavior, some things to consider:
For my thoughts on "other projects setting this value to 0", I need more resources confirming that they do such thing. And for the next part, I asked GPT about what does this value do: -------------------------
-------------------------
Then I asked GPT about why there's no "
My final thoughts:
1.3. And from what I saw from users on forums, this key is dynamic and will be changed by Windows Defender when some actions are triggered (like scanning), And in order to report the correct status of " (I'll say my personal choice of whatever these keys should be added to the script or not after this)
IMPORTANT!
We also have so many choices of whatever we should add them to the privacy.sexy or not: First option, we can add both, under "Advanced/Not-recommended" classification. Give them static keys of "example. Second option, we can add these under another script (Merge these values with another related script). For example, after confirming that these values only affect " Third option, we can complete our (possible) tests and documentation, and decide for what's next. Add them in a completely different script, Merge them with other scripts, Or even decide to not add them at all due to conflict and... Wrapping up: The only correct way to decide what to do next, is proper documentations and possibly tests (if needed). All information I've provided is limited and my conclusions are highly limited too, with proper documentation and (perhaps) tests, we can provide better solutions. Sorry for poor English. |
Thank you for the research. Another article is this one which seems to be copy paste of the same thing as you figured out. There are bunch of copies of this article on very low reputable sources.
Similarly, Interestingly Either personal tests or docs. We do not have the doc and seems that we're doing the first research on these. As you verify that running state is I think a good test would be, disabling Defender by official way which is installing a third-party antivirus, for example Avast. Then watch how values of these keys are changing. |
Thanks for the response.
No, I don't use these cheap copy-paste articles which they only serve to boost the website reputation and make money for the website. Moving on. And to mention that, I have no comments on how-to test this value. So, looks like you found out more things that connect to those 2 values, really interesting. From what I see, I think that those .dll's are related to Windows Defender and all of it's services. Please check out #402 , SIDE NOTE 2 at additional information about my suggestions to disable new defender services. Best practice should be, creating a whole "Disable All Windows Defender Services" script, using my suggestions and current codes in the project (and further more research about all Windows Defender services), and finally, adding those two values (+ some tweaks, -hat im not sure about, to remove/unload those functions from those .dll's) with correct data and configuration, and test it on a clean Windows installation, and confirm within Event Viewer. |
I installed third-party antivirus (Avast) and see the following changes: Windows 11 23H2:
Windows 10 23H2:
I will still include setting |
Uhhh, Avast? |
This commit adds disabling missing low-level Defender service/drivers, improve disabling existing ones, and improve their documentation. Key changes: - Add disabling missing Defender services. - Add disabling missing Defender processes. - Add soft-deleting of missing service files - Fix `ServiceKeepAlive` value #393, #426 - Add disabling system modification restrictions for persistent Disable service disabling. - Recommend more Defender scripts on 'Strict' level Other supporting changes: - Add more documentation for related scripts. - Move disabling `SecHealthUI` to disabling Windows Security. - Fix `DisableService` attempting to disable the service even though its disabled. - Add ability to disable service on revert in `DisableServiceInRegistry`. - Improve categorization for simplicity, add new categories for new scripts. - Add ability to run `DeleteRegistryValue` as `TrustedInstaller`. - Rename some scripts/categories for simplicity and clarity.
Description
This is the code used on the website "privacy.sexy"
Which is in fact, wrong.
The correct value for '
ServiceKeepAlive
' should be '0
' as documented here:Group policy template
How can the bug be recreated?
Script error
(GPT made this)
Operating system
This script affects Windows users.
Script file
https://gist.github.com/femdiya/dd9c4628cd0261e65f09d586801fa8a0
Screenshots
No response
Additional information
The data for the value '
ServiceKeepAlive
' should be '0
', not '1
'. (In order to disable antimalware service, as promised in title of the script)The text was updated successfully, but these errors were encountered: