Detection rules › Splunk

Detect Use of cmd exe to Launch Script Interpreters

Status
production
Severity
low
Group by
IntegrityLevel, command_line, computer_name, event_action, original_file_name, parent_command_line, parent_process_guid, parent_process_id, parent_process_name, process_guid, process_hash, process_id, process_name, user, user_id, vendor_product
Author
Bhavin Patel, Mauricio Velazco, Splunk
Source
github.com/splunk/security_content

The following detects the execution of cscript.exe or wscript.exe processes spawned by cmd.exe, leveraging Endpoint Detection and Response (EDR) telemetry mapped to the Endpoint data model, with additional contextual filtering to improve fidelity and reduce false positives. It focuses on executions originating from user-writable directories such as Users, AppData, Temp, and Downloads, which are commonly abused by attackers to stage and execute malicious scripts, while excluding trusted system paths like C:\Windows\System32\ and C:\Program Files\ that are typically associated with legitimate activity. The detection also filters out service accounts (e.g., accounts ending with $ or known naming conventions) to minimize noise from automated processes and incorporates command-line context to better assess script execution patterns and identify potentially suspicious behavior.

Known false positives

  • This detection may still generate alerts from legitimate administrative or enterprise activity, particularly in environments that rely on logon scripts, software deployment tools (e.g., SCCM, Intune), legacy applications, or IT automation frameworks that execute scripts via cmd.exe. Some organizations may also have internally developed scripts that run from user-writable directories, which can appear suspicious but are benign. Additionally, environments with non-standard application installations or portable tools may trigger this detection.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

name: Detect Use of cmd exe to Launch Script Interpreters
id: b89919ed-fe5f-492c-b139-95dbb162039e
version: 16
creation_date: '2020-04-29'
modification_date: '2026-05-13'
author: Bhavin Patel, Mauricio Velazco, Splunk
status: production
type: Anomaly
description: |
    The following detects the execution of cscript.exe or wscript.exe processes spawned by cmd.exe, leveraging Endpoint Detection and Response (EDR) telemetry mapped to the Endpoint data model, with additional contextual filtering to improve fidelity and reduce false positives.
    It focuses on executions originating from user-writable directories such as Users, AppData, Temp, and Downloads, which are commonly abused by attackers to stage and execute malicious scripts, while excluding trusted system paths like C:\Windows\System32\ and C:\Program Files\ that are typically associated with legitimate activity.
    The detection also filters out service accounts (e.g., accounts ending with $ or known naming conventions) to minimize noise from automated processes and incorporates command-line context to better assess script execution patterns and identify potentially suspicious behavior.
data_source:
    - Sysmon EventID 1
    - Windows Event Log Security 4688
    - CrowdStrike ProcessRollup2
search: |-
    | tstats `security_content_summariesonly`
      count min(_time) as firstTime
            max(_time) as lastTime
    
    FROM datamodel=Endpoint.Processes WHERE
    
    Processes.parent_process_name="cmd.exe"
    (
        Processes.process_name IN ("cscript.exe", "wscript.exe")
        OR
        Processes.original_file_name IN ("cscript.exe", "wscript.exe")
    )
    NOT Processes.process IN (
        "* \"C:\\Program Files (x86)\\*",
        "* \"C:\\Program Files\\*",
        "* \"C:\\Windows\\System32\\*",
        "* \"C:\\Windows\\SysWOW64\\*",
        "* C:\\Program Files (x86)\\*",
        "* C:\\Program Files\\*",
        "* C:\\Windows\\System32\\*",
        "* C:\\Windows\\SysWOW64\\*"
    )
    NOT Processes.user="*$"
    BY Processes.action Processes.dest Processes.original_file_name
       Processes.parent_process Processes.parent_process_exec
       Processes.parent_process_guid Processes.parent_process_id
       Processes.parent_process_name Processes.parent_process_path
       Processes.process Processes.process_exec Processes.process_guid
       Processes.process_hash Processes.process_id Processes.process_integrity_level
       Processes.process_name Processes.process_path Processes.user
       Processes.user_id Processes.vendor_product
    | `drop_dm_object_name("Processes")`
    | `security_content_ctime(firstTime)`
    | `security_content_ctime(lastTime)`
    | `detect_use_of_cmd_exe_to_launch_script_interpreters_filter`
how_to_implement: The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this search, you must ingest logs that contain the process GUID, process name, and parent process. Additionally, you must ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product. The logs must also be mapped to the `Processes` node of the `Endpoint` data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
known_false_positives: |-
    This detection may still generate alerts from legitimate administrative or enterprise activity, particularly in environments that rely on logon scripts, software deployment tools (e.g., SCCM, Intune), legacy applications, or IT automation frameworks that execute scripts via cmd.exe. Some organizations may also have internally developed scripts that run from user-writable directories, which can appear suspicious but are benign. Additionally, environments with non-standard application installations or portable tools may trigger this detection.
references:
    - https://attack.mitre.org/techniques/T1059/
    - https://redcanary.com/threat-detection-report/techniques/windows-command-shell/
intermediate_findings:
    entities:
        - field: dest
          type: system
          score: 20
          message: cmd.exe launched a script interpreter [$process_name$] with CommandLine [$process$] on [$dest$]
threat_objects:
    - field: process
      type: process
analytic_story:
    - Emotet Malware DHS Report TA18-201A
    - Suspicious Command-Line Executions
    - Azorult
asset_type: Endpoint
mitre_attack_id:
    - T1059.003
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
category: endpoint
security_domain: endpoint

Stages and Predicates

Stage 1: tstats

| tstats `security_content_summariesonly`
  count min(_time) as firstTime
        max(_time) as lastTime

FROM datamodel=Endpoint.Processes WHERE

Processes.parent_process_name="cmd.exe"
(
    Processes.process_name IN ("cscript.exe", "wscript.exe")
    OR
    Processes.original_file_name IN ("cscript.exe", "wscript.exe")
)
NOT Processes.process IN (
    "* \"C:\\Program Files (x86)\\*",
    "* \"C:\\Program Files\\*",
    "* \"C:\\Windows\\System32\\*",
    "* \"C:\\Windows\\SysWOW64\\*",
    "* C:\\Program Files (x86)\\*",
    "* C:\\Program Files\\*",
    "* C:\\Windows\\System32\\*",
    "* C:\\Windows\\SysWOW64\\*"
)
NOT Processes.user="*$"
BY Processes.action Processes.dest Processes.original_file_name
   Processes.parent_process Processes.parent_process_exec
   Processes.parent_process_guid Processes.parent_process_id
   Processes.parent_process_name Processes.parent_process_path
   Processes.process Processes.process_exec Processes.process_guid
   Processes.process_hash Processes.process_id Processes.process_integrity_level
   Processes.process_name Processes.process_path Processes.user
   Processes.user_id Processes.vendor_product

Stage 2: search

| `drop_dm_object_name("Processes")`

Stage 3: search

| `security_content_ctime(firstTime)`

Stage 4: search

| `security_content_ctime(lastTime)`

Stage 5: search

| `detect_use_of_cmd_exe_to_launch_script_interpreters_filter`

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
Processes.processin"* C:\\Program Files (x86)\\*", "* C:\\Program Files\\*", "* C:\\Windows\\SysWOW64\\*", "* C:\\Windows\\System32\\*", "* \"C:\\Program Files (x86)\\*", "* \"C:\\Program Files\\*", "* \"C:\\Windows\\SysWOW64\\*", "* \"C:\\Windows\\System32\\*"excludes:Processes.process
Processes.usereq"*$"excludes:Processes.user

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Processes.original_file_namein
  • "cscript.exe" corpus 32 (sigma 17, elastic 15)
  • "wscript.exe" corpus 38 (elastic 21, sigma 17)
field:"OriginalFileName" kind:in
Processes.parent_process_nameeq
  • "cmd.exe" corpus 36 (elastic 31, splunk 4, kusto 1)
field:"parent_process_name" kind:eq
Processes.process_namein
  • "cscript.exe" corpus 67 (elastic 65, splunk 2)
  • "wscript.exe" corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:in