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