Viewing and killing TCP IP connections Windows
Many time inย troubleshooting or needing to view network traffic information or connection information, seeing your TCP/IP connections in Windows can provide valuable insight into problems or issues that may be going on in Windows with connectivity. ย Also, viewing connection information is a great way to narrow down on possible backdoor traffic to a workstation if malware is suspected. ย In this guide, we want to look at several tools and utilities to both view connection information as well as kill TCP connections in Windows that may be problematic or malicious.
Windows itself has many really nice tools built-in that will enable you to see TCP and UDP connections right out of the box via the commandline. ย Especially the later versions of Windows which include Powershell expand these capabilities as well.
Commandline Tools
Powershell
With powershell we have a whole new array of commandlets to peer inside of and control what is going on with Network connections in Windows. ย There are two commands in generalย among othersย that provide really powerful monitoring inside of Powershell and that is theย get-nettcpconnection andย get-udpendpoint. ย Take a look at the whole list of new powershell commands for monitoring and controlling TCP activity here: ย https://docs.microsoft.com
Get-NetTcpConnection –ย cmdlet gets current TCP connections. Use this cmdlet to view TCP connection properties such as local or remote IP address, local or remote port, and connection state.
Get-NetUDPEndpoint –ย gets current statistics for a UDP endpoint. The cmdlet returns UDP end point properties, such as local and remote UDP ports. If you do not specify any parameters, the cmdlet gets statistics for all UDP end points.
Netstat
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat displays active TCP connections.
Below the command was issuedย netstat -ano
With the PID information you see above in the netstat output, you can use this number to correlate with PID information in Task Manager to identify the exact process and kill if need be.
wkillcx
Wkillcxย is a small command-line utility to close any TCP connection under Windows XP/Vista/Seven as well as Windows Server 2003/2008. ย This is a great little commandline program that allows you to kill the remote IP:port connection information without knowing the PID. ย You simply issue the command, feed the appropriate connection information, it searches for that connection and kills it. ย Download wkillcx here: ย https://wkillcx.sourceforge.net/
syntax : wkillcx [dest_ip:dest_port] wkillcx 10.11.22.23:1234
GUI Tools
Along with the commandline tools included in Windows there are also a couple of really nice GUI tools that allow ones to see TCP activity as well as kill those TCP connections via killing the process that is spawning the TCP connections.
TCPView
TCPView is a Windows SysInternals Tool that is designed to basically showย detailed listings of all TCP and UDP endpoints on your system, including the local and remote addresses and state of TCP connections. ย The download of the utility also includes a commandline version of the tool inย tcpvcon. ย Download TCPView here: ย https://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
Another really nice feature of TCPView is that you can right-click on any connection entry and then Kill the process that is using it:
Microsoftย Message Analyzer 1.0
Microsoft Message Analyzer is a new tool for capturing, displaying, and analyzing protocol messaging traffic and other system messages. ย This is a relatively new tool that also can import data from the legacy Microsoft Network Protocol Analyzer 3.4.
This is a more full blown protocol analyzer, but can do many of the basic things we are referring too in the above guide. ย Download the Microsoft Message Analyzer here: ย https://docs.microsoft.com
Final Thoughts
Using the tools listed above, one can view network connection information via either the commandline or using GUI tools. ย This is extremely helpful when you are tracking down a rogue connection or a problematic process that has network hooks.
Microsoft Message Analyzer 1.0 is no longer available on MS’ website