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>
Figure 4: Viewing details for each connection with Get-NetTCPConnection on Windows 11.

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.

The Author

Andrea Ciarrocchi is a technology enthusiast. Visit his homepage at https://andreaciarrocchi.altervista.org.

Buy this article as PDF

Download Article PDF now with Express Checkout
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Related content

  • Building a port scanner in Python
    Learn how to develop a simple yet effective port scanner to analyze network security.
  • Internet socket programming in Perl
    Perl sockets work like file handles that can span across a network or the entire Internet.
  • Spanning Tree Protocol
    Ethernet is so popular because it simply works and is inexpensive. However, the administration side looks a bit more complicated: For the network to run smoothly, the admin might need to make important decisions about the Spanning Tree protocol.
  • TCP Stealth hides open ports
    Port scans for finding vulnerable services are nothing new, and port knocking as a defense has been around for a while, too. TCP Stealth tries to do something similar, but it takes a more sophisticated approach. We take a closer look.
  • SoftEther VPN software
    SoftEther is lean VPN software that outpaces the current king of the hill, OpenVPN, in terms of technology and performance.
comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



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.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=