T1059.005

Visual Basic

Adversaries may abuse Visual Basic (VB) for execution. VB is a programming language created by Microsoft with interoperability with many Windows technologies such as COM and the Native API. Derivative languages include Visual Basic for Applications (VBA) embedded in Microsoft Office documents and VBScript executed via Windows Script Host (wscript.exe/cscript.exe). VBA macros in Office documents remain one of the most prevalent initial access vectors, while VBScript is used in HTA files and standalone scripts for payload delivery and execution.

Microsoft Sentinel / Defender
kusto
let SuspiciousPatterns = dynamic([
  "CreateObject", "WScript.Shell", "Shell.Application",
  "Scripting.FileSystemObject", "ADODB.Stream",
  "MSXML2.XMLHTTP", "WinHttp.WinHttpRequest",
  "Environ(", "Shell(", "CallByName",
  "powershell", "cmd /c", "cmd.exe",
  "RegWrite", "RegRead", "RegDelete",
  "GetObject(\"winmgmts", "Win32_Process",
  "-decode", "certutil", "bitsadmin"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("wscript.exe", "cscript.exe", "mshta.exe")
| where ProcessCommandLine has_any (SuspiciousPatterns) or ProcessCommandLine has_any (".vbs", ".vbe", ".wsf", ".hta")
| extend IsHTA = FileName =~ "mshta.exe" or ProcessCommandLine has ".hta"
| extend IsVBS = ProcessCommandLine has_any (".vbs", ".vbe")
| extend ShellExec = ProcessCommandLine has_any ("WScript.Shell", "Shell.Application", "powershell", "cmd /c")
| extend NetworkDownload = ProcessCommandLine has_any ("MSXML2.XMLHTTP", "WinHttp", "ADODB.Stream")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         IsHTA, IsVBS, ShellExec, NetworkDownload
| sort by Timestamp desc
high severity high confidence

Data Sources

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

Required Tables

DeviceProcessEvents

False Positives

  • Legitimate IT administration scripts using VBScript for system configuration and inventory
  • Login scripts deployed via Group Policy that use VBS for drive mapping and printer assignment
  • Legacy business applications that depend on VBScript or HTA interfaces
  • Microsoft Office macros used for approved business automation (finance, HR processes)

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections