Wednesday, March 16, 2011

How to find listening / open ports on a computer?

So how do I tell if a TCP or UDP network port is open or not?

Microsoft Windows
1. To find open ports on a computer, you can use netstat command line.

Netstat (network statistics) is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics. It is available on Unix, Unix-like, and Windows NT-based operating systems.
It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement.

a. To display all open ports, open DOS command, type netstat and press Enter.
b. To list all listening ports, use netstat -an | find /i "listening" command.
c. To see what ports your computer actually communicates with, use netstat -an | find /i "established"
d. To find specified open port, use find switch. For example, to find if the port 3389 is open or not, do netstat -an | find /i "3389".

Example: Port 3389 is closed / not listening
1. netstat -an | find "3389" command shows nothing

2.1. You can also test by telneting to localhost or 127.0.0.1 at specific port you want to check.
telnet localhost 3389  or   telnet 127.0.0.1 3389

The following error message will popup if the port is closed / not listening.
"Connecting To 3389...Could not open connection to the host, on port 23: Connect failed"


Example: Port is open / listening
1. netstat -an | find "3389" command shows "LISTENING" message

2.1. You can also test by telneting to localhost or 127.0.0.1 at specific port you want to check.
telnet localhost 135 or telnet 127.0.0.1 135

2.2. Once you press enter, a blank screen as image below shows that the port is listening.

e. You can use PULIST from the Windows Resource Kit to find which process is using a specified port. For example, pulist | find /i "4125" may display

Process PID User
mad.exe 4125 Chicagotech/blin

Or you can use tasklist to find PID.

Reference:
http://en.wikipedia.org/wiki/Netstat
http://nixcraft.com/getting-started-tutorials/622-windows-how-do-i-tell-if-tcp-network-port-open-not.html
http://www.speedguide.net/faq_in_q.php?qid=115
http://www.howtonetworking.com/command/openport1.htm
http://www.techrepublic.com/blog/security/list-open-ports-and-listening-services/443

Related post:

Related Posts with Thumbnails