Detection rule
Disable Windows Defender AV Security Monitoring
Overview
Detects attackers attempting to disable Windows Defender using Powershell
- Rule id
a7ee1722-c3c5-aeff-3212-c777e4733217- ATT&CK techniques
- T1685 Disable or Modify Tools
- Severity
- High
- 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; 1 of 1 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) · a7ee1722-c3c5-aeff-3212-c777e4733217
title: Disable Windows Defender AV Security Monitoring
id: a7ee1722-c3c5-aeff-3212-c777e4733217
status: test
description: Detects attackers attempting to disable Windows Defender using Powershell
references:
- https://www.nccgroup.com/research/wastedlocker-a-new-ransomware-variant-developed-by-the-evil-corp-group/
- https://rvsec0n.wordpress.com/2020/01/24/malwares-that-bypass-windows-defender/
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1562.001/T1562.001.md
author: 'ok @securonix invrep-de, oscd.community, frack113'
date: 2020-10-12
modified: 2022-11-18
tags:
- attack.defense-impairment
- attack.t1685
logsource:
category: process_creation
product: windows
detection:
selection_pwsh_binary:
- Image|endswith:
- '\powershell.exe'
- '\pwsh.exe'
- OriginalFileName:
- 'PowerShell.EXE'
- 'pwsh.dll'
selection_pwsh_cli:
CommandLine|contains:
- '-DisableBehaviorMonitoring $true'
- '-DisableRuntimeMonitoring $true'
selection_sc_binary:
- Image|endswith: '\sc.exe'
- OriginalFileName: 'sc.exe'
selection_sc_tamper_cmd_stop:
CommandLine|contains|all:
- 'stop'
- 'WinDefend'
selection_sc_tamper_cmd_delete:
CommandLine|contains|all:
- 'delete'
- 'WinDefend'
selection_sc_tamper_cmd_disabled:
CommandLine|contains|all:
- 'config'
- 'WinDefend'
- 'start=disabled'
condition: all of selection_pwsh_* or (selection_sc_binary and 1 of selection_sc_tamper_*)
falsepositives:
- 'Minimal, for some older versions of dev tools, such as pycharm, developers were known to sometimes disable Windows Defender to improve performance, but this generally is not considered a good security practice.'
level: highQRadar 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("Process Path") LIKE '%\powershell.exe' OR LOWER("Process Path") LIKE '%\pwsh.exe') OR (LOWER("Process Name") LIKE '%\powershell.exe' OR LOWER("Process Name") LIKE '%\pwsh.exe')) OR (Filename IN('PowerShell.EXE', 'pwsh.dll'))) AND (LOWER(Command) LIKE '%-disablebehaviormonitoring $true%' OR LOWER(Command) LIKE '%-disableruntimemonitoring $true%')) OR (((LOWER("Process Path") LIKE '%\sc.exe' OR LOWER("Process Name") LIKE '%\sc.exe') OR Filename='sc.exe') AND ((LOWER(Command) LIKE '%stop%' AND LOWER(Command) LIKE '%windefend%') OR (LOWER(Command) LIKE '%delete%' AND LOWER(Command) LIKE '%windefend%') OR (LOWER(Command) LIKE '%config%' AND LOWER(Command) LIKE '%windefend%' AND LOWER(Command) LIKE '%start=disabled%'))))QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Disable Windows Defender AV Security Monitoring- 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:Disable Windows Defender AV Security Monitoring:selection_pwsh_binary(match)Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.Process Path / Process Nameends with:\powershell.exe,\pwsh.exeFilenameis equal to (case-insensitive):PowerShell.EXE,pwsh.dll
BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_pwsh_cli(match)All test lines must match (AND).Commandcontains:-DisableBehaviorMonitoring $true,-DisableRuntimeMonitoring $true
BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_sc_binary(match)Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.Process Path / Process Nameends with:\sc.exeFilenameis equal to (case-insensitive):sc.exe
BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_sc_tamper_cmd_stop(match)All test lines must match (AND).Commandcontains:stop,WinDefend
BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_sc_tamper_cmd_delete(match)All test lines must match (AND).Commandcontains:delete,WinDefend
BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_sc_tamper_cmd_disabled(match)All test lines must match (AND).Commandcontains:config,WinDefend,start=disabled
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:Disable Windows Defender AV Security Monitoring:selection_pwsh_binary, BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_pwsh_cli]) OR (BB:OffSet7:Disable Windows Defender AV Security Monitoring:selection_sc_binary AND (ANY of [])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND (((((LOWER("Process Path") LIKE '%\powershell.exe' OR LOWER("Process Path") LIKE '%\pwsh.exe') OR (LOWER("Process Name") LIKE '%\powershell.exe' OR LOWER("Process Name") LIKE '%\pwsh.exe')) OR (Filename IN('PowerShell.EXE', 'pwsh.dll'))) AND (LOWER(Command) LIKE '%-disablebehaviormonitoring $true%' OR LOWER(Command) LIKE '%-disableruntimemonitoring $true%')) OR (((LOWER("Process Path") LIKE '%\sc.exe' OR LOWER("Process Name") LIKE '%\sc.exe') OR Filename='sc.exe') AND ((LOWER(Command) LIKE '%stop%' AND LOWER(Command) LIKE '%windefend%') OR (LOWER(Command) LIKE '%delete%' AND LOWER(Command) LIKE '%windefend%') OR (LOWER(Command) LIKE '%config%' AND LOWER(Command) LIKE '%windefend%' AND LOWER(Command) LIKE '%start=disabled%'))))
Rule response
- Severity 7, 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.
((Image IN ("*\\powershell.exe", "*\\pwsh.exe") OR OriginalFileName IN ("PowerShell.EXE", "pwsh.dll")) (CommandLine IN ("*-DisableBehaviorMonitoring $true*", "*-DisableRuntimeMonitoring $true*"))) OR ((Image="*\\sc.exe" OR OriginalFileName="sc.exe") ((CommandLine="*stop*" CommandLine="*WinDefend*") OR (CommandLine="*delete*" CommandLine="*WinDefend*") OR (CommandLine="*config*" CommandLine="*WinDefend*" CommandLine="*start=disabled*")))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
[Disable Windows Defender AV Security Monitoring]
description = Detects attackers attempting to disable Windows Defender using Powershell
search = ((Image IN ("*\\powershell.exe", "*\\pwsh.exe") OR OriginalFileName IN ("PowerShell.EXE", "pwsh.dll")) (CommandLine IN ("*-DisableBehaviorMonitoring $true*", "*-DisableRuntimeMonitoring $true*"))) OR ((Image="*\\sc.exe" OR OriginalFileName="sc.exe") ((CommandLine="*stop*" CommandLine="*WinDefend*") OR (CommandLine="*delete*" CommandLine="*WinDefend*") OR (CommandLine="*config*" CommandLine="*WinDefend*" CommandLine="*start=disabled*")))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 (((TargetProcessName endswith "\\powershell.exe" or TargetProcessName endswith "\\pwsh.exe") or (TargetProcessFileOriginalName in~ ("PowerShell.EXE", "pwsh.dll"))) and (TargetProcessCommandLine contains "-DisableBehaviorMonitoring $true" or TargetProcessCommandLine contains "-DisableRuntimeMonitoring $true")) or ((TargetProcessName endswith "\\sc.exe" or TargetProcessFileOriginalName =~ "sc.exe") and ((TargetProcessCommandLine contains "stop" and TargetProcessCommandLine contains "WinDefend") or (TargetProcessCommandLine contains "delete" and TargetProcessCommandLine contains "WinDefend") or (TargetProcessCommandLine contains "config" and TargetProcessCommandLine contains "WinDefend" and TargetProcessCommandLine contains "start=disabled")))Defender XDR
Microsoft Defender XDR KQLHunting query
Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.
DeviceProcessEvents
| where (((FolderPath endswith "\\powershell.exe" or FolderPath endswith "\\pwsh.exe") or (ProcessVersionInfoOriginalFileName in~ ("PowerShell.EXE", "pwsh.dll"))) and (ProcessCommandLine contains "-DisableBehaviorMonitoring $true" or ProcessCommandLine contains "-DisableRuntimeMonitoring $true")) or ((FolderPath endswith "\\sc.exe" or ProcessVersionInfoOriginalFileName =~ "sc.exe") and ((ProcessCommandLine contains "stop" and ProcessCommandLine contains "WinDefend") or (ProcessCommandLine contains "delete" and ProcessCommandLine contains "WinDefend") or (ProcessCommandLine contains "config" and ProcessCommandLine contains "WinDefend" and ProcessCommandLine contains "start=disabled")))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.executable:(*\\powershell.exe OR *\\pwsh.exe)) OR (process.pe.original_file_name:(PowerShell.EXE OR pwsh.dll))) AND (process.command_line:(*\-DisableBehaviorMonitoring\ $true* OR *\-DisableRuntimeMonitoring\ $true*))) OR ((process.executable:*\\sc.exe OR process.pe.original_file_name:sc.exe) AND ((process.command_line:*stop* AND process.command_line:*WinDefend*) OR (process.command_line:*delete* AND process.command_line:*WinDefend*) OR (process.command_line:*config* AND process.command_line:*WinDefend* AND process.command_line:*start\=disabled*)))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.executable like~ ("*\\powershell.exe", "*\\pwsh.exe")) or (process.pe.original_file_name like~ ("PowerShell.EXE", "pwsh.dll"))) and (process.command_line like~ ("*-DisableBehaviorMonitoring $true*", "*-DisableRuntimeMonitoring $true*"))) or ((process.executable:"*\\sc.exe" or process.pe.original_file_name:"sc.exe") and ((process.command_line:"*stop*" and process.command_line:"*WinDefend*") or (process.command_line:"*delete*" and process.command_line:"*WinDefend*") or (process.command_line:"*config*" and process.command_line:"*WinDefend*" and process.command_line:"*start=disabled*")))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 (ends_with(process.executable, "\\powershell.exe") or ends_with(process.executable, "\\pwsh.exe") or process.pe.original_file_name in ("PowerShell.EXE", "pwsh.dll")) and (process.command_line like "*-DisableBehaviorMonitoring $true*" or process.command_line like "*-DisableRuntimeMonitoring $true*") or (ends_with(process.executable, "\\sc.exe") or process.pe.original_file_name=="sc.exe") and (process.command_line like "*stop*" and process.command_line like "*WinDefend*" or process.command_line like "*delete*" and process.command_line like "*WinDefend*" or process.command_line like "*config*" and process.command_line like "*WinDefend*" and process.command_line like "*start=disabled*")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineImageOriginalFileName
False positives
- Minimal, for some older versions of dev tools, such as pycharm, developers were known to sometimes disable Windows Defender to improve performance, but this generally is not considered a good security practice.
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://www.nccgroup.com/research/wastedlocker-a-new-ransomware-variant-developed-by-the-evil-corp-group/
- https://rvsec0n.wordpress.com/2020/01/24/malwares-that-bypass-windows-defender/
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1562.001/T1562.001.md
Author and attribution
- Author
- ok @securonix invrep-de, oscd.community, frack113
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_powershell_disable_defender_av_security_monitoring.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2