Powershell Windows Defender Exclusion Commands

 Original Source: [splunk source]
Name:Powershell Windows Defender Exclusion Commands
id:907ac95c-4dd9-11ec-ba2c-acde48001122
version:17
date:None
author:Teoderick Contreras, Splunk
status:production
type:Anomaly
Description:The following analytic detects the use of PowerShell commands to add or set Windows Defender exclusions. It leverages EventCode 4104 to identify suspicious `Add-MpPreference` or `Set-MpPreference` commands with exclusion parameters. This activity is significant because adversaries often use it to bypass Windows Defender, allowing malicious code to execute without detection. If confirmed malicious, this behavior could enable attackers to evade antivirus defenses, maintain persistence, and execute further malicious activities undetected.
Data_source:
  • -Powershell Script Block Logging 4104
search:`powershell`
EventCode=4104
ScriptBlockText IN (
"*Add-MpPreference *",
"*Set-MpPreference *"
)
ScriptBlockText = "*-exclusion*"
| fillnull
| stats count min(_time) as firstTime
max(_time) as lastTime
by dest signature signature_id
user_id vendor_product EventID
Guid Opcode Name
Path ProcessID ScriptBlockId
ScriptBlockText
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `powershell_windows_defender_exclusion_commands_filter`


how_to_implement:To successfully implement this search you need to be ingesting information on process that include the name of the process responsible for the changes from your endpoints into the `Endpoint` datamodel in the `Registry` node. Also make sure that this registry was included in your config files ex. sysmon config to be monitored.
known_false_positives:admin or user may choose to use this windows features.
References:
  -https://tccontre.blogspot.com/2020/01/remcos-rat-evading-windows-defender-av.html
  -https://app.any.run/tasks/cf1245de-06a7-4366-8209-8e3006f2bfe5/
  -https://www.microsoft.com/security/blog/2022/01/15/destructive-malware-targeting-ukrainian-organizations/
drilldown_searches:
 name:'View the detection results for - "$user_id$" and "$dest$"'
 search:'%original_detection_search% | search user_id = "$user_id$" dest = "$dest$"'
 earliest_offset:'$info_min_time$'
 latest_offset:'$info_max_time$'
 name:'View risk events for the last 7 days for - "$user_id$" and "$dest$"'
 search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$user_id$", "$dest$") | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`'
 earliest_offset:'7d'
 latest_offset:'0'
analytic_story:['CISA AA22-320A', 'AgentTesla', 'Remcos', 'Windows Defense Evasion Tactics', 'Data Destruction', 'WhisperGate', 'Warzone RAT', 'NetSupport RMM Tool Abuse', 'BlankGrabber Stealer', 'Salat Stealer']

asset_type:Endpoint

mitre_attack_id:['T1685']

product:['Splunk Enterprise', 'Splunk Enterprise Security', 'Splunk Cloud']

category:endpoint

security_domain:endpoint

tags:

tests:
 name:'True Positive Test'
 attack_data:
  data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1562.001/powershell_windows_defender_exclusion_commands/windows-xml.log
  source: XmlWinEventLog:Microsoft-Windows-PowerShell/Operational
  sourcetype: XmlWinEventLog
 test_type:'unit'
manual_test:None