PowerShell ScriptBlockLogging: Disable/Lower Windows Defender Monitoring via Set-MpPreference
Alert on PowerShell Set-MpPreference usage that disables Defender scanning/monitoring or sets threat default actions to Allow.
FreeUnreviewedSigmahighv1
powershell-scriptblocklogging-disable-lower-windows-defender-monitoring-via-set--14c71865
title: "PowerShell ScriptBlockLogging: Disable/Lower Windows Defender Monitoring via Set-MpPreference"
id: 84fc32c1-c066-4b72-bd06-c454d023cbcb
related:
- id: ec19ebab-72dc-40e1-9728-4c0b805d722c
type: derived
- id: 14c71865-6cd3-44ae-adaa-1db923fae5f2
type: derived
status: test
description: This rule flags PowerShell script block activity that calls Set-MpPreference to disable multiple Windows Defender monitoring and scanning features, using parameter values like -Disable* set to true/1. It also triggers when Set-MpPreference is used to set high/low/moderate/severe threat default actions to Allow. Disabling or relaxing Defender protections can help attackers evade detection and response, and the rule relies on Script Block Logging telemetry containing the relevant Set-MpPreference text and parameters.
references:
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1562.001/T1562.001.md
- https://learn.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=windowsserver2022-ps
- https://bidouillesecurity.com/disable-windows-defender-in-powershell/
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_tamper_windows_defender_set_mp.yml
author: frack113, elhoim, Tim Shelton (fps, alias support), Swachchhanda Shrawan Poudel, Nasreddine Bencherchali (Nextron Systems), Huntrule Team
date: 2022-01-16
modified: 2024-01-02
tags:
- attack.defense-impairment
- attack.t1685
logsource:
product: windows
category: ps_script
definition: "Requirements: Script Block Logging must be enabled"
detection:
selection_options_disabling_preference:
ScriptBlockText|contains: Set-MpPreference
selection_options_disabling_function:
ScriptBlockText|contains:
- -dbaf $true
- -dbaf 1
- -dbm $true
- -dbm 1
- -dips $true
- -dips 1
- -DisableArchiveScanning $true
- -DisableArchiveScanning 1
- -DisableBehaviorMonitoring $true
- -DisableBehaviorMonitoring 1
- -DisableBlockAtFirstSeen $true
- -DisableBlockAtFirstSeen 1
- -DisableCatchupFullScan $true
- -DisableCatchupFullScan 1
- -DisableCatchupQuickScan $true
- -DisableCatchupQuickScan 1
- -DisableIntrusionPreventionSystem $true
- -DisableIntrusionPreventionSystem 1
- -DisableIOAVProtection $true
- -DisableIOAVProtection 1
- -DisableRealtimeMonitoring $true
- -DisableRealtimeMonitoring 1
- -DisableRemovableDriveScanning $true
- -DisableRemovableDriveScanning 1
- -DisableScanningMappedNetworkDrivesForFullScan $true
- -DisableScanningMappedNetworkDrivesForFullScan 1
- -DisableScanningNetworkFiles $true
- -DisableScanningNetworkFiles 1
- -DisableScriptScanning $true
- -DisableScriptScanning 1
- -MAPSReporting $false
- -MAPSReporting 0
- -drdsc $true
- -drdsc 1
- -drtm $true
- -drtm 1
- -dscrptsc $true
- -dscrptsc 1
- -dsmndf $true
- -dsmndf 1
- -dsnf $true
- -dsnf 1
- -dss $true
- -dss 1
selection_other_default_actions_allow:
ScriptBlockText|contains: Set-MpPreference
selection_other_default_actions_func:
ScriptBlockText|contains:
- HighThreatDefaultAction Allow
- htdefac Allow
- LowThreatDefaultAction Allow
- ltdefac Allow
- ModerateThreatDefaultAction Allow
- mtdefac Allow
- SevereThreatDefaultAction Allow
- stdefac Allow
condition: all of selection_options_disabling_* or all of selection_other_default_actions_*
falsepositives:
- Legitimate PowerShell scripts that disable Windows Defender for troubleshooting purposes. Must be investigated.
level: high
license: DRL-1.1
What it detects
This rule flags PowerShell script block activity that calls Set-MpPreference to disable multiple Windows Defender monitoring and scanning features, using parameter values like -Disable* set to true/1. It also triggers when Set-MpPreference is used to set high/low/moderate/severe threat default actions to Allow. Disabling or relaxing Defender protections can help attackers evade detection and response, and the rule relies on Script Block Logging telemetry containing the relevant Set-MpPreference text and parameters.
Known false positives
- Legitimate PowerShell scripts that disable Windows Defender for troubleshooting purposes. Must be investigated.
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.