Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will take two command line arguments: the name of a single log file (such as the one attached to this assignment) and the

This program will take two command line arguments: the name of a single log file (such as the one attached to this assignment) and the name of an output file.

Read each line of the program in, extract the IP address from the line and determine whether the line is a failed login attempt or valid login attempt.

Look through the logs_processed.txt file. It follows a fairly clear format and indicates "Invalid" whenever a bad attempt is made. Once it identify the invalid line, the IP address should always be in the same position. Make use of String's split method to parse the lines.

Keep track of the number of times a particular IP address fails to login.

The program should then open the output file and print a list of IP addresses to that fail 3 or more times.

A sample command line execution of this file might look like this:

$ java Fail2Ban logs_processed.txt output.txt

The list of IP addresses that have failed 3 or more times should appear in the output.txt file.

The problem provides an empty Fail2Ban.java file to fill in.

logs_processed.txt looks like this

Apr 12 13:07:59 fembot sshd[22146]: Accepted publickey for pblaer from 108.14.56.33 port 58518 ssh2 Apr 12 13:08:17 fembot sshd[22457]: Accepted publickey for pblaer from 108.14.56.33 port 58519 ssh2 Apr 12 13:08:20 fembot sshd[22706]: Accepted publickey for pblaer from 108.14.56.33 port 58520 ssh2 Apr 12 13:19:00 fembot sshd[22978]: Accepted publickey for pblaer from 108.14.56.33 port 58532 ssh2 Apr 12 14:06:54 fembot sshd[23396]: Invalid user admin from 37.72.179.246 Apr 12 14:07:14 fembot sshd[23404]: Invalid user admin from 37.72.179.246 Apr 12 14:07:43 fembot sshd[23408]: Invalid user ftpuser from 37.72.179.246 Apr 12 14:07:57 fembot sshd[23419]: Invalid user PlcmSpIp from 37.72.179.246 Apr 12 14:08:12 fembot sshd[23421]: Invalid user pi from 37.72.179.246

- Please write the Fail2Ban.java

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

\f\f\f

Answered: 1 week ago