CT 320: Network and Systems Administration
Group Work, COMSC 315 Lab
The purpose of this assignment is to learn about network security by writing a Python port scanner that detects which network ports are open on a system, and by using the same program to gather statistics on multiple systems.
For this assignment you will turn in a program called Scanner.py
that
checks network ports to see if a server has the port open for use by a
service. The program has the following command line options:
./Scanner.py -a <host> -p <port> -f <filename> -h <page>
The <host> parameter is an IP address or host name, the <port> parameter is a number between 0 and 65535 or ‘all’, the <filename> parameter is a text file with host names, and the <page> parameter is the page to be fetched via HTTP.
Implement scanning of a single port using the following command:
./Scanner.py -a <host> -p <port>
Use a function to scan the specified address and port, as follows:
def scan_server(address, port):
The function should create a socket and connect to the host on the specified port. If the connection is accepted the function should return true, else it should return false. The function should also print “Connected to server <host> on port <port>.” to standard error. Do not print anything if no connection is established. Test the program on the www.cs.colostate.edu server, port 80.
Implement scanning of all ports using the following command:
./Scanner.py -a <host> -p all
Make the program loop through all ports between 0 and 1023 on the specified system. You should set the socket timeout to a small number such as 0.05s. Test on www.cs.colostate.edu (server), waters.cs.colostate.edu (workstation), and localhost to see which ports are open. Explain which ports are open on these three systems and which protocols they support. Try disabling a service on localhost and see how the list of open ports changes.
Change Scanner.py
to optionally read:
./Scanner.py -f <file> -p <port>
The program should scan all the ports on each system in the file, and return statistics on the number of open ports across all systems. Test the program using an input file with the following:
www.cs.colostate.edu www.math.colostate.edu www.physics.colostate.edu www.languages.colostate.edu www.maps.colostate.edu www.csurams.com www.admissions.colostate.edu www.ramct.colostate.edu
The program should print accumulated statistics for all of the ports between 0 and 1023 for all of the above servers. Do not print ports that have no open connections on any of the systems. Here is the sample output:
<number> systems had port <port> open.
Add a command to Scanner.py
that connects to the specified
host and port and sends an HTTP request for the specified <page>. Write
the code that receives the return HTTP message and parses it, displaying
only the HTM data returned. Test the command on
www.cs.colostate.edu/~ct320. The command syntax should be extended to
specify the server page desired using the ‘h’ option, as shown below.
./Scanner.py -a <host> -p <port> -h <page>
Submit your Scanner.py
file into the drop box on RamCT for
Recitation 8 (R8).
Modified: 2013-11-10T10:50 User: Guest Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |