Created
March 11, 2023 01:26
-
-
Save quonic/772897fe3e538f6529cfc167fcae40be to your computer and use it in GitHub Desktop.
Script to automate the removal of xhunter1.sys when found. Create a scheduled task that runs at start up as admin.
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
#Requires -Version 5.1 -RunAsAdministrator | |
function Remove-XHunter1 { | |
param () | |
Stop-Service xhunter1 -Force -NoWait -Confirm:$false | |
Remove-Item "HKLM:\SYSTEM\CurrentControlSet\Services\xhunter1" -ErrorAction SilentlyContinue | |
Remove-Item -Path "C:\Windows\xhunter1.sys" -Force -ErrorAction SilentlyContinue | |
} | |
function Test-XHunter1 { | |
param () | |
$(Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xhunter1" -ErrorAction SilentlyContinue) -or | |
$(Get-Service xhunter1 -ErrorAction SilentlyContinue) -or | |
$(Test-Path -Path "C:\Windows\xhunter1.sys") | |
} | |
if (Test-XHunter1) { | |
Remove-XHunter1 | |
if (Test-XHunter1) { | |
Write-EventLog -LogName Application -Source "Remove-XHunter1.ps1" -EntryType Error -EventId 666 -Category "Removal" -Message "Failed to remove xhunter1.sys" | |
exit 1 | |
} | |
else { | |
Write-EventLog -LogName Application -Source "Remove-XHunter1.ps1" -EntryType Warning -EventId 666 -Category "Removal" -Message "Removed xhunter1.sys" | |
exit 0 | |
} | |
} | |
else { | |
Write-EventLog -LogName Application -Source "Remove-XHunter1.ps1" -EntryType Information -EventId 666 -Category "Removal" -Message "xhunter1.sys was not found." | |
exit 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment