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.
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 Data Sources
Required Tables
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
References (6)
- https://attack.mitre.org/techniques/T1497/002/
- https://www.fireeye.com/blog/threat-research/2017/04/fin7-phishing-lnk.html
- https://unit42.paloaltonetworks.com/unit42-sofacy-continues-global-attacks-wheels-new-cannon-trojan/
- https://www.sans.org/reading-room/whitepapers/forensics/detecting-malware-sandbox-evasion-techniques-36667
- https://drive.google.com/file/d/1t0jn3xr4ff2fR30oQAUn_RsWSnMpOAQc/edit
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1497.002/T1497.002.md
Unlock Pro Content
Get the full detection package for T1497.002 including response playbook, investigation guide, and atomic red team tests.