T1497.002

User Activity Based Checks

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.

Microsoft Sentinel / Defender
kusto
let UserActivityAPIs = dynamic(["GetCursorPos", "GetLastInputInfo", "GetForegroundWindow", "GetAsyncKeyState", "GetKeyState", "mouse_event", "SetCursorPos", "GetDesktopWindow"]);
let UserActivityChecks = dynamic(["RecentDocs", "Recent", "Desktop", "Favorites", "Bookmarks", "History", "Cookies", "Downloads"]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (UserActivityAPIs)
    or (FileName in~ ("cmd.exe", "powershell.exe") and ProcessCommandLine has_any ("dir /b", "Get-ChildItem") 
        and ProcessCommandLine has_any ("Desktop", "Recent", "Downloads", "Documents") 
        and ProcessCommandLine has_any ("count", ".Count", "find /c", "Measure-Object"))
    or (FileName =~ "reg.exe" and ProcessCommandLine has "RecentDocs")
| extend MouseCheck = ProcessCommandLine has_any ("GetCursorPos", "GetLastInputInfo", "mouse_event", "SetCursorPos")
| extend WindowCheck = ProcessCommandLine has_any ("GetForegroundWindow", "GetDesktopWindow")
| extend FileCountCheck = ProcessCommandLine has_any ("Desktop", "Recent", "Downloads") and ProcessCommandLine has_any ("count", ".Count", "find /c", "Measure-Object")
| extend RecentDocsCheck = ProcessCommandLine has "RecentDocs"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         MouseCheck, WindowCheck, FileCountCheck, RecentDocsCheck
| sort by Timestamp desc
medium severity low confidence

Data Sources

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

Required Tables

DeviceProcessEvents

False Positives

  • Accessibility tools and automation software that track mouse position for user interface automation
  • RPA (Robotic Process Automation) tools like UiPath that monitor user input state
  • Custom IT scripts that count files in user directories for compliance or cleanup purposes
  • Screen recording or remote desktop software that tracks input events

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