Detect User Activity Based Checks in Sumo Logic CSE
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/
Sumo Detection Query
_sourceCategory=*windows*sysmon* OR _sourceCategory=*wineventlog*security*
| where EventID = 1 OR EventCode = 1
| parse regex "(?i)<Data Name='CommandLine'>(?<CommandLine>[^<]+)" nodrop
| parse regex "(?i)<Data Name='Image'>(?<Image>[^<]+)" nodrop
| parse regex "(?i)<Data Name='ParentImage'>(?<ParentImage>[^<]+)" nodrop
| parse regex "(?i)<Data Name='User'>(?<User>[^<]+)" nodrop
| parse regex "(?i)<Data Name='ParentCommandLine'>(?<ParentCommandLine>[^<]+)" nodrop
| eval cmd_lower = toLowerCase(CommandLine)
| eval img_lower = toLowerCase(Image)
| eval mouse_check = if(matches(cmd_lower, "(?i)(getcursorpos|getlastinputinfo|mouse_event|setcursorpos|getasynckeystate)"), 1, 0)
| eval window_check = if(matches(cmd_lower, "(?i)(getforegroundwindow|getdesktopwindow)"), 1, 0)
| eval file_count_check = if(matches(cmd_lower, "(?i)(desktop|recent|downloads|documents)") and matches(cmd_lower, "(?i)(count|\.count|find /c|measure-object|wc -l)"), 1, 0)
| eval recentdocs_check = if(matches(cmd_lower, "(?i)recentdocs"), 1, 0)
| eval browser_history_check = if(matches(cmd_lower, "(?i)(history|bookmarks|cookies|places\.sqlite)") and !matches(img_lower, "(?i)(chrome|firefox|msedge|brave|opera)\.exe"), 1, 0)
| eval suspicion_score = (mouse_check * 2) + (window_check * 2) + file_count_check + recentdocs_check + browser_history_check
| where suspicion_score > 0
| fields _messageTime, Computer, User, Image, CommandLine, ParentImage, ParentCommandLine, mouse_check, window_check, file_count_check, recentdocs_check, browser_history_check, suspicion_score
| sort by _messageTime desc Sumo Logic detection for T1497.002 using Sysmon EventID 1 (Process Create) events. Parses XML-structured Sysmon event payloads to extract CommandLine, Image, ParentImage, and User fields, then applies a weighted suspicion scoring model across five user activity enumeration subcategories. Events scoring above zero are surfaced for analyst triage. Requires Sysmon deployed with a configuration that captures command line data.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate Robotic Process Automation workflows using AutoHotkey, Sikuli, or WinAppDriver that programmatically invoke mouse and window Win32 APIs during UI-driven automation
- Scheduled PowerShell tasks executed by endpoint management tooling that count files in Desktop or Downloads directories as part of periodic housekeeping or telemetry collection
- Browser migration utilities or password managers that read browser history, cookies, or bookmarks paths during profile import or credential synchronisation operations
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.