Aug-18-2019, 07:25 PM
(This post was last modified: Aug-18-2019, 07:28 PM by raymond2688.)
(Aug-18-2019, 06:56 PM)ndc85430 Wrote: Have you even tried that code? Do you understand why it's incorrect? Where are the two values you need stored? It really shouldn't be too hard.
I know its something simple and yes i ran the code this is the output:
Output:Attackers tried anonymous times to log in as root
Attackers tried bin times to log in as root
Attackers tried suse times to log in as root
Attackers tried bob times to log in as root
Attackers tried 89502 times to log in as root
Attackers tried 61947 times to log in as root
Attackers tried sshd times to log in as root
Attackers tried nagios times to log in as root
Attackers tried mobile times to log in as root
Attackers tried installer times to log in as root
Attackers tried adam times to log in as root
Attackers tried forum times to log in as root
Attackers tried data times to log in as root
As I stated I do not believe that my values (maybe not the correct term) are going in my dictionary and I am certain it is not counting how many times each user attempts to log in. I know you say this should be simple, but please keep in mind I am in an introductory class 5 weeks ago I never wrote code before. I have struggled and spent countless hours on 1 assignment and this forum has helped me tremendously. and I thank everyone for thatupdated code so far
intruder_log = {} with open("auth.log.1") as auth_log: for line in auth_log: if "Failed password" in line: start = line.find("invalid user") end = line.find(" from") name = line[start + 13:end] if name in intruder_log: intruder_log[name] += 1 else: intruder_log[name] = 1 for key in intruder_log: print("Attackers tried {1} times to log in as {0}".format(name, key))