Finding Which Process Sent an Outbound Traffic Spike
A network monitor that alerts on an outbound traffic spike shows the interface and the rate, but the alert doesn't say which program on the host sent the traffic. This post covers how to find the process while the spike is happening on Linux and Windows, how to keep a record of outbound connections per process so you can look one up after an alert, and where ET Ducky records the same thing.
A recent r/sysadmin thread asks how to build monitoring that finds root causes, with Prometheus and Grafana watching a 1 Gbit link and an alert planned for suspicious outbound spikes. The replies cover traffic baselines, sFlow, and an IDS on the firewall. Tying a spike on a host to the process that caused it is the step left to cover.
Find the process during the spike on Linux
Run nethogs as root on the interface to watch sent and received traffic per process while the spike is happening. It is packaged as nethogs in most distributions.
sudo nethogs eth0
Existing TCP connections can be listed with ss, along with the process that owns each one and its internal TCP counters.
sudo ss -tnpi state established
The users: field holds the program name and PID. The bytes_acked counter is the number of bytes the remote side has acknowledged on that connection. Run the command twice, a minute apart, and compare bytes_acked for each connection to find the one that is growing fastest.
Find the process during the spike on Windows
Open Resource Monitor with resmon.exe, select the "Network" tab, and sort "Processes with Network Activity" by "Send (B/sec)".
For a list you can script, match each established TCP connection to its owning process in PowerShell.
Get-NetTCPConnection -State Established | Select-Object LocalAddress,RemoteAddress,RemotePort,OwningProcess
Match the OwningProcess value to the PID column in Task Manager, or pass it to Get-Process -Id to get the program name.
Keep a record you can check after the alert
A spike is often over before anyone opens a shell on the host. Logging each outbound connection with the process that opened it lets you look up the program after the alert fires.
Log outbound connections on Linux with auditd
Add an audit rule on the connect system call with a key, and search the records by that key around the time of the alert.
sudo auditctl -a always,exit -F arch=b64 -S connect -k netconn sudo ausearch -k netconn -ts today -i
Each SYSCALL record has the program in its exe= field and the login user in auid=. With -i, the SOCKADDR record that goes with it shows the address and port the program connected to as text. Add -x with a program name to the ausearch command when you already suspect one program.
A rule added with auditctl is gone after a reboot. Put the same rule in a file under /etc/audit/rules.d/ to keep it. The rule records every connect call on the host, so check the audit log volume on a busy server before you leave it on.
Log outbound connections on Windows
Windows can log each permitted connection in the Security log as event 5156, "The Windows Filtering Platform has permitted a connection." Turn on success auditing for the Filtering Platform Connection subcategory.
auditpol /set /subcategory:"Filtering Platform Connection" /success:enable
Microsoft's page on this subcategory rates its event volume as high, with one event for every connection made to or from the system. Turn it on for the hosts you are investigating. Read the outbound events from the last hour.
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=5156; StartTime=(Get-Date).AddHours(-1)} | Where-Object { $_.Message -match 'Outbound' } | Select-Object TimeCreated,Message
Each event has an "Application Name" with the full path of the program, a "Direction", a "Destination Address", and a "Destination Port". The event 5156 reference notes that the "Process ID" is in hexadecimal, so convert it to decimal before you compare it with Task Manager.
Sysmon is the other option on Windows. Its event ID 3 records TCP and UDP connections with the process that made them. It stays off until the Sysmon configuration file has a NetworkConnect section. Install Sysmon with that configuration, and read the connections around the time of the alert.
sysmon -accepteula -i config.xml
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Sysmon/Operational'; Id=3} -MaxEvents 50 | Select-Object TimeCreated,Message
The Sysmon page has an example NetworkConnect filter that includes and excludes connections by port and by program.
Match the connections to the spike
Line up the connection times from the log with the start and end of the spike on the monitor. Start with the program that opened the most connections in that window, and check the destination addresses it connected to.
Where ET Ducky shows it
I build ET Ducky. Its agent reads process and network connect events from the kernel with ETW on Windows and eBPF on Linux. It attributes every outbound connection to the process that opened it. Every alert gets a root-cause analysis backed by the kernel events on that host.
On a Windows host you'd start a Live Session to investigate further. The AI picks which ETW providers to read in each round. Only counts-only summaries leave the host. One of the built-in behavioral rules covers unusual outbound connections from system daemons. Beyond the built-in rules, you can create custom rules using a rule builder to monitor for events that are unique in your environment.
Try it on one server
One Windows or Linux server costs $5 a month with no query subscription.
See pricing