Detect AutoHotKey & AutoIT in Elastic Security
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/
Elastic Detection Query
sequence by host.name with maxspan=5m
[process where event.type == "start" and (
process.name in~ ("AutoIt3.exe", "AutoHotkey.exe", "AutoHotkeyU64.exe", "AutoHotkeyU32.exe") or
process.args : ("*.au3", "*.ahk") or
process.command_line : ("*AutoIt*", "*AutoHotkey*", "*.au3*", "*.ahk*")
)
| eval is_autoit = process.name == "AutoIt3.exe" or process.command_line like "*.au3*"
| eval is_ahk = process.name like "*AutoHotkey*" or process.command_line like "*.ahk*"
| eval script_from_temp = process.command_line like "*\\Temp\\*" or process.command_line like "*AppData*" or process.command_line like "*%TEMP%*"
| eval network_activity = process.command_line like "*URLDownloadToFile*" or process.command_line like "*_WinHttpSimpleRequest*" or process.command_line like "*Inet*"
| eval key_logging = process.command_line like "*Hotkey,*" or process.command_line like "*SetKeyDelay,*" or process.command_line like "*SendInput,*"
| eval dll_call = process.command_line like "*DllCall(*"
] Detects execution of AutoIT (AutoIt3.exe) and AutoHotKey (AutoHotkey.exe) scripting engines along with suspicious command-line patterns indicating malicious use such as script execution from temp directories, network download functions, keylogging functions, and DLL calls. Covers MITRE ATT&CK T1059.010 as used by DarkGate, Lumma Stealer, APT39, and XLoader.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate IT automation scripts using AutoHotKey for keyboard remapping, window management, or productivity automation deployed by the IT department
- AutoIT-based software installers or legitimate application automation tools used by helpdesk or operations teams
- Software testing frameworks and QA automation pipelines that use AutoIT or AutoHotKey for GUI testing of Windows applications
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.
- 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.
- 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.
- 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.
References (5)
- https://attack.mitre.org/techniques/T1059/010/
- https://www.splunk.com/en_us/blog/security/enter-the-gates-an-analysis-of-the-darkgate-autoit-loader.html
- https://www.autoitscript.com/autoit3/docs/intro/running.htm
- https://www.autohotkey.com/docs/v1/Program.htm
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1059.010/T1059.010.md
Unlock Pro Content
Get the full detection package for T1059.010 including response playbook, investigation guide, and atomic red team tests.