The osquery process_open_sockets table records processes that currently have open network sockets. Join it with the processes table to attribute a suspicious network connection to a process, including its PID, name, local address and port, and remote address and port. section 6.1.5
Treat its results as a point-in-time view. A query can return no match after a short-lived connection has closed; when investigating periodic beaconing, repeat the query until the connection is active. section 6.1.5
Identify the process behind a suspected beacon
Filter process_open_sockets by remote address and join processes by PID. For connections to 34.125.188.180, repeated querying identifies powershell.exe using local port 54063 to reach remote port 80, linking the observed traffic to a Windows process. section 6.1.5
Listing 6.43 Listing processes connecting to 34.125.188.180
SELECT DISTINCT pos.pid, p.name, pos.local_address, pos.local_port, pos.remote_address, pos.remote_port FROM processes p JOIN process_open_sockets pos USING (pid) WHERE pos.remote_address like "%34.125.188.180%" #1
Use this query pattern to select process and socket fields, join on PID, and filter for a suspected remote address. section 6.1.5
Endpoint socket evidence can also resolve disagreements in telemetry. When Splunk Stream reported a connection involving port 23456, packet capture showed inbound SYN packets followed by local TCP RESET packets because no endpoint service listened on that port; packet capture was trusted over the conflicting event. section 7.1.8
