T1064 Elastic Security · Elastic

Detect Scripting in Elastic Security

Adversaries may use scripts to aid in operations and perform multiple actions that would otherwise be manual. This deprecated technique (now superseded by T1059 Command and Scripting Interpreter) covered adversary use of scripting languages including VBScript, JavaScript, Windows Script Host, batch scripts, and macro-enabled Office documents. Scripts can be used to speed up operations, bypass process monitoring by interacting with the OS at an API level, and enable execution via spearphishing attachments containing malicious macros. Common attack patterns include VBScript/JScript execution via wscript.exe or cscript.exe, malicious Office macros spawning child processes, and batch scripts performing reconnaissance or lateral movement.

MITRE ATT&CK

Tactic
Defense Evasion Execution
Canonical reference
https://attack.mitre.org/techniques/T1064/

Elastic Detection Query

Elastic Security (Elastic)
eql
process where event.type == "start" and (
  (
    /* Branch 1: Office macro spawning script interpreters */
    process.parent.name : ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "access.exe", "visio.exe") and
    process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "cmd.exe", "powershell.exe", "pwsh.exe", "regsvr32.exe", "rundll32.exe")
  ) or
  (
    /* Branch 2: wscript/cscript with suspicious arguments */
    process.name : ("wscript.exe", "cscript.exe") and
    process.command_line regex~ "(invoke-expression|iex\\(|downloadstring|downloadfile|net\\.webclient|createobject|shell\\.application|shellexecute|wscript\\.shell|http:\\/\\/|https:\\/\\/|certutil|bitsadmin|\\.(vbs|vbe|js|jse|wsf|wsh|hta)\\b)"
  ) or
  (
    /* Branch 3: MSHTA loading remote or inline scripts */
    process.name : "mshta.exe" and
    process.command_line regex~ "(vbscript:|javascript:|http:\\/\\/|https:\\/\\/|\\/\\/|\\\\\\\\)"
  ) or
  (
    /* Branch 4: Cmd.exe obfuscated or Office-spawned */
    process.name : "cmd.exe" and
    (
      process.parent.name : ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "access.exe") or
      (
        process.command_line regex~ "(\\^\\^|&&|\\|\\|)" and
        process.command_line regex~ "(?i)(certutil|bitsadmin|powershell|wscript|cscript|http)"
      )
    )
  )
)
high severity high confidence

Detects T1064 scripting abuse across four branches using Elastic EQL process launch telemetry: (1) Office applications spawning script interpreters indicating macro execution, (2) wscript.exe or cscript.exe invoked with suspicious download, COM object, or file extension patterns, (3) mshta.exe loading remote or inline VBScript/JavaScript via protocol handlers or UNC paths, and (4) cmd.exe executing obfuscated batch chains with LOLBin download tools or spawned directly from Office applications.

Data Sources

Elastic Endpoint Security (elastic-endpoint)Winlogbeat with Sysmon moduleElastic Agent (Windows Integration)

Required Tables

logs-endpoint.events.process-*winlogbeat-*logs-windows.sysmon_operational-*

False Positives & Tuning

  • Legitimate Office add-ins or macros used by finance or operations teams that invoke wscript.exe or cscript.exe for automated document processing, mail-merge, or report generation workflows
  • Enterprise software deployment tooling such as SCCM, PDQ Deploy, or Ansible that use cmd.exe with certutil for artifact hash verification during managed software installations
  • Internal .hta-based enterprise portals loaded via mshta.exe that reference local intranet addresses using http:// or vbscript: protocol handlers on legacy infrastructure
Download portable Sigma rule (.yml)

Other platforms for T1064


Testing Methodology

Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1VBScript Download Cradle via wscript.exe

    Expected signal: Sysmon Event ID 1: Process Create with Image=wscript.exe, CommandLine referencing df00tech_test.vbs. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 from wscript.exe (connection will fail). Sysmon Event ID 11: File creation of df00tech_test.vbs in %TEMP%.

  2. Test 2JScript Execution via cscript.exe with Shell Command

    Expected signal: Sysmon Event ID 1: Process Create for cscript.exe with CommandLine referencing df00tech_shell.js. Sysmon Event ID 1 (child): cmd.exe spawned by cscript.exe with 'whoami' command. Sysmon Event ID 11: Output file creation in %TEMP%.

  3. Test 3MSHTA Remote HTA Execution

    Expected signal: Sysmon Event ID 1: Process Create with Image=mshta.exe, CommandLine='mshta.exe http://127.0.0.1:8080/df00tech_test.hta'. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 (will fail — no listener). The process creation event fires regardless of connection success.

  4. Test 4Simulated Office Macro Child Process (cmd.exe spawned from Word context)

    Expected signal: Sysmon Event ID 1: powershell.exe process create followed by cmd.exe child process. Security Event ID 4688 (if command line auditing enabled) for both processes. To fully test the OfficeMacroSpawn detection branch, the test would need to originate from a running winword.exe process — this simulation exercises the cmd.exe execution and output paths.

  5. Test 5VBScript Inline Execution via mshta vbscript: Protocol

    Expected signal: Sysmon Event ID 1: Process Create with Image=mshta.exe, CommandLine containing 'vbscript:Execute'. A dialog box will appear briefly — dismiss it. No network connections or file writes are expected for this test variant.

Unlock Pro Content

Get the full detection package for T1064 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections