Windows Remediation Commands

Set logging on all success/failure events

(WARNING THIS WILL PRODUCE A LOT OF NOISE, TAILOR TO YOUR NEEDS)

auditpol /set /category:* /success:enable /failure:enable

Enable logging of process creation

auditpol /set /subcategory:"Process Creation" /success:enable /failure:enable

Enable logging of non non-Windows module loads via WDAC code integrity

Note 1: Special thanks to Matt Graeber for this.

Note 2: This is based off of a Windows Defender Application Control system integrity policy which has been converted on an enterprise system.

On an enterprise system enable it by creating a module load audit policy: https://twitter.com/mattifestation/status/1366435525272481799

ConvertFrom-CIPolicy Non_Microsoft_UserMode_Load_Audit.xml C:\Windows\System32\CodeIntegrity\SIPolicy.p7b

Store the converted policy on a Win10 system to be monitored at: Windows\System32\CodeIntegrity\SIPolicy.p7b

Kill “Unstoppable” Service/Process

reg add HKLM\SYSTEM\CurrentControlSet\Services\{SERVICENAME}\XblAuthManager\Parameters /V start /T reg_dword /D 4 /f
sc.exe sdset {SERVICENAME} "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"
Get-Service -Name {SERVICENAME} | Set-Service -Status Paused
sc.exe config {SERVICENAME} start= disabled
Get-Service -Name {SERVICENAME} | Set-Service -Status Stopped
tasklist /FI "IMAGENAME eq {SERVICEEXENAME}"
taskkill /F /t /IM "{SERVICEEXENAME}"

Kill malicious process

Note: Call terminate allows you to specify an exit status in terms of a signed integer or a quoted negative value. Both methods essentially function the same by calling TerminateProcess.

Locate Possible Shellcode within process via Injected Thread

Obtain Possible Shellcode within process as Hex

Obtain Possible Shellcode within process as Hex

Remove ACE entries for “everyone”

Disable unwanted windows binaries (via Base64 encoding and removal)

Note: This is one method, not the only way.

Enable windows binaries (via Base64 decoding and removal)

Make multiple files visible and remove ‘superhidden’

Enable Date Accessed Timestamps

Remove BITSAdmin Persistence

Delete Windows Defender excluded files

Open File Extension (e.g. scripts) with certain application (elevated cmd)

Disable Command Prompt

Remediate malicious files

Powershell:

Remediate Persistent WMI Subscriptions

The most important aspect is to locate and remove the CommandLineEventConsumer. This has the malicious command stored within the value ‘CommandLineTemplate’. The below example searches for commands that contain ‘powershell’.

Malicious scheduled tasks

Powershell:

Registry Keys

Unload all users registry keys

Remediate Automatic Load/Run Reg Keys

Powershell:

Prevent Executable from Running.

Note: Load in hives and add particular SID to prevent users running named files, helps prevent for example your IIS service account from running cmd.exe or powershell.exe