Detection rule
Powershell Defender Exclusion
Overview
Detects requests to exclude files, folders or processes from Antivirus scanning using PowerShell cmdlets
- Rule id
17769c90-230e-488b-a463-e05c08e9d48f- ATT&CK techniques
- T1685 Disable or Modify Tools
- Severity
- Medium
- Confidence
- Low
- Origin
- SigmaHQ (community)
- SigmaHQ status
test- Used in defense packs
- n0n, The Gentlemen, qilin, INC Ransom, Akira, safepay, Play, braincipher, majinahanashi
Validation
- ExperimentalSyntax checked only. Not yet tested on events.
- Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
- SIEM-validatedRun in a real SIEM, with a recorded result.
2 of 2 positive test events matched; 2 of 2 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.
Detection logic and queries
Queries are shown exactly as generated. Test them in your environment before you deploy them.
Sigma
Sigma (YAML) · 17769c90-230e-488b-a463-e05c08e9d48f
title: Powershell Defender Exclusion
id: 17769c90-230e-488b-a463-e05c08e9d48f
related:
- id: c1344fa2-323b-4d2e-9176-84b4d4821c88
type: similar
status: test
description: Detects requests to exclude files, folders or processes from Antivirus scanning using PowerShell cmdlets
references:
- https://learn.microsoft.com/en-us/defender-endpoint/configure-process-opened-file-exclusions-microsoft-defender-antivirus
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1562.001/T1562.001.md
- https://twitter.com/AdamTheAnalyst/status/1483497517119590403
author: Florian Roth (Nextron Systems)
date: 2021-04-29
modified: 2022-05-12
tags:
- attack.defense-impairment
- attack.t1685
logsource:
category: process_creation
product: windows
detection:
selection1:
CommandLine|contains:
- 'Add-MpPreference '
- 'Set-MpPreference '
selection2:
CommandLine|contains:
- ' -ExclusionPath '
- ' -ExclusionExtension '
- ' -ExclusionProcess '
- ' -ExclusionIpAddress '
condition: all of selection*
falsepositives:
- Possible Admin Activity
- Other Cmdlets that may use the same parameters
level: mediumQRadar AQL
IBM QRadar AQL (hunting query)Hunting query
Hunting search for the Log Activity tab or the API. It is not a QRadar rule.
AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).
SELECT * FROM events WHERE devicetype=12 AND (LOWER(Command) LIKE '%add-mppreference %' OR LOWER(Command) LIKE '%set-mppreference %') AND (LOWER(Command) LIKE '% -exclusionpath %' OR LOWER(Command) LIKE '% -exclusionextension %' OR LOWER(Command) LIKE '% -exclusionprocess %' OR LOWER(Command) LIKE '% -exclusionipaddress %')QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Powershell Defender Exclusion- Rule type
- Event rule (Local)
- Log source types
- Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1
Building blocks
BB:OffSet7:Powershell Defender Exclusion:selection1(match)All test lines must match (AND).Commandcontains:Add-MpPreference,Set-MpPreference
BB:OffSet7:Powershell Defender Exclusion:selection2(match)All test lines must match (AND).Commandcontains:-ExclusionPath,-ExclusionExtension,-ExclusionProcess,-ExclusionIpAddress
Main rule, option A (building blocks)
- when the event(s) were detected by one or more of these log source types:
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1 - when an event matches the condition built from these building blocks:
(ALL of [BB:OffSet7:Powershell Defender Exclusion:selection1, BB:OffSet7:Powershell Defender Exclusion:selection2])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND (LOWER(Command) LIKE '%add-mppreference %' OR LOWER(Command) LIKE '%set-mppreference %') AND (LOWER(Command) LIKE '% -exclusionpath %' OR LOWER(Command) LIKE '% -exclusionextension %' OR LOWER(Command) LIKE '% -exclusionprocess %' OR LOWER(Command) LIKE '% -exclusionipaddress %')
Rule response
- Severity 5, credibility 6, relevance 7
- Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
- Respond no more than once per 30 minutes per Log Source (tune per environment)
Limitations
- QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.
Splunk
Splunk SPLSearch
Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.
(CommandLine IN ("*Add-MpPreference *", "*Set-MpPreference *")) (CommandLine IN ("* -ExclusionPath *", "* -ExclusionExtension *", "* -ExclusionProcess *", "* -ExclusionIpAddress *"))Splunk savedsearches.conf stanzaScheduled search template
Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.
[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now
[Powershell Defender Exclusion]
description = Detects requests to exclude files, folders or processes from Antivirus scanning using PowerShell cmdlets
search = (CommandLine IN ("*Add-MpPreference *", "*Set-MpPreference *")) (CommandLine IN ("* -ExclusionPath *", "* -ExclusionExtension *", "* -ExclusionProcess *", "* -ExclusionIpAddress *"))Microsoft Sentinel
Microsoft Sentinel KQL (ASIM)Hunting query
Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.
imProcessCreate
| where (TargetProcessCommandLine contains "Add-MpPreference " or TargetProcessCommandLine contains "Set-MpPreference ") and (TargetProcessCommandLine contains " -ExclusionPath " or TargetProcessCommandLine contains " -ExclusionExtension " or TargetProcessCommandLine contains " -ExclusionProcess " or TargetProcessCommandLine contains " -ExclusionIpAddress ")Defender XDR
Microsoft Defender XDR KQLHunting query
Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.
DeviceProcessEvents
| where (ProcessCommandLine contains "Add-MpPreference " or ProcessCommandLine contains "Set-MpPreference ") and (ProcessCommandLine contains " -ExclusionPath " or ProcessCommandLine contains " -ExclusionExtension " or ProcessCommandLine contains " -ExclusionProcess " or ProcessCommandLine contains " -ExclusionIpAddress ")Elastic
Elastic Lucene (ECS)Hunting query
Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.
(process.command_line:(*Add\-MpPreference\ * OR *Set\-MpPreference\ *)) AND (process.command_line:(*\ \-ExclusionPath\ * OR *\ \-ExclusionExtension\ * OR *\ \-ExclusionProcess\ * OR *\ \-ExclusionIpAddress\ *))Elastic EQL (ECS)Hunting query
EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.
any where (process.command_line like~ ("*Add-MpPreference *", "*Set-MpPreference *")) and (process.command_line like~ ("* -ExclusionPath *", "* -ExclusionExtension *", "* -ExclusionProcess *", "* -ExclusionIpAddress *"))Elastic ES|QL (ECS)Hunting query
ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.
from * metadata _id, _index, _version | where (process.command_line like "*Add-MpPreference *" or process.command_line like "*Set-MpPreference *") and (process.command_line like "* -ExclusionPath *" or process.command_line like "* -ExclusionExtension *" or process.command_line like "* -ExclusionProcess *" or process.command_line like "* -ExclusionIpAddress *")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLine
False positives
- Possible Admin Activity
- Other Cmdlets that may use the same parameters
Investigation and response
No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.
References
- https://learn.microsoft.com/en-us/defender-endpoint/configure-process-opened-file-exclusions-microsoft-defender-antivirus
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1562.001/T1562.001.md
- https://twitter.com/AdamTheAnalyst/status/1483497517119590403
Author and attribution
- Author
- Florian Roth (Nextron Systems)
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_powershell_defender_exclusion.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2