Skip to content
Threat Feed
high advisory

Detection of Windows Console History Clearing

Adversaries often attempt to clear PowerShell command history to conceal malicious activities conducted during a security incident.

Adversaries frequently employ anti-forensic techniques to hinder post-incident investigations by erasing evidence of their presence on a compromised host. One common objective is the removal of the PowerShell command history, which logs executed commands and script interactions. By deleting the 'ConsoleHost_history.txt' file or executing the 'Clear-History' cmdlet, attackers aim to prevent defenders from reconstructing the timeline of their actions, such as C2 communication, lateral movement, or data staging. This activity is a classic indicator of an attacker attempting to cover their tracks before disconnecting from the environment. Defenders should monitor for these specific command patterns in PowerShell Script Block logs to identify potential attempts to destroy forensic evidence.

Impact

Successful execution of console history clearing significantly degrades the ability of incident response teams to perform root cause analysis, identify the scope of the compromise, and recover sensitive information about the attacker's TTPs within the environment.

Recommendation

  • Enable PowerShell Script Block Logging (Event ID 4104) to capture the full command content of executed scripts.
  • Deploy the provided Sigma rule to your SIEM and alert on instances of manual history deletion or clearing command patterns.
  • Baseline administrative scripts that might perform log maintenance to reduce false positives.

Immediate actions

Enable PowerShell Script Block Logging (Event ID 4104) across all endpoint assets.

IT Operations 48h

Deploy the Sigma detection rule to monitor for history deletion events.

Detection Engineering 72h

Threat Hunt

Search historical logs for evidence of Clear-History or file deletion of history paths.

T1070.003 medium high confidence hunt now

Data: Event ID 4104

Mitigations

Restrict user execution permissions to prevent the removal of log files.

medium_term IT Operations

T1070.003

Detection coverage 1

Detect PowerShell Console History Clearing

high

Identifies attempts to clear PowerShell console history using Clear-History cmdlet or manual file deletion of ConsoleHost_history.txt.

sigma tactics: stealth techniques: T1070.003 sources: ps_script, windows

Detection queries are available on the platform. Get full rules →