← Back to SOC feed Coverage →

Cscript script daily summary breakdown (Normalized Process Events)

kql MEDIUM Azure-Sentinel
imProcessCreate
huntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-04-22T09:00:00Z · Confidence: medium

Hunt Hypothesis

The hypothesis is that an adversary is leveraging scheduled script execution to maintain persistence and exfiltrate data across the environment. A SOC team should proactively hunt for this behavior in Azure Sentinel to identify potential long-term access and data leakage activities.

KQL Query

imProcessCreate
| where Process has "cscript.exe"
| extend FileName=tostring(split(Process, '\\')[-1])
| where FileName =~ "cscript.exe"
| extend removeSwitches = replace(@"/+[a-zA-Z0-9:]+", "", CommandLine)
| extend CommandLine = trim(@"[a-zA-Z0-9\\:""]*cscript(.exe)?("")?(\s)+", removeSwitches)
// handle case where script name is enclosed in " characters or is not enclosed in quotes 
| extend ScriptName= iff(CommandLine startswith @"""", 
extract(@"([:\\a-zA-Z_\-\s0-9\.()]+)(""?)", 0, CommandLine), 
extract(@"([:\\a-zA-Z_\-0-9\.()]+)(""?)", 0, CommandLine))
| extend ScriptName=trim(@"""", ScriptName) , ScriptNameLength=strlen(ScriptName)
// extract remainder of commandline as script parameters: 
| extend ScriptParams = iff(ScriptNameLength < strlen(CommandLine), substring(CommandLine, ScriptNameLength +1), "")
| summarize min(TimeGenerated), count() by Dvc, User, ScriptName, ScriptParams, EventVendor, EventProduct
| order by count_ asc nulls last 
| extend timestamp = min_TimeGenerated, HostCustomEntity = Dvc, AccountCustomEntity = User

Analytic Rule Definition

id: bd89c7a0-76cb-4fa1-bc64-c366687cda9e
name: Cscript script daily summary breakdown (Normalized Process Events)
description: |
  'breakdown of scripts running in the environment'
requiredDataConnectors: []
tactics:
  - Execution
query: |
  imProcessCreate
  | where Process has "cscript.exe"
  | extend FileName=tostring(split(Process, '\\')[-1])
  | where FileName =~ "cscript.exe"
  | extend removeSwitches = replace(@"/+[a-zA-Z0-9:]+", "", CommandLine)
  | extend CommandLine = trim(@"[a-zA-Z0-9\\:""]*cscript(.exe)?("")?(\s)+", removeSwitches)
  // handle case where script name is enclosed in " characters or is not enclosed in quotes 
  | extend ScriptName= iff(CommandLine startswith @"""", 
  extract(@"([:\\a-zA-Z_\-\s0-9\.()]+)(""?)", 0, CommandLine), 
  extract(@"([:\\a-zA-Z_\-0-9\.()]+)(""?)", 0, CommandLine))
  | extend ScriptName=trim(@"""", ScriptName) , ScriptNameLength=strlen(ScriptName)
  // extract remainder of commandline as script parameters: 
  | extend ScriptParams = iff(ScriptNameLength < strlen(CommandLine), substring(CommandLine, ScriptNameLength +1), "")
  | summarize min(TimeGenerated), count() by Dvc, User, ScriptName, ScriptParams, EventVendor, EventProduct
  | order by count_ asc nulls last 
  | extend timestamp = min_TimeGenerated, HostCustomEntity = Dvc, AccountCustomEntity = User

Required Data Sources

Sentinel TableNotes
imProcessCreateEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/ASimProcess/imProcess_cscript_summary.yaml