« Previous 1 2
Modern network diagnostics on Windows and Linux
Hall Monitor
Identifying Potential Threats
Get-NetTCPConnection can be used to identify unusual or suspicious connections in much the same way you would use ss on Linux.
To obtain similar information on Windows, you can use Get-NetTCPConnection to display details about the active TCP connections and their associated states. By default, Get-NetTCPConnection shows connections in a variety of states (e.g., Established
, Listen
, SynSent
, and CloseWait
). The State field is crucial for spotting unusual patterns that might indicate an attack or abnormal behavior, like an excessive number of connections in a SYN_SENT
state, which could suggest a SYN flood attack.
If you want to see all active TCP connections, you would run the PowerShell command
Get-NetTCPConnection
which lists all TCP connections, including information such as the local address, local port, remote address, remote port, and state of the connection. To filter the results by a specific state or look for connections in the Established state, you could use the command
Get-NetTCPConnection | Where-Object { $_.State -eq 'Established' }which returns only the currently established connections, helping you identify active connections to and from your system.
If you're interested in seeing which process is associated with each connection, the Get-NetTCPConnection cmdlet reveals the owning PID. By correlating the PID with running processes (with the Get-Process cmdlet), you can determine which program is using a specific connection. To display this information, run,
Get-NetTCPConnection | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State, OwningProcess
which shows the local and remote addresses, the ports involved, the state of the connection, and the PID for each connection (Figure 4). Once you have the PID, you can further investigate the associated process:
Get-Process -Id <PID>
This information lets you track down any suspicious or unknown processes that might be associated with unusual network connections, much as you would use ss -p on Linux.
To filter out specific connections by remote address, local port, or other criteria, you can adjust the Where-Object filter. For example, if you wanted to see all connections on port 80 (HTTP), you could run
Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 80 }to filter the connections to show only those on port 80. This information might be useful if you're monitoring web traffic.
Conclusion
Both ss on Linux and Get-NetTCPConnection on Windows offer powerful capabilities for monitoring network connections and identifying potential security threats. By leveraging these tools, system administrators and security professionals can gain valuable insights into the state of active connections, detect abnormal patterns, and quickly identify processes that could be linked to malicious activity.
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
