Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:44:23+00:00 2026-05-31T02:44:23+00:00

How would i find the number of attacks per day from the example log

  • 0

How would i find the number of attacks per day from the example log file? I’d like it to give a hint of anything that starts with a failed password.

I got most of the code but it needs work and am not quite sure been playing around with it for a few hours but have no luck.

$ myFile = open('auth','r')

#! /bin/python

att_dic = {}    
count_attack = 0
print 'Start of Debug messages'

for line in myFile.readlines():
    lineList2 = line.split(']')        
    att_list = lineList2[0]
    att_list2 = att_list.split('[')
    attack = att_list2[1]
    if att_dic.has_key(attack):
        count_attack = att_dic[attack]
        count_attack = count_attack +1
        att_dic[attack] = count_attack
        count_attack = 0
    else:
        att_dic[attack] = 1
    else:
        lineList2 = line.split(']')
        att_list = lineList2[1]
        att_list2 = att_list.split('[')
        attack = att_list2[0]

    if att_dic.has_key(attack):
        count_att = att_dic[ip]
        count_attack = count_att +1
        att_dic[attack] = count_attack
        count_attack =0
    else:
        att_dic[attack] = 1

    print attack        

print '\nEnd of Debug messages\n\n'
print 'Answers:\n'
print 'Number of attacks per day:'
for att_items in att_dic.keys():
print att_items ,' has', att_dic[att_items] , ' attacks per day '

Log File Sample

Jan 10 09:32:07 j4-be03 sshd[3876]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.241.173.35  user=root   
Jan 10 09:32:09 j4-be03 sshd[3876]: Failed password for root from 218.241.173.35 port 47084 ssh2
Jan 10 09:32:17 j4-be03 sshd[3879]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.241.173.35  user=root
Jan 10 09:32:19 j4-be03 sshd[3879]: Failed password for root from 218.241.173.35 port 47901 ssh2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:44:25+00:00Added an answer on May 31, 2026 at 2:44 am

    I done it i used a dict and a count found the days and counted the number of attack per day.
    thanks for your help anyway

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In rails, I would like to find an incremental number that increases or at
Given a specific word pattern (say, balloon), I would like to find the number
I am trying to extract numbers from a typical scoreboard that you would find
I would like to find the number of rows in a cursor. Is there
Given a column of strings I would like to find the number of search
Possible Duplicate: Find the number of columns in a table I would like to
Anyone knows any free Visual Studio add-in that would find and/or delete dead (unused)
I'm trying to write a program that would find the minimum spanning tree. But
How would get find an average from an array? If I have the array:
I have UltraMon installed and quite like it but I would also find it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.