1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ugo [173]
3 years ago
8

Statement: There are two files. One file, "badIP_list.txt" has a listing of known bad IP addresses. These addresses were extract

ed from Talos Threat Hunting listings for 26 Jul 2018. The second file, "server_logs.txt", is a listing of IP addresses pulled off of your firewall logs, representing computers which have attempted entry into your network through network services, such as http, ssh and ftp. You will find which bad actors have attempted to enter your network for the purpose of tuning your firewalls and IDS's. Challenge: Write a program which reads in both files and checks the IP addresses from your server logs against the know bad IP's. If there is a match, write the bad IP address to a file titled "filter_list.txt". List unique IP's, do not list duplicates. Also, at the end of the "filter_list.txt" there should be a total of "Known bad IP's detected", and the percentage of IP addresses from your logs which are bad. (Divide the number of bad IP's by the number of total IP's)
Computers and Technology
1 answer:
lapo4ka [179]3 years ago
5 0

Answer:

See explaination

Explanation:

SOURCE CODE IN PYTHON:

inp=open('badIP_list.txt', 'r') #opening file for input

badIPs=[i.rstrip('\n') for i in inp.readlines()] #reading bad IPs

inp.close() #closing file

inp=open('server_logs.txt', 'r') #opening file for input

IPs=[i.rstrip('\n') for i in inp.readlines()] #reading all IPs from log

inp.close() #closing file

uniqueBadIPs=[] #to store unique bad IPs

countBadIPs=0 #to store count of bad IPs

countIPs=0 #to store count of all IPs

for IP in IPs: #iterating through the log of IPs

if IP in badIPs: #checking if IP is bad

countBadIPs+=1

if IP not in uniqueBadIPs: #checking if bad IP is unique

uniqueBadIPs.append(IP)

countIPs+=1

out=open('filter_list.txt', 'w') #opening file for output

out.write('_________________________________________________________\n')

out.write('Date : 26/07/2018\nName : Last, First\nMajor: CS\n\n')

out.write('Server logs contained these known bad IP addresses:\n')

for IP in uniqueBadIPs: #output the unique bad IPs

out.write(IP+'\n')

out.write('\n')

out.write('Total unique known bad IP\'s detected:\n'+str(len(uniqueBadIPs))+'\n\n')

out.write('Percentage of bad IP addresses in server logs:\n{:.2f}%\n'.format(countBadIPs*100/countIPs))

out.write('_________________________________________________________')

out.close() #closing file

You might be interested in
Write a class called Dragon. A Dragon should have a name, a level, and a boolean variable, canBreatheFire, indicating whether or
Alex Ar [27]

Answer: A dragon name could be name Holls and at level 14 and can breathe fire

Explanation:

4 0
3 years ago
Which of the following protects against cave-ins? A. All answer choices protect against cave-ins B. Shielding C. Shoring D. Slop
babunello [35]
I think it is b idk if it is 100% right
4 0
2 years ago
Read 2 more answers
Write a Python 3 program that prompts the user for 3 postive numbers (or zero) and then adds them together. If the user enters a
Citrus2011 [14]

Answer:

def prompt_number():

   while True:

       number = int(input("Enter a number: "))

       if number >= 0:

           break

       

   return number

   

def compute_sum(n1, n2, n3):

   total = n1 + n2 + n3

   return total

   

n1 = prompt_number()

n2 = prompt_number()

n3 = prompt_number()

result = compute_sum(n1, n2, n3)

print(result)

Explanation:

Create a function named prompt_number that asks the user to enter a number until a positive number or 0 is entered and returns the number

Create a function named compute_sum that takes three numbers, sums them and returns the sum

Ask the user to enter three numbers, call the prompt_number() three times and assign the values

Calculate the the sum, call the compute_sum and pass the numbers as parameters

Print the result

6 0
2 years ago
Plz help ( which is an example of a good URL?
Simora [160]

The answer is B because it is short and simple and gets you to the point

8 0
3 years ago
Read 2 more answers
I think i have a virus on my computer what am i supposed to do
patriot [66]

Answer:

call like a phone or computer company and ask wjat thry can do

4 0
3 years ago
Other questions:
  • Best value supply chains strive to excel along four measures: speed, quality, cost, and flexibility. Group of answer choices Tru
    10·1 answer
  • Cobbling together elements from the previous definition and whittling away the unnecessary bits leaves us with the following def
    7·1 answer
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers to the e
    9·1 answer
  • Which segment of society introduced the grunge look?
    5·2 answers
  • What is work flexibility?
    15·1 answer
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • What do you hope will be in/added GTA 6?
    13·1 answer
  • What are benefits of virtualizing servers ?
    5·1 answer
  • Can geico save me 15% or more on car insurance?
    8·2 answers
  • Which is a software application used to analyze an organization’s data to improve decision making?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!