T1059.007

JavaScript

Adversaries may abuse various implementations of JavaScript for execution. JavaScript (JS) is a platform-independent scripting language commonly associated with web pages, but can also execute in runtime environments outside the browser. JScript is Microsoft's implementation interpreted via the Windows Script engine. JavaScript for Automation (JXA) is a macOS scripting language based on JavaScript, included in Apple's Open Scripting Architecture. Adversaries abuse JS for drive-by compromises, malicious email attachments (.js files), HTA-based payloads, and post-exploitation on macOS via JXA. Threat actors including APT32, TA505, Contagious Interview, and FIN6 use JavaScript extensively.

Microsoft Sentinel / Defender
kusto
let SuspiciousPatterns = dynamic([
  "WScript.Shell", "Shell.Application",
  "Scripting.FileSystemObject", "ADODB.Stream",
  "MSXML2.XMLHTTP", "WinHttp.WinHttpRequest",
  "ActiveXObject", "new Function",
  "eval(", "WScript.CreateObject",
  "powershell", "cmd /c", "cmd.exe",
  "certutil", "bitsadmin",
  "RunHTMLApplication", "javascript:",
  "ScriptEngine", "GetObject"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("wscript.exe", "cscript.exe", "mshta.exe", "node.exe", "osascript")
| where ProcessCommandLine has_any (SuspiciousPatterns) or ProcessCommandLine has_any (".js", ".jse", ".wsf")
| extend IsJScript = ProcessCommandLine has_any (".js", ".jse") and FileName in~ ("wscript.exe", "cscript.exe")
| extend IsNodeJS = FileName =~ "node.exe"
| extend IsJXA = FileName =~ "osascript" and ProcessCommandLine has "-l JavaScript"
| extend ActiveXUse = ProcessCommandLine has_any ("ActiveXObject", "WScript.CreateObject", "GetObject")
| extend ShellExec = ProcessCommandLine has_any ("WScript.Shell", "Shell.Application", "powershell", "cmd /c")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         IsJScript, IsNodeJS, IsJXA, ActiveXUse, ShellExec
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives

  • Developers running Node.js applications on their workstations or servers
  • IT automation scripts using JScript/WSF for system administration tasks
  • macOS developers using JXA for application automation and testing
  • Build systems and CI/CD pipelines that invoke Node.js

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections