T1497.002 Elastic Security · Elastic

Detect User Activity Based Checks in Elastic Security

Adversaries may employ various user activity checks to detect and avoid virtualization and analysis environments. This includes checking mouse movement speed/frequency, click patterns, browser history and bookmarks, number of files on the desktop or in common directories, recently opened documents, and presence of user-created files. Some malware requires specific user interaction before activating, such as waiting for a document to close, a user to double-click an embedded image, or waiting for mouse button presses. Darkhotel checks mouse cursor position repeatedly, Okrum requires three left-clicks before executing, and FIN7 used embedded images requiring double-clicks to activate.

MITRE ATT&CK

Tactic
Defense Evasion Discovery
Technique
T1497 Virtualization/Sandbox Evasion
Sub-technique
T1497.002 User Activity Based Checks
Canonical reference
https://attack.mitre.org/techniques/T1497/002/

Elastic Detection Query

Elastic Security (Elastic)
eql
process where event.type == "start" and (
  process.command_line regex~ "(?i)(getcursorpos|getlastinputinfo|mouse_event|setcursorpos|getasynckeystate|getforegroundwindow|getdesktopwindow)"
  or (
    process.name in~ ("cmd.exe", "powershell.exe") and
    process.command_line regex~ "(?i)(desktop|recent|downloads|documents)" and
    process.command_line regex~ "(?i)(count|\\.count|find /c|measure-object)"
  )
  or (
    process.name like~ "reg.exe" and
    process.command_line like~ "*recentdocs*"
  )
  or (
    process.command_line regex~ "(?i)(history|bookmarks|cookies|places\\.sqlite)" and
    not process.name regex~ "(?i)(chrome|firefox|msedge|brave|opera)\\.exe"
  )
)
medium severity medium confidence

Detects process execution patterns consistent with user activity enumeration used by malware to identify sandbox or analysis environments (T1497.002). Covers mouse Win32 API calls (GetCursorPos, GetLastInputInfo, mouse_event, SetCursorPos, GetAsyncKeyState), window handle queries (GetForegroundWindow, GetDesktopWindow), file count enumeration on user profile directories via cmd.exe or PowerShell, RecentDocs registry path access via reg.exe, and browser history or bookmarks path access by non-browser executables.

Data Sources

Elastic Endpoint Security agentWinlogbeat with Sysmon module (EventID 1)Auditbeat process dataset

Required Tables

logs-endpoint.events.process-*winlogbeat-*.ds-logs-system.security-*

False Positives & Tuning

  • Legitimate GUI automation frameworks such as AutoHotkey, AutoIt, PyAutoGUI, or Sikuli that invoke GetCursorPos or mouse_event Win32 APIs for UI testing pipelines
  • IT administrator PowerShell scripts that count files in Desktop, Recent, or Downloads folders for storage quota audits or user profile cleanup routines
  • Endpoint DLP or UEBA agents that inspect browser history and bookmark paths to enforce data governance or insider threat detection policies
Download portable Sigma rule (.yml)

Other platforms for T1497.002


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 1Check desktop file count for sandbox detection

    Expected signal: Sysmon Event ID 1: Process Create for cmd.exe with 'dir /b' + Desktop path, piped to find.exe. Two process events generated.

  2. Test 2Check RecentDocs registry for user activity

    Expected signal: Sysmon Event ID 1: Process Create for reg.exe with RecentDocs query. Sysmon Event ID 13: Registry key access event for the RecentDocs path.

  3. Test 3PowerShell mouse position check for sandbox detection

    Expected signal: Sysmon Event ID 1: PowerShell process with GetCursorPos in command line. PowerShell ScriptBlock Log Event ID 4104 with the full P/Invoke code and mouse check logic.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections