Skip to content
WETNav

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.

Worst caseHigh

Subcommands

user

Lists logged-on users. Runs quser.exe.

Low
session

Lists sessions. Runs qwinsta.exe.

Low
process

Lists processes per session.

Low
termserver

Lists terminal servers in the domain.

Low

Command 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)

    T1218

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.

  • High
    Suspicious Child Process Of Manage Engine ServiceDesk

    Detects suspicious child processes of the "Manage Engine ServiceDesk Plus" Java web service

    T1102by Florian Roth (Nextron Systems)

  • High
    Suspicious 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)

  • High
    Suspicious 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

  • High
    Suspicious Shells Spawn by Java Utility Keytool

    Detects suspicious shell spawn from Java utility keytool process (e.g. adselfservice plus exploitation)

    by Andreas Hunkeler (@Karneades)

  • High
    Suspicious Spool Service Child Process

    Detects suspicious print spool service (spoolsv.exe) child processes.

    T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)

  • Medium
    Query 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.