Detect User Activity Based Checks in Splunk
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/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| eval CommandLine=lower(CommandLine)
| eval MouseActivityCheck=if(match(CommandLine, "(getcursorpos|getlastinputinfo|mouse_event|setcursorpos|getasynckeystate)"), 1, 0)
| eval WindowActivityCheck=if(match(CommandLine, "(getforegroundwindow|getdesktopwindow)"), 1, 0)
| eval FileCountCheck=if(match(CommandLine, "(desktop|recent|downloads|documents)") AND match(CommandLine, "(count|\.count|find /c|measure-object|wc -l)"), 1, 0)
| eval RecentDocsCheck=if(match(CommandLine, "recentdocs"), 1, 0)
| eval BrowserHistoryCheck=if(match(CommandLine, "(history|bookmarks|cookies|places\.sqlite)") AND NOT match(Image, "(?i)(chrome|firefox|msedge|brave|opera)"), 1, 0)
| eval SuspicionScore=MouseActivityCheck*2 + WindowActivityCheck*2 + FileCountCheck + RecentDocsCheck + BrowserHistoryCheck
| where SuspicionScore > 0
| table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine, MouseActivityCheck, WindowActivityCheck, FileCountCheck, RecentDocsCheck, BrowserHistoryCheck, SuspicionScore
| sort - _time Detects user activity-based sandbox evasion via Sysmon process creation events. Identifies mouse/input activity checks, foreground window API usage, file count enumeration in user directories, RecentDocs registry queries, and browser history access by non-browser processes. Lower confidence due to overlap with legitimate automation tools.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Accessibility and automation software tracking mouse position
- RPA tools monitoring user input state
- IT scripts counting files for compliance/cleanup
- Remote desktop and screen sharing software
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.
- 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.
- 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.
- 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.
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.