Latest alertCVE-2018-11776 in Apache Struts Confirmed Exploited in the WildRead
Search all news in the platform

Detection rule

Suspicious Eventlog Clear

MediumTest-data validatedSigmaHQ (community)T1685.005

Overview

Detects usage of known powershell cmdlets such as "Clear-EventLog" to clear the Windows event logs

Rule id
0f017df3-8f5a-414f-ad6b-24aff1128278
ATT&CK techniques
T1685.005 Disable or Modify Tools: Clear Windows Event Logs
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

  1. ExperimentalSyntax checked only. Not yet tested on events.
  2. Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
  3. SIEM-validatedRun in a real SIEM, with a recorded result.

1 of 1 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) · 0f017df3-8f5a-414f-ad6b-24aff1128278

Download
title: Suspicious Eventlog Clear
id: 0f017df3-8f5a-414f-ad6b-24aff1128278
related:
    - id: cc36992a-4671-4f21-a91d-6c2b72a2edf5
      type: derived
status: test
description: Detects usage of known powershell cmdlets such as "Clear-EventLog" to clear the Windows event logs
references:
    - https://twitter.com/oroneequalsone/status/1568432028361830402
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1070.001/T1070.001.md
    - https://eqllib.readthedocs.io/en/latest/analytics/5b223758-07d6-4100-9e11-238cfdd0fe97.html
    - https://stackoverflow.com/questions/66011412/how-to-clear-a-event-log-in-powershell-7
    - https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventing.reader.eventlogsession.clearlog?view=windowsdesktop-9.0&viewFallbackFrom=dotnet-plat-ext-5.0#System_Diagnostics_Eventing_Reader_EventLogSession_ClearLog_System_String_
    - https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog.clear
author: Nasreddine Bencherchali (Nextron Systems), Swachchhanda Shrawan Poudel (Nextron Systems)
date: 2022-09-12
modified: 2025-10-06
tags:
    - attack.defense-impairment
    - attack.t1685.005
logsource:
    product: windows
    category: ps_script
    definition: 'Requirements: Script Block Logging must be enabled'
detection:
    selection:
        - ScriptBlockText|contains:
              - 'Clear-EventLog '
              - 'Remove-EventLog '
              - 'Limit-EventLog '
              - 'Clear-WinEvent '
        - ScriptBlockText|contains|all:
              - 'Eventing.Reader.EventLogSession' # [System.Diagnostics.Eventing.Reader.EventLogSession]::GlobalSession.ClearLog($_.LogName)
              - 'ClearLog'
        - ScriptBlockText|contains|all:
              - 'Diagnostics.EventLog'
              - 'Clear'
    condition: selection
falsepositives:
    - Rare need to clear logs before doing something. Sometimes used by installers or cleaner scripts. The script should be investigated to determine if it's legitimate
level: medium

QRadar 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(Message) LIKE '%clear-eventlog %' OR LOWER(Message) LIKE '%remove-eventlog %' OR LOWER(Message) LIKE '%limit-eventlog %' OR LOWER(Message) LIKE '%clear-winevent %') OR (LOWER(Message) LIKE '%eventing.reader.eventlogsession%' AND LOWER(Message) LIKE '%clearlog%') OR (LOWER(Message) LIKE '%diagnostics.eventlog%' AND LOWER(Message) LIKE '%clear%'))

QRadar CRE

Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.

Rule name
OffSet7: Suspicious Eventlog Clear
Rule type
Event rule (Local)
Log source types
Microsoft Windows Security Event Log DSM collecting Microsoft-Windows-PowerShell/Operational 4104 (Script Block Logging)

Building blocks

  • BB:OffSet7:Suspicious Eventlog Clear:selection (match)
    Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.
    • Message contains: Clear-EventLog, Remove-EventLog, Limit-EventLog, Clear-WinEvent
    • Message contains: Eventing.Reader.EventLogSession, ClearLog
    • Message contains: Diagnostics.EventLog, Clear

Main rule, option A (building blocks)

  1. when the event(s) were detected by one or more of these log source types: Microsoft Windows Security Event Log DSM collecting Microsoft-Windows-PowerShell/Operational 4104 (Script Block Logging)
  2. when an event matches the condition built from these building blocks: BB:OffSet7:Suspicious Eventlog Clear:selection

Main rule, option B (AQL filter test)

  1. when the event matches this AQL filter query: devicetype=12 AND ((LOWER(Message) LIKE '%clear-eventlog %' OR LOWER(Message) LIKE '%remove-eventlog %' OR LOWER(Message) LIKE '%limit-eventlog %' OR LOWER(Message) LIKE '%clear-winevent %') OR (LOWER(Message) LIKE '%eventing.reader.eventlogsession%' AND LOWER(Message) LIKE '%clearlog%') OR (LOWER(Message) LIKE '%diagnostics.eventlog%' AND LOWER(Message) LIKE '%clear%'))

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.

ScriptBlockText IN ("*Clear-EventLog *", "*Remove-EventLog *", "*Limit-EventLog *", "*Clear-WinEvent *") OR (ScriptBlockText="*Eventing.Reader.EventLogSession*" ScriptBlockText="*ClearLog*") OR (ScriptBlockText="*Diagnostics.EventLog*" ScriptBlockText="*Clear*")

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

[Suspicious Eventlog Clear]
description = Detects usage of known powershell cmdlets such as "Clear-EventLog" to clear the Windows event logs
search = ScriptBlockText IN ("*Clear-EventLog *", "*Remove-EventLog *", "*Limit-EventLog *", "*Clear-WinEvent *") OR (ScriptBlockText="*Eventing.Reader.EventLogSession*" ScriptBlockText="*ClearLog*") OR (ScriptBlockText="*Diagnostics.EventLog*" ScriptBlockText="*Clear*")

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.

(powershell.file.script_block_text:(*Clear\-EventLog\ * OR *Remove\-EventLog\ * OR *Limit\-EventLog\ * OR *Clear\-WinEvent\ *)) OR (powershell.file.script_block_text:*Eventing.Reader.EventLogSession* AND powershell.file.script_block_text:*ClearLog*) OR (powershell.file.script_block_text:*Diagnostics.EventLog* AND powershell.file.script_block_text:*Clear*)

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 (powershell.file.script_block_text like~ ("*Clear-EventLog *", "*Remove-EventLog *", "*Limit-EventLog *", "*Clear-WinEvent *")) or (powershell.file.script_block_text:"*Eventing.Reader.EventLogSession*" and powershell.file.script_block_text:"*ClearLog*") or (powershell.file.script_block_text:"*Diagnostics.EventLog*" and powershell.file.script_block_text:"*Clear*")

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 powershell.file.script_block_text like "*Clear-EventLog *" or powershell.file.script_block_text like "*Remove-EventLog *" or powershell.file.script_block_text like "*Limit-EventLog *" or powershell.file.script_block_text like "*Clear-WinEvent *" or powershell.file.script_block_text like "*Eventing.Reader.EventLogSession*" and powershell.file.script_block_text like "*ClearLog*" or powershell.file.script_block_text like "*Diagnostics.EventLog*" and powershell.file.script_block_text like "*Clear*"

No working conversion: Microsoft Sentinel KQL (ASIM) (No ASIM parser/table for this log source in the stock pipeline (see native draft on the Event table where one exists).); Microsoft Defender XDR KQL (Defender XDR advanced hunting has no PowerShell script-block/module text.)

Required telemetry

Log source
product: windows · category: ps_script · definition: Requirements: Script Block Logging must be enabled
Fields used
ScriptBlockText

False positives

  • Rare need to clear logs before doing something. Sometimes used by installers or cleaner scripts. The script should be investigated to determine if it's legitimate

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

Author and attribution

Author
Nasreddine Bencherchali (Nextron Systems), Swachchhanda Shrawan Poudel (Nextron Systems)
Source
SigmaHQ · rules/windows/powershell/powershell_script/posh_ps_susp_clear_eventlog.yml
Upstream commit
9688134317a2
Licence
Detection Rule License (DRL) 1.1

Version history

  1. Version 1Imported from SigmaHQ
  2. OffSet7 build · SigmaHQ 9688134317a2

Related rules