Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have been hired as a threat detection analyst for a bank. Part of your job is inspecting IP logs to try to find any

You have been hired as a threat detection analyst for a bank. Part of your job is inspecting IP logs
to try to find any potential security threats.
An IP version 4 address contains 4 octets of numbers between 0 and 255. They are in a format
such as:
192.116.234.122
For purposes of this lab, all the IPv4 addresses have the full octet, even if the number starts with
As such, 78.82.123.145 would be stored as 078.082.123.145.
Professor Offenberg teaches an excellent Ethical Hacking class here at HCC. Unfortunately, his
evil twin brother, Darth Offenberg, is the head of the international crime group Offenberg's
Unethical Computer Hackers (OUCH). Hackers from OUCH are trying to penetrate your system.
OUCH always begin with one of three IP address ranges in the first two octets:
168.193
224.174
233.012
You have been forwarded a file called "ipfile.txt". This file contains an unknown number of IP
addresses and the data and time that the IP address accessed your system. Your job is to read
the file, find all the suspect IP addresses that might have been used by OUCH, and produce an
output report to both the screen and to an output file.
The program must allow the user to enter in the name of the input file:
a. The program must call a function that receives the input filename as a parameter
b. The program must use a try..except block to test that the file exists; if it does not
exist, the program must display the appropriate error message and allow the
reentry of the filename
c. Once the program determines that the file exists, the function must return the file
handle
The program must allow the user to enter in the name of the output file:
a. The program must call the same function as above that recieives the output
filename as a parameter
b. The program must use a try..except block to test that the file can be crated; if it
cannot be created, the program must display the appropriate error message and
allow the reentry of the filename
c. Once the program determines that the file can be created, the function must
return the file handle
The program must read all the data in the input file as strings:
a. The program must keep a count of the total number of records in the file
b. The program must create a list of strings that contains all the suspect IP Addresses;
these are IP addresses that start with the values listed above
c. Once the entire file is read, the program must close the file
The program must create and call a function to create the output report:
a. The function must take the total number of records in the file, the list of suspect IP
addresses and the output file handle as parameters
b. The function must create the output report as displayed in the screen shot below;
the output report MUST match the screen shot exactly
c. The function must create the output file with the exact format as shown in the
screen shot below; again, the output format must match the screen shot exactly
d. The output report must contain the following:
i. The number of records in the file
ii. The number of suspect IP addresses (the number must be determined
using a list function)
iii. The percentage of IP addresses that are suspect (formatted to display to 3
decimal places)
iv. The list of suspect IP addresses sorted by the IP address (the code must use
a list function to perform this sort and string slicing to separate the IP
address from the data and time stamp)
e. The function must close the output file once the output report is complete
f. NOTE - the file name prompts are NOT in the output file. Only the report
information itself is in the output file.
The code must display an end of program message
Notes:
Submit the .py file and the "badip.txt" output file in Canvas.
Any actions involving the list must use list functions; the code MUST create a list of the
suspect IP addresses
The output file must look exactly like this:
Encer the ouepue tile name: c:lleesellbadip. ext
Outpue Report
The rotal number of records in the f1.1e 15: 103657
The number of augpect Ip addresges is: 11
The percentage of suspect IP addresses 1s: 0.011
Sugpect If Acleresses
If Address =168.193*070.208 Dace and Time = Thu Jul 709:51:022022
IP Address -168.193.123.124 Dse and Time - Thu Ju1709:50:572022
If Address =168*193*202.160 Date and Time = Thu Jul 709:51:012022
IP Address =224.174.035.037 Dace and Time = Thu Ju1709:51:012022
IP Andress =224.174.127.229 Dace and T1me = Thu Ju1709:51:012022
IP Addregs =224*174.179*128 Date and Time = Thu Jul 709:50:432022
IP Address =224*174*200*210 Dace and Time = Thu Ju1
image text in transcribed

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Identify several examples of ethical investing and SRI.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago