Python Forum
test..and I'm already lost
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test..and I'm already lost
#1
Hi all, i have to create a log scanner or python script that will run through a .txt file, and it should create a text file that reads all rows in the file and searches for certain text, and gives me the following summarized info after the analyzation of said log file:
- Displays a count of how many scan events occurred in the logs
- Displays a list of all host ip addresses where the scans originated from
- Displays a list of all host ip addresses where the scans were performed against

I have created the python file itself, but that's about as far as i got. Unfortunately, my teacher is terrible at responding to questions, so i shall resource to the all knowing internet.

here is what i have so far:
import os
import re

filePath = "./ssh.log.txt"
fd = open(filePath, 'r')

with fd as reader :
    for line in reader :
        print( line )
Here are two samples of the file: (Text box breaks it into two lines)ANY HELP WILL BE GREATLY APPRECIATED! THANKS GUYS!

1331902037.460000 CzOW1hqdnsStTLdB2 192.168.202.79 46073 192.168.229.101 22 undetermined INBOUND SSH-1.5-Nmap-SSH1-Hostkey SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1 - - - - -

1331902037.730000 COIlCg1sDKjduod1e8 192.168.202.79 46085 192.168.229.101 22 failure INBOUND SSH-2.0-Nmap-SSH2-Hostkey SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1 - - - - -
Reply
#2
Have you found a python function to search for specific text string? otherwise you have to make that part yourself, maybe with a loop.

If you always have the IP adress in the same part/position of the lines, you read each line into a list and then refer to the IP part of the list by position as:
[python]list5[0:9]/python]
for the first 10 characters
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am completely lost on this homework assignment a36 1 1,750 Feb-21-2022, 06:01 AM
Last Post: buran
  Very Lost vollynez 3 1,862 Oct-02-2020, 09:09 PM
Last Post: Yoriz
  I got lost in the program Gadev 1 1,884 Nov-11-2018, 05:50 PM
Last Post: j.crater
  I keep getting errors and I'm lost! samjonsnell 9 4,908 Oct-28-2018, 11:38 PM
Last Post: samjonsnell
  Completly lost about to fail my class! crakacheezy 7 4,534 Dec-28-2017, 11:50 PM
Last Post: mepyyeti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020