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]
4 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]4 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 program with the total change amount as an integer input, and output the change using the fewest coins, one coin type pe
riadik2000 [5.3K]

Answer:

In Python:

cents = int(input("Cents: "))

dollars = int(cents/100)

quarters = int((cents - 100*dollars)/25)

dimes = int((cents - 100*dollars- 25*quarters)/10)

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

if not(dollars == 0):

   if dollars > 1:

       print(str(dollars)+" dollars")

   else:

       print(str(dollars)+" dollar")

if not(quarters == 0):

   if quarters > 1:

       print(str(quarters)+" quarters")

   else:

       print(str(quarters)+" quarter")

if not(dimes == 0):

   if dimes > 1:

       print(str(dimes)+" dimes")

   else:

       print(str(dimes)+" dime")

if not(nickels == 0):

   if nickels > 1:

       print(str(nickels)+" nickels")

   else:

       print(str(nickels)+" nickel")

if not(pennies == 0):

   if pennies > 1:

       print(str(pennies)+" pennies")

   else:

       print(str(pennies)+" penny")

   

Explanation:

A prompt to input amount in cents

cents = int(input("Cents: "))

Convert cents to dollars

dollars = int(cents/100)

Convert the remaining cents to quarters

quarters = int((cents - 100*dollars)/25)

Convert the remaining cents to dimes

dimes = int((cents - 100*dollars- 25*quarters)/10)

Convert the remaining cents to nickels

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

Convert the remaining cents to pennies

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

This checks if dollars is not 0

<em>if not(dollars == 0):</em>

If greater than 1, it prints dollars (plural)

<em>    if dollars > 1:</em>

<em>        print(str(dollars)+" dollars")</em>

Otherwise, prints dollar (singular)

<em>    else:</em>

<em>        print(str(dollars)+" dollar")</em>

This checks if quarters is not 0

<em>if not(quarters == 0):</em>

If greater than 1, it prints quarters (plural)

<em>    if quarters > 1:</em>

<em>        print(str(quarters)+" quarters")</em>

Otherwise, prints quarter (singular)

<em>    else:</em>

<em>        print(str(quarters)+" quarter")</em>

This checks if dimes is not 0

<em>if not(dimes == 0):</em>

If greater than 1, it prints dimes (plural)

<em>    if dimes > 1:</em>

<em>        print(str(dimes)+" dimes")</em>

Otherwise, prints dime (singular)

<em>    else:</em>

<em>        print(str(dimes)+" dime")</em>

This checks if nickels is not 0

<em>if not(nickels == 0):</em>

If greater than 1, it prints nickels (plural)

<em>    if nickels > 1:</em>

<em>        print(str(nickels)+" nickels")</em>

Otherwise, prints nickel (singular)

<em>    else:</em>

<em>        print(str(nickels)+" nickel")</em>

This checks if pennies is not 0

<em>if not(pennies == 0):</em>

If greater than 1, it prints pennies (plural)

<em>    if pennies > 1:</em>

<em>        print(str(pennies)+" pennies")</em>

Otherwise, prints penny (singular)

<em>    else:</em>

<em>        print(str(pennies)+" penny")</em>

<em>    </em>

4 0
3 years ago
Two technicians are discussing using a lift to raise a vehicle. Technician A says to be sure the lift pads on the lift are conta
lianna [129]
Its B no doubt
cuz ik how to do this i took classes for this so ik im right ight
6 0
3 years ago
Read 2 more answers
What is adobe photoshop?
Hitman42 [59]
Its a photoshop that u need to pay for
4 0
3 years ago
Read 2 more answers
Any of my friends can you answer me plz?
Valentin [98]

Answer:

God is always your friend mate

Explanation:

5 0
3 years ago
Please write in python:
Alenkasestr [34]

Week 1:

print("1. Skittles    2. M&M's\n3. Starbursts   4. Twizzlers\n5. Twix")

while True:

   item = input("Enter the number of your item to be purchased: ")

   if item == "1":

       print("You chose skittles.")

   elif item == "2":

       print("You chose M&M's.")

   elif item == "3":

       print("You chose Starbursts.")

   elif item == "4":

       print("You chose Twizzlers.")

   elif item == "5":

       print("You chose Twix.")

Week 2:

print("1. Skittles    2. M&M's\n3. Starbursts   4. Twizzlers\n5. Twix")

total = 0

while True:

   item = input("Enter the number of your item to be purchased: ")

   if item == "1":

       print("You chose skittles.")

       total += 2

   elif item == "2":

       print("You chose M&M's.")

       total += 2

   elif item == "3":

       print("You chose Starbursts.")

       total += 1

   elif item == "4":

       print("You chose Twizzlers.")

       total += 3

   elif item == "5":

       print("You chose Twix.")

       total += 4

   elif item == "exit":

       exit()

   elif item == "out":

       total += round(total*0.0625,2)

       print("Your total is: ${}".format(total))

       deposit = int(input("How much money did you input? "))

       change_due = round(deposit - total,2)

       print("Your change due is ${}".format(change_due))

   else:

       print("Please choose an option or enter \"exit\" to exit the vending machine.")

week 3:

print("1. Skittles    2. M&M's\n3. Starbursts   4. Twizzlers\n5. Twix")

total = 0

while True:

   item = input("Enter the number of your item to be purchased: ")

   if item == "1":

       print("You chose skittles.")

       total += 2

   elif item == "2":

       print("You chose M&M's.")

       total += 2

   elif item == "3":

       print("You chose Starbursts.")

       total += 1

   elif item == "4":

       print("You chose Twizzlers.")

       total += 3

   elif item == "5":

       print("You chose Twix.")

       total += 4

   elif item == "exit":

       exit()

   elif item == "out":

       total += round(total * 0.0625, 2)

       print("Your total is: ${}".format(total))

       deposit = int(input("How much money did you input? "))

       while deposit < total:

           deposit = int(

               input("Please input a dollar amount greater than or equal to the total (whole numbers only): "))

       change_due = round(deposit - total, 2)

       if change_due == 0:

           print("No change due.")

       else:

           print("You are owed {} dollars and {} cents".format(int(change_due), round(change_due - int(change_due),2)))

   else:

       print("Please choose an option or enter \"exit\" to exit the vending machine.")

week 4:

def print_menu():

   print("1. Skittles    2. M&M's\n3. Starbursts   4. Twizzlers\n5. Twix    Enter \"out\" to checkout.")

def calculate_total(new_item):

   total = 0

   if new_item == "1":

       print("You chose skittles.")

       total += 2

   elif new_item == "2":

       print("You chose M&M's.")

       total += 2

   elif new_item == "3":

       print("You chose Starbursts.")

       total += 1

   elif new_item == "4":

       print("You chose Twizzlers.")

       total += 3

   elif new_item == "5":

       print("You chose Twix.")

       total += 4

   return total

def make_change(change_due):

   print(

       "Here is your change: {} dollars and {} cents".format(int(change_due), round(int(change_due) - change_due, 2)))

   print("Have a great day")

def amount_due(total_price):

   sales_tax = 0.0625

   final_price = total_price * +(total_price * sales_tax)

   print("Subtotal: {}".format(total_price))

   print("Final total: {}".format(final_price))

   deposit = int(input("Enter how much you deposited: "))

   while deposit < final_price:

       deposit = int(input("Enter an amount greater than or equal to {}".format(final_price)))

   make_change(deposit - final_price)

total = 0

while True:

   item = input("Enter the number of your item to be purchased: ")

   if item == "1":

       print("You chose skittles.")

       total += 2

   elif item == "2":

       print("You chose M&M's.")

       total += 2

   elif item == "3":

       print("You chose Starbursts.")

       total += 1

   elif item == "4":

       print("You chose Twizzlers.")

       total += 3

   elif item == "5":

       print("You chose Twix.")

       total += 4

   elif item == "exit":

       exit()

   elif item == "out":

       sales_tax = 0.0625

       total += round(total * sales_tax, 2)

       print("Your total is: ${}".format(total))

       deposit = int(input("How much money did you input? "))

       while deposit < total:

           deposit = int(

               input("Please input a dollar amount greater than or equal to the total (whole numbers only): "))

       change_due = round(deposit - total, 2)

       if change_due == 0:

           print("No change due.")

       else:

           print(

               "You are owed {} dollars and {} cents".format(int(change_due), round(change_due - int(change_due), 2)))

   else:

       print("Please choose an option or enter \"exit\" to exit the vending machine.")

I didn't implement the functions because the problem never stated that we had to. Best of luck.

6 0
3 years ago
Other questions:
  • Ryan wants to ensure that all the words in this document are evenly spaced so that they look neat and readable . Which option in
    12·1 answer
  • Create a function that will concatenate two strings, combining them with a specified separator. To do so, write a function calle
    5·1 answer
  • How to hard reset a iphone 7 without computer
    8·2 answers
  • NEED ASAP!!
    14·1 answer
  • Three common risk factors for young drivers and how you plan to minimize these factors.
    13·1 answer
  • Which scenario describes unethical lab behavior?
    9·1 answer
  • When it comes to having certain sales skills as a hotel manager, being able to really hear, learn about, and show customers that
    10·1 answer
  • Does anyone else have edge and think its not the awful?
    12·2 answers
  • "Use onblur and onfocus to add red borders to the input elements when the user leaves without any input, and a green border if a
    8·1 answer
  • Which database can be used to find studies related to allied health sciences?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!