// question

A user launched a Windows command prompt and executed a built-in utility to enumerate all active network connections. Using process creation logs, identify the exact tool that produced the list of current connections.

Reference KQL answer and model-by-model comparison.

0940a971-809a-48f1-9c4d-b1d785e96ee5
question id
18/23
models correct
1
valid answer
78%
success rate
// reference answer

Human-validated correct answer for this question.

netstat
// model comparison
ModelAnswerKQL queryStatusTriesTimeCost
gemini-2.5-flash-preview-04-17
netstat
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where InitiatingProcessFileName =~ "cmd.exe"
| where FileName =~ "netstat.exe"
| project Timestamp, DeviceName, InitiatingProcessCommandLine, ProcessCommandLine, AccountName
pass110.38s0.0041
gpt-35-turbo
NETSTAT.EXE
DeviceProcessEvents
| where ActionType == 'ProcessCreated'
| where FileName endswith '.exe' and tolower(FileName) contains 'netstat' // Filter for 'netstat' utility
| extend CommandLine = tolower(InitiatingProcessCommandLine)
| where CommandLine contains 'netstat' // Filter for the specific netstat command
pass12.52s0.0030
gpt-4-turbo-2024-04-09
netstat
DeviceProcessEvents
| where InitiatingProcessFileName == 'cmd.exe' and ProcessCommandLine has 'netstat'
| project DeviceId, DeviceName, AccountName, ProcessCommandLine, TimeGenerated
| distinct DeviceId, DeviceName, AccountName, ProcessCommandLine, TimeGenerated
pass18.65s0.0506
gpt-4.1
NETSTAT.EXE
DeviceProcessEvents
| where FileName =~ "netstat.exe" or FileName =~ "netstat"
| extend Parent = InitiatingProcessFileName
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, Parent, InitiatingProcessCommandLine
| order by TimeGenerated desc
pass15.40s0.0130
gpt-4.1-finetuned
None
let CmdStart = DeviceProcessEvents
| where FileName =~ "cmd.exe"
| summarize arg_min(Timestamp, *) by InitiatingProcessAccountSid, DeviceName, FileName;
let BuiltinTools = dynamic([
  "netstat.exe",
  "net.exe",
  "tasklist.exe"
]);
let OriginalTool =  DeviceProcessEvents
  | join kind=inner
    (
      CmdStart
    )
    on $left.DeviceName == $right.DeviceName, $left.InitiatingProcessAccountSid == $right.InitiatingProcessAccountSid
  | where FileName in (BuiltinTools)
  | summarize arg_min(Timestamp, *) by DeviceName, InitiatingProcessAccountSid, FileName;
OriginalTool
| extend ToConsole = iif(isnotempty(ProcessVersionInfoFileDescription), 1, 0)
| extend Filename = iif(ToConsole == 1, "N/A", tostring(split(ProcessCommandLine, ">", 1)[1])) 
| project-reorder DeviceName, InitiatingProcessAccountSid, FileName, ToConsole, Filename
| sort by DeviceName desc, InitiatingProcessAccountSid
// The query outputs details about the tool found in the cmd.exe process tree, whether output went to the console or file, and the associated machine/user details.
fail583.94s0.0843
gpt-4.1-mini
no answer
no query generatedfail50.00s0.0055
gpt-4.1-nano
netstat
DeviceProcessEvents
| where (FileName endswith 'cmd.exe' or InitiatingProcessFileName endswith 'cmd.exe')
| extend ProcessCmdLine = coalesce(InitiatingProcessCommandLine, ProcessCommandLine)
| where ProcessCmdLine contains 'netstat' or ProcessCmdLine contains '/netstat'
| project TimeGenerated, DeviceName, InitiatingProcessFileName, ProcessCmdLine, InitiatingProcessId
| order by TimeGenerated desc
pass425.25s0.0014
gpt-4o
netstat
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where InitiatingProcessCommandLine has_any ("netstat", "nbtstat")
| extend ToolName = iff(InitiatingProcessCommandLine has "netstat", "netstat", iff(InitiatingProcessCommandLine has "nbtstat", "nbtstat", ""))
| project TimeGenerated, InitiatingProcessAccountName, InitiatingProcessCommandLine, ToolName
pass220.23s0.0402
gpt-5-high
netstat.exe
DeviceProcessEvents
| where ActionType == "ProcessCreated"
// Focus on tools that enumerate current connections
| where tolower(FileName) in ("netstat.exe","powershell.exe","netsh.exe")
   or ProcessCommandLine has_any ("netstat","Get-NetTCPConnection","Get-NetUDPEndpoint","show tcpconnections","show tcp")
// Keep only executions that actually map to connection enumeration
| where (
        tolower(FileName) == "netstat.exe"
     ) or (
        tolower(FileName) == "powershell.exe" and ProcessCommandLine has_any ("Get-NetTCPConnection","Get-NetUDPEndpoint")
     ) or (
        tolower(FileName) == "netsh.exe" and ProcessCommandLine has_any ("show tcpconnections","show conn","show connections","show tcp")
     )
// Ensure it was launched from Windows Command Prompt (cmd) context
| where tolower(InitiatingProcessFileName) in ("cmd.exe","conhost.exe")
    or tolower(InitiatingProcessParentFileName) == "cmd.exe"
    or InitiatingProcessCommandLine has @"\cmd.exe"
// Identify the exact tool
| extend ExactTool = case(
        tolower(FileName) == "netstat.exe", "netstat.exe",
        tolower(FileName) == "powershell.exe" and ProcessCommandLine has "Get-NetTCPConnection", "PowerShell:Get-NetTCPConnection",
        tolower(FileName) == "powershell.exe" and ProcessCommandLine has "Get-NetUDPEndpoint", "PowerShell:Get-NetUDPEndpoint",
        tolower(FileName) == "netsh.exe", "netsh.exe",
        "Unknown")
| project TimeGenerated, DeviceName, AccountDomain, AccountName, ExactTool,
          FileName, ProcessCommandLine,
          ParentProcess=InitiatingProcessFileName, ParentCommandLine=InitiatingProcessCommandLine,
          PID=ProcessId, ParentPID=InitiatingProcessId, ReportId
| order by TimeGenerated desc
pass2216.65s0.1036
gpt-5-mini-high
no answer
no query generatedfail50.00s0.0265
gpt-5-mini-low
netstat
let network_tools = dynamic(["netstat","get-nettcpconnection","get-netudpendpoint","ipconfig","arp","route","nbtstat","ss"]);

// Process creation observations
let DPE = DeviceProcessEvents
| where (tolower(InitiatingProcessFileName) has "cmd.exe" or tolower(InitiatingProcessFileName) has "powershell.exe" or tolower(InitiatingProcessFileName) has "pwsh.exe")
| where (tolower(FileName) has_any (network_tools) or tolower(ProcessCommandLine) has_any (network_tools))
| extend Source = "DeviceProcessEvents", ObservedTime = TimeGenerated, ToolFileName = FileName, ToolCommandLine = ProcessCommandLine, ParentFileName = InitiatingProcessFileName, ParentCommandLine = InitiatingProcessCommandLine, ToolPID = ProcessId, Account = AccountName;

// Generic device events that may include command lines
let DE = DeviceEvents
| where (tolower(InitiatingProcessFileName) has "cmd.exe" or tolower(InitiatingProcessFileName) has "powershell.exe" or tolower(InitiatingProcessFileName) has "pwsh.exe")
| where isnotempty(ProcessCommandLine) and tolower(ProcessCommandLine) has_any (network_tools)
| extend Source = "DeviceEvents", ObservedTime = TimeGenerated, ToolFileName = FileName, ToolCommandLine = ProcessCommandLine, ParentFileName = InitiatingProcessFileName, ParentCommandLine = InitiatingProcessCommandLine, ToolPID = coalesce(ProcessId, InitiatingProcessId), Account = AccountName;

union DPE, DE
| extend DetectedTool = case(
    tolower(ToolFileName) has "netstat" or tolower(ToolCommandLine) has "netstat", "netstat",
    tolower(ToolFileName) has "ipconfig" or tolower(ToolCommandLine) has "ipconfig", "ipconfig",
    tolower(ToolCommandLine) has "get-nettcpconnection" or tolower(ToolCommandLine) has "get-netudpendpoint", "Get-NetTCPConnection/UDPEndpoint",
    tolower(ToolCommandLine) has "arp", "arp",
    tolower(ToolCommandLine) has "route", "route",
    tolower(ToolCommandLine) has "nbtstat", "nbtstat",
    tolower(ToolCommandLine) has "ss", "ss",
    "other"
)
| summarize Count = count(), FirstSeen = min(ObservedTime), LastSeen = max(ObservedTime) by DeviceName, Account, ParentFileName, ParentCommandLine, ToolFileName, ToolPID, DetectedTool, Source
| project DeviceName, Account, InitiatingProcess = ParentFileName, InitiatingCommandLine = ParentCommandLine, ToolFileName, DetectedTool, ToolPID, Source, FirstSeen, LastSeen, Count
| order by LastSeen desc
pass241.34s0.0091
gpt-5-mini-medium
no answer
no query generatedfail50.00s0.0134
gpt-5-nano-high
NETSTAT.EXE
DeviceProcessEvents
| where InitiatingProcessFileName contains_cs "cmd.exe"
| where (FileName contains_cs "netstat" or ProcessCommandLine contains_cs "netstat" or InitiatingProcessCommandLine contains_cs "netstat")
| extend Tool = FileName
| project TimeGenerated, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, Tool
| distinct TimeGenerated, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, Tool
pass4101.68s0.0068
gpt-5-nano-medium
no answer
no query generatedfail50.00s0.0079
grok-3-beta
netstat
DeviceProcessEvents
| where InitiatingProcessFileName =~ 'cmd.exe'
| where FileName in~ ('netstat.exe', 'ipconfig.exe', 'arp.exe')
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, ProcessCreationTime, InitiatingProcessAccountName
| order by Timestamp desc
pass221.83s0.0383
grok-3-mini-beta
netstat
DeviceProcessEvents
| where ProcessCommandLine contains 'netstat'
| project TimeGenerated, DeviceName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
| order by TimeGenerated desc
| limit 10
pass220.14s0.0031
o1-high
NETSTAT.EXE
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where InitiatingProcessFileName =~ "cmd.exe"
| where FileName =~ "netstat.exe"
| project TimeGenerated, DeviceName, AccountName, InitiatingProcessAccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
pass133.42s0.2441
o1-low
netstat
DeviceProcessEvents
| where ActionType == "ProcessCreated"
| where InitiatingProcessFileName =~ "cmd.exe"
| where FileName =~ "netstat.exe"
| project TimeGenerated, DeviceName, FolderPath, InitiatingProcessAccountDomain, InitiatingProcessAccountName, FileName, ProcessCommandLine
| order by TimeGenerated desc
pass117.17s0.1590
o3-high
netstat
// "Who ran netstat to list current network connections?"
DeviceProcessEvents
| where ActionType == "ProcessCreated"
// --- Identify the utility ----------------------------------------------------
| where FileName =~ "netstat.exe" or ProcessCommandLine has "netstat"
// --- (Optional) keep only typical listing switches --------------------------
| where ProcessCommandLine has_any (" -a", " -an", " -ano", " -b", " -n", " -o")
// --- Basic enrichment --------------------------------------------------------
| extend ParentProcess   = tostring(InitiatingProcessFileName),
         ParentCmdLine   = tostring(InitiatingProcessCommandLine),
         User            = strcat(AccountDomain, "\\", AccountName)
// --- Output -----------------------------------------------------------------
| project TimeGenerated,
          DeviceName,
          User,
          FileName,
          ProcessCommandLine,
          ParentProcess,
          ParentCmdLine,
          SHA256,
          InitiatingProcessSHA256,
          IsProcessElevated = iff(ProcessTokenElevation == "Elevated", true, false)
| order by TimeGenerated desc
pass131.17s0.0344
o3-mini-high
netstat
DeviceProcessEvents
| where InitiatingProcessFileName =~ "cmd.exe"
  and ProcessCommandLine has "netstat"
| extend ToolExecuted = tostring(split(ProcessCommandLine, ' ')[0])
| project TimeGenerated, DeviceName, FileName, ProcessCommandLine, InitiatingProcessFileName, ToolExecuted
| order by TimeGenerated desc
pass110.27s0.0100
o3-mini-low
netstat
DeviceProcessEvents
| where InitiatingProcessFileName =~ "cmd.exe" and FileName =~ "netstat.exe"
| project TimeGenerated, DeviceName, InitiatingProcessAccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine, ProcessCreationTime
pass125.81s0.0079
o4-mini-high
netstat.exe
DeviceProcessEvents
| where tolower(InitiatingProcessFileName) == "cmd.exe"
| where tolower(FileName) == "netstat.exe"
      or ProcessCommandLine has_any ("netstat", "Get-NetTCPConnection")
| project TimeGenerated,
          DeviceName,
          AccountName,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          ChildProcessFileName = FileName,
          ChildProcessCommandLine = ProcessCommandLine
| order by TimeGenerated desc
pass274.57s0.0198
o4-mini-low
netstat
DeviceProcessEvents
| where InitiatingProcessFileName == "cmd.exe"
// Filter to child processes of cmd.exe that enumerate network connections
| where ProcessCommandLine contains "netstat"
// Select relevant details to identify the tool and context
| project TimeGenerated, DeviceName, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine
pass131.35s0.0123