T1059.010 Microsoft Sentinel · KQL

Detect AutoHotKey & AutoIT in Microsoft Sentinel

Adversaries may execute commands and perform malicious tasks using AutoIT and AutoHotKey automation scripts. AutoIT and AutoHotkey (AHK) are scripting languages that enable users to automate Windows tasks such as clicking buttons, entering text, and managing programs. Adversaries may use AHK (.ahk) and AutoIT (.au3) scripts to execute malicious code, deploy keyloggers, and deliver phishing payloads. These scripts can be compiled into self-contained executables. Threat actors including DarkGate, Lumma Stealer, APT39, and XLoader have leveraged AutoIT and AutoHotKey for malware delivery and execution.

MITRE ATT&CK

Tactic
Execution
Technique
T1059 Command and Scripting Interpreter
Sub-technique
T1059.010 AutoHotKey & AutoIT
Canonical reference
https://attack.mitre.org/techniques/T1059/010/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
let AutoITPatterns = dynamic([
  "AutoIt3.exe", "AutoIt", ".au3",
  "#include <Inet.au3>", "#include <File.au3>",
  "ShellExecute(", "RunWait(", "Run(",
  "FileInstall(", "DllCall(", "_WinHttpSimpleRequest",
  "ProcessClose(", "RegWrite(", "RegRead(",
  "@ScriptDir", "@TempDir", "@AppDataDir"
]);
let AHKPatterns = dynamic([
  "AutoHotkey.exe", "AutoHotkey", ".ahk",
  "Send,", "SendInput,", "SendRaw,",
  "RunWait,", "Run,", "WinActivate,",
  "FileAppend,", "URLDownloadToFile,",
  "DllCall(", "RegWrite,", "RegRead,",
  "Hotkey,", "SetKeyDelay,"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("AutoIt3.exe", "AutoHotkey.exe", "AutoHotkeyU64.exe", "AutoHotkeyU32.exe")
    or ProcessCommandLine has_any (AutoITPatterns)
    or ProcessCommandLine has_any (AHKPatterns)
| extend IsAutoIT = FileName =~ "AutoIt3.exe" or ProcessCommandLine has ".au3"
| extend IsAHK = FileName has "AutoHotkey" or ProcessCommandLine has ".ahk"
| extend ScriptFromTemp = ProcessCommandLine has_any ("\\Temp\\", "\\tmp\\", "%TEMP%", "AppData")
| extend NetworkActivity = ProcessCommandLine has_any ("URLDownloadToFile", "_WinHttpSimpleRequest", "Inet")
| extend KeyLogging = ProcessCommandLine has_any ("Hotkey,", "SetKeyDelay,", "Send,", "SendInput,")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         IsAutoIT, IsAHK, ScriptFromTemp, NetworkActivity, KeyLogging
| sort by Timestamp desc
medium severity medium confidence

Detects AutoIT and AutoHotKey script execution using MDE DeviceProcessEvents. Identifies AutoIt3.exe and AutoHotkey.exe execution, scripts running from temp directories (common with malware droppers), network activity via built-in download functions, and keystroke injection/logging patterns.

Data Sources

Process: Process CreationCommand: Command ExecutionMicrosoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives & Tuning

  • IT departments using AutoIT for legitimate desktop automation and software deployment scripts
  • AutoHotKey users with custom keyboard shortcuts and text expansion macros
  • Software testing teams using AutoIT for GUI test automation
Download portable Sigma rule (.yml)

Other platforms for T1059.010


Testing Methodology

Validate this detection against 3 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 1AutoHotKey Script Execution

    Expected signal: Sysmon Event ID 1: Process Create for AutoHotkey.exe with .ahk file in CommandLine. Sysmon Event ID 11: File Create for the .ahk script in Temp directory.

  2. Test 2AutoIT Script Execution

    Expected signal: Sysmon Event ID 1: Process Create for AutoIt3.exe with .au3 file in CommandLine. Sysmon Event ID 11: File Create for the .au3 script in Temp directory.

  3. Test 3AutoIT Compiled Executable Detection

    Expected signal: Sysmon Event ID 1: PowerShell process creation. The script scans for compiled AutoIT executables by checking PE metadata.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections