Lab Assignment

Be sure to include your name and the name of this lab when it is submitted, via email, to the instructor's email address. Acceptable formats are text files, html files and pdf's. Do not send MS Word or OpenOffice.org documents.
Total assignment value: 25 points
  1. (5 points) build a shell script which will pull out all the IP addresses from all lines which contain the words 'Invalid user' from the file linked after this question. It should then run nmap -O against each of them, appending the output of that command into a file named 'dummy_nmapscan.txt'.
  2. sample messages file (from http://ccis2161.linux-classes.com/sample_files/messages)
  3. (2 points) now enhance your script so that it removes all duplicates and sorts them numerically.
  4. (5 points) Further enhance the above script so that it removes any of the IP addresses stored in a file named /etc/firewall/whitelist.
  5. sample data file for previous question (from http://ccis2161.linux-classes.com/sample_files/whitelist)
  6. (3 points) enhance your script to automatically block each IP using the following IP tables command: /sbin/iptables -I INPUT -i eth1 -s IP_ADDRESS -d 0.0.0.0/0 -j DROP
  7. (10 points) Write a shell script which presents the user with a menu which allows them the following options:
    1. check load average
    2. display all blocked IP addresses (from the previous questions)
    3. display all whitelisted IP addresses
    4. rescan logfiles and re-run the blocking script you wrote above
    5. logout
    You can assume the user which runs it already has sudo permission to perform all of these tasks.
  8. Extra Credit

  9. (3 points) Write a shell script which asks for a username. Once the user enters a valid username, have it track down and terminate all processes owned by that user. Ensure that the script will not accept 'root' as an argument, and that it will check to ensure that the user entered really does exist on the system (check out the 'id' command for an easy way to do that.
  10. (2 points) Keep a count of how many IP addresses have been blocked by your script above, and display only the total at the end of script execution