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.
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.
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 http://www.iana.org/assignments/port-numbers.
Getting Started: Begin by familiarizing yourself with the Nmap software. A simple starting point is to scan your machine, aka, localhost, via "nmap 127.0.0.1". Another useful resource is telnet will allow you to interact with a server using a plain text command line. For example, "telnet burrow.cs.indiana.edu 22" will allow you to connect to the SSH service running on burrow.cs.indiana.edu on port 22. burrow.cs.indiana.edu 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, http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html 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:
The grading will be based on the following three deliverables, all of which are due by 11:55pm on the due date: