Project 1: Basic Port Scanner

Assigned: 9/16/10, Due: 10/01/10

Project Goals

Port scanner software can probe machines for open ports. Port scanners are often used by network administrators to verify the security of machines in their network. They are of interest to Internet miscreants as well, since attackers can use them to find machines to compromise simply by probing for software versions with known vulnerabilities. An example of a well known, open source port scanner is Nmap. In this project you will create a stripped down port scanner, written for network administrators interested in ensuring that machines on their network run only expected services. During this project, you will also gain experience with basic socket programming.

Note: We may be building another programming project based on this basic port scanner later in the semester, so make sure that you do a good job at writing this one.

Project Specification

The basic idea behind a port scanner is simple: Given an IP address of a machine and a list of interesting ports to scan, the scanner will connect on each port using TCP sockets, make a determination of whether or not the port is open based on success of the connection request and close the socket before moving on to the next port to scan. It will then repeat the process for UDP sockets.

Specifics of Expected Port Scanner Functionality:

Your scanner should run on CS Linux machines and you must write it in C/C++. An administrator would invoke it as: "./portScanner [option1, ..., optionN]". Implement the following options:

Details of each option are given below:

Output: After each invocation, the portScanner should output a succinct summary of the list of open TCP and UDP ports on each IP address. Additionally, for each open port, it will include the name of the service that is likely running. To find services associated with ports [1-1024], visit

Resources and Restrictions

Getting Started: Begin by familiarizing yourself with the Nmap software. A simple starting point is to scan your machine, aka, localhost, via "nmap". Another useful resource is telnet will allow you to interact with a server using a plain text command line. For example, "telnet 22" will allow you to connect to the SSH service running on on port 22. will respond by telling you a bit about the SSH service and will wait for you to send the appropriate authentication.

Implementation Specifics:As stated earlier, you are required to use either C or C++ for this assignment. Additionally, you must use the native Linux/BSD socket system calls to open TCP and UDP sockets. You may not use other socket libraries. No credit will be given to solutions that do not adhere to these requirements. These restrictions are being made so you become familiar with the details of lower-level socket programming.

Other Resources: As always, you are encouraged to avail yourself to Internet resources and Linux manual pages when completing the assignment. Socket tutorials such as, will be helpful in understanding socket programming. However, you must ensure you write your own code and that you cite what resources you use, including web tutorials and discussions with individuals outside of your group.

Roadmap:Build your program incrementally. Here is a road-map to use:

  1. Get your program to scan one TCP port on an IP address and display the entire output on the screen.
  2. Expand the program to scan TCP ports in a loop.
  3. Add scanning of UDP sockets.
  4. Add functionality for options related to IP addresses and ports to scan.

Deliverables and Grading

The grading will be based on the following three deliverables, all of which are due by 11:55pm on the due date: