// question

An attacker is suspected of using the Windows shell to enumerate a user’s Internet Explorer bookmarks via the Favorites folder. Identify the exact command they executed to perform this listing.

Reference KQL answer and model-by-model comparison.

727dbcdb-e495-4ab1-a6c4-80c7f77aef85
question id
17/23
models correct
1
valid answer
74%
success rate
// reference answer

Human-validated correct answer for this question.

dir /s /b %USERPROFILE%\Favorites
// model comparison
ModelAnswerKQL queryStatusTriesTimeCost
gemini-2.5-flash-preview-04-17
"cmd.exe" /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where InitiatingProcessFileName in ("cmd.exe", "powershell.exe") or FileName in ("cmd.exe", "powershell.exe")
| where ProcessCommandLine has "Favorites" and (ProcessCommandLine has "dir" or ProcessCommandLine has "Get-ChildItem")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
pass112.63s0.0062
gpt-35-turbo
no answer
no query generatedfail50.00s0.0109
gpt-4-turbo-2024-04-09
"cmd.exe" /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where FileName == 'cmd.exe' or FileName == 'powershell.exe'
| where ProcessCommandLine contains 'Favorites'
| project DeviceName, AccountName, ProcessCommandLine, TimeGenerated
pass113.21s0.0532
gpt-4.1
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine has_any ('dir', 'ls', 'Get-ChildItem')
    and ProcessCommandLine has 'Favorites'
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine, FileName, FolderPath, InitiatingProcessAccountName, InitiatingProcessCommandLine
| order by TimeGenerated desc
pass14.69s0.0119
gpt-4.1-finetuned
"cmd.exe" /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where Timestamp > ago(7d)
| where ProcessCommandLine has "dir" and ProcessCommandLine has "%userprofile%" and ProcessCommandLine has "Favorites"
| distinct ProcessCommandLine, DeviceName, AccountName 
| extend timestamp = now(), AccountCustomEntity = AccountName, HostCustomEntity = DeviceName
pass323.34s0.0253
gpt-4.1-mini
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine has_any ("dir", "ls", "Get-ChildItem")
      and ProcessCommandLine contains "Favorites"
| project TimeGenerated, DeviceName, InitiatingProcessAccountName, ProcessCommandLine
| sort by TimeGenerated desc
pass13.99s0.0022
gpt-4.1-nano
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine contains 'Favorites' and (ProcessCommandLine contains 'dir' or ProcessCommandLine contains 'ls' or ProcessCommandLine contains 'Get-ChildItem')
| where ProcessCommandLine matches regex @'(?:dir\s+.*Favorites|ls\s+.*Favorites|Get-ChildItem\s+.*Favorites)'
| project TimeGenerated, DeviceName, InitiatingProcessFileName, ProcessCommandLine
pass24.44s0.0007
gpt-4o
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine has 'dir' and ProcessCommandLine contains 'Favorites' 
| project TimeGenerated, DeviceName, ProcessCommandLine, AccountDomain, AccountName
pass222.34s0.0253
gpt-5-high
"cmd.exe" /c dir /s /b %USERPROFILE%\Favorites
let favorites_path_rx = @"(?i)(shell:favorites|%userprofile%\\favorites|\\users\\[^\\]+\\favorites|\\documents and settings\\[^\\]+\\favorites)";
let listing_cmd_rx  = @"(?i)\b(dir|tree|ls|gci|get-childitem|for)\b";
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe")
| where ProcessCommandLine matches regex favorites_path_rx
| where ProcessCommandLine matches regex listing_cmd_rx
| project TimeGenerated, DeviceName, AccountDomain, AccountName, FileName, ExactCommand=ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
| order by TimeGenerated asc
pass1105.53s0.0478
gpt-5-mini-high
no answer
no query generatedfail50.00s0.0179
gpt-5-mini-low
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
let procs = DeviceProcessEvents
| where isnotempty(ProcessCommandLine)
| project Source = "DeviceProcessEvents", Timestamp = Timestamp, DeviceName, AccountName, FileName, ProcessId, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine;

let devs = DeviceEvents
| where isnotempty(ProcessCommandLine)
| project Source = "DeviceEvents", Timestamp = Timestamp, DeviceName, AccountName, FileName, ProcessId = coalesce(ProcessId, 0), ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine;

procs
| union devs
| where tolower(ProcessCommandLine) has_any ("favorites", ".url", ".htm", ".html", "get-childitem", "gci", "dir", "tree", "ls", "attrib", "select-string", "for /f", "/s", "/b")
| where FileName in~ ("cmd.exe","powershell.exe","pwsh.exe","explorer.exe","wscript.exe","cscript.exe","rundll32.exe","mshta.exe")
| summarize FirstSeen = min(Timestamp), LastSeen = max(Timestamp), Count = count(), AnyProcessId = any(ProcessId), AnyInitiatingProcess = any(InitiatingProcessFileName) by ProcessCommandLine, FileName, DeviceName, AccountName
| order by LastSeen desc, Count desc
| take 200
| project FirstSeen, LastSeen, Count, DeviceName, AccountName, FileName, AnyProcessId, AnyInitiatingProcess, ProcessCommandLine
pass460.89s0.0161
gpt-5-mini-medium
"cmd.exe" /c dir /s /b %USERPROFILE%\\Favorites
// Look for processes that explicitly reference the Favorites folder AND contain directory-listing verbs/flags
let listing_keywords = dynamic(["dir","tree","ls","gci","get-childitem","get-child","/s","/r","/b","/a","-recurse","--recursive","-name","/ad","/o","/w","/?"]);

let search_proc = DeviceProcessEvents
| where isnotempty(ProcessCommandLine) or isnotempty(InitiatingProcessCommandLine)
| extend Cmd = tostring(coalesce(ProcessCommandLine, InitiatingProcessCommandLine))
| where tolower(Cmd) has "favorites"
| where tolower(Cmd) has_any(listing_keywords)
| project TimeGenerated, DeviceName, AccountDomain, AccountName, InitiatingProcessFileName, ProcessId, ExactCommand = Cmd, ProcessCommandLine, InitiatingProcessCommandLine, FileName, FolderPath;

let search_dev = DeviceEvents
| where isnotempty(ProcessCommandLine) or isnotempty(InitiatingProcessCommandLine)
| extend Cmd = tostring(coalesce(ProcessCommandLine, InitiatingProcessCommandLine))
| where tolower(Cmd) has "favorites"
| where tolower(Cmd) has_any(listing_keywords)
| project TimeGenerated, DeviceName, AccountDomain, AccountName, InitiatingProcessFileName, ProcessId, ExactCommand = Cmd, ProcessCommandLine, InitiatingProcessCommandLine, FileName, FolderPath;

let search_file = DeviceFileEvents
| where isnotempty(InitiatingProcessCommandLine)
| extend Cmd = tostring(InitiatingProcessCommandLine)
| where tolower(Cmd) has "favorites" or tolower(FolderPath) has "favorites" or tolower(FileName) has "favorites"
| where tolower(Cmd) has_any(listing_keywords)
| project TimeGenerated, DeviceName, AccountDomain = InitiatingProcessAccountDomain, AccountName = InitiatingProcessAccountName, InitiatingProcessFileName, ProcessId = InitiatingProcessId, ExactCommand = Cmd, ProcessCommandLine = Cmd, InitiatingProcessCommandLine = Cmd, FileName, FolderPath;

search_proc
| union search_dev, search_file
| order by TimeGenerated desc
| distinct ExactCommand, DeviceName, AccountDomain, AccountName, InitiatingProcessFileName, ProcessId, TimeGenerated
| take 100
pass359.62s0.0154
gpt-5-nano-high
no answer
no query generatedfail50.00s0.0061
gpt-5-nano-medium
no answer
no query generatedfail50.00s0.0073
grok-3-beta
dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where TimeGenerated > ago(30d)
| where ProcessCommandLine contains 'Favorites'
| where InitiatingProcessFileName in ('cmd.exe', 'powershell.exe')
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName
pass19.73s0.0207
grok-3-mini-beta
"cmd.exe" /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine contains 'Favorites' and ProcessCommandLine contains 'dir'
| project Timestamp, DeviceName, ProcessCommandLine
| order by Timestamp desc
| limit 10
pass220.65s0.0029
o1-high
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where ProcessCommandLine has "dir" and ProcessCommandLine has "Favorites"
// Optionally include shell references if relevant:
//| where ProcessCommandLine has "shell:favorites"
| project TimeGenerated, DeviceId, DeviceName, AccountName, ProcessCommandLine
| order by TimeGenerated desc
pass139.39s0.2943
o1-low
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where FileName =~ "cmd.exe" or FileName =~ "powershell.exe"
| where ProcessCommandLine has_all ("dir", "Favorites")
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessCommandLine
| order by TimeGenerated desc
pass135.68s0.2721
o3-high
dir /s /b %USERPROFILE%\Favorites
// Time range placeholder – will be supplied by the calling function
DeviceProcessEvents
| where FileName in~ ("cmd.exe", "powershell.exe")
// Shell commands commonly used to enumerate directory contents
| where ProcessCommandLine has_any ("dir", "Get-ChildItem", "gci", "ls")
// Must also reference the Internet Explorer Favorites folder (literal or env-var form)
| where ProcessCommandLine has_any ("\\Favorites", "%userprofile%\\Favorites", " %userprofile% %", "\"Favorites\"")
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine,
          FolderPath, InitiatingProcessFileName, InitiatingProcessCommandLine
| order by TimeGenerated asc
pass149.65s0.0257
o3-mini-high
no answer
no query generatedfail50.00s0.0374
o3-mini-low
no answer
no query generatedfail50.00s0.0470
o4-mini-high
cmd.exe /c dir /s /b %USERPROFILE%\Favorites
DeviceProcessEvents
| where ProcessCommandLine has "\\Favorites"
| where FileName in ("cmd.exe", "powershell.exe")
| where ProcessCommandLine matches regex @"(?i)\b(dir|ls|tree|get-childitem)\b"
| project TimeGenerated, DeviceName, InitiatingProcessAccountName, FileName, ProcessCommandLine
pass131.61s0.0117
o4-mini-low
"cmd.exe" /c dir /s /b %USERPROFILE%\\Favorites
DeviceProcessEvents
| where FileName in~ ("cmd.exe", "powershell.exe", "explorer.exe")
| where ProcessCommandLine has "Favorites"
| where ProcessCommandLine matches regex @"\b(dir|tree|ls|Get-ChildItem)\b.*Favorites"
| project TimeGenerated, DeviceName, InitiatingProcessAccountName, FileName, ProcessCommandLine
| sort by TimeGenerated asc
pass258.27s0.0159