Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The operating system logs many events. One file that contains interesting events is /var/log/auth.log, which shows, in part, unsuccessful logins to your system. Some lines

The operating system logs many events. One file that contains interesting events is /var/log/auth.log, which shows, in part, unsuccessful logins to your system. Some lines of the file will look like this:

May 26 07:29:20 instance-1 sshd[20327]: Disconnected from 61.147.247.146 port 45177 [preauth] May 26 07:32:22 instance-1 sshd[20351]: Invalid user nagios from 159.65.144.233 port 49715 May 26 07:32:22 instance-1 sshd[20351]: input_userauth_request: invalid user nagios [preauth] May 26 07:32:23 instance-1 sshd[20351]: Received disconnect from 159.65.144.233 port 49715:11: Normal Shutdown, Thank you for playing [preauth]

Your task in this exercise is to write a python program to read the lines of data from this file, and print out a sorted list of invalid user names to the screen, one per line, like the partial list shown below.

aD-min.123 admin admin admin admin admin admin backups  web3 zabbix zabbix zabbix zimbra

This isnt a long program. Depending on how verbose your code is, it should be done in 10-25 lines.

  1. A general outline of this program is to

Open the file

For each line in the file

Find if this line contains an invalid user name

If it does, add the name to a list of names

When all lines have been processed, sort the list

Print each element in the list to the screen on a separate line

  1. Finding the invalid user name is the hardest part of this assignment. The easiest thing to do is use the string function find(), to see if the string Invalid user is in the line. The return value tells you where this string is and then you can fiddle with the line from that point on to get the actual name that is invalid.
  2. Be sure to comment your code, including a header comment with your name and the date.
  3. Once your program works on your local machine, start your instance from the Cloud Console, then login using the SSH button. From there you can upload your program to your instance. Use the gear icon, then select upload file. The file will end up in your home directory.
  1. Make sure your program still works. Most likely youll have to change the path to the file to be exactly /var/log/auth.log. Your output will be different, since this file is different from the one copied to your local machine. Save your output in a file using output redirection.
  2. Download your output file to your local computer. If you made any changes to your program, download a copy from your instance to your local machine so you can submit it to Canvas.
  3. In a Word document, write a paragraph about what you liked about this assignment, what you disliked or found confusing, and what you do to improve your code if you had another couple of hours to work on it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago