Discovery · Windows · LOLBAS
query.exe
Query
Front end for query user, session, process and termserver. It calls the matching helper binary from its own folder, so a copy outside System32 is worth checking.
Legitimate use
Admins use it to see sessions and processes on terminal servers.
Subcommands
Lists logged-on users. Runs quser.exe.
LowLists sessions. Runs qwinsta.exe.
LowLists processes per session.
LowLists terminal servers in the domain.
LowCommand lines to worry about
- High
query.exe run outside System32
query.exe starts its helper from the folder it runs in. A copy outside System32 or SysWOW64 can start a planted binary of the same name.
Detection regex
^\s*"?(?![a-z]:\\windows\\(system32|syswow64)\\)[^\s"]*\\query(\.exe)?"?\s+(user|session|process)
Where it is recorded
- Security4688Process creation with the full command line, when command-line auditing is enabled.
- Sysmon1Process creation with command line, hashes and parent process.
Community detections
6 SigmaHQ rules for query.exe. The explainer checks every pasted command line against all of them.
- HighSuspicious Child Process Of Manage Engine ServiceDesk
Detects suspicious child processes of the "Manage Engine ServiceDesk Plus" Java web service
T1102by Florian Roth (Nextron Systems)
- HighSuspicious Process By Web Server Process
Detects potentially suspicious processes being spawned by a web server process which could be the result of a successfully placed web shell or exploitation
T1505.003T1190by Thomas Patzke, Florian Roth (Nextron Systems), Zach Stanford @svch0st, Tim Shelton, Nasreddine Bencherchali (Nextron Systems)
- HighSuspicious Processes Spawned by Java.EXE
Detects suspicious processes spawned from a Java host process which could indicate a sign of exploitation (e.g. log4j)
by Andreas Hunkeler (@Karneades), Florian Roth
- HighSuspicious Shells Spawn by Java Utility Keytool
Detects suspicious shell spawn from Java utility keytool process (e.g. adselfservice plus exploitation)
by Andreas Hunkeler (@Karneades)
- HighSuspicious Spool Service Child Process
Detects suspicious print spool service (spoolsv.exe) child processes.
T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)
- MediumQuery Usage To Exfil Data
Detects usage of "query.exe" a system binary to exfil information such as "sessions" and "processes" for later use
by Nasreddine Bencherchali (Nextron Systems)
Rules from SigmaHQ (rules/windows/process_creation), Detection Rule License (DRL) 1.1. Each rule links to its source and credits its authors.