Skip to content

Instantly share code, notes, and snippets.

@JoshuaSchlichting
Created April 1, 2019 17:40
Show Gist options
  • Select an option

  • Save JoshuaSchlichting/58423fa36dc6c37dff66d02846ad66fb to your computer and use it in GitHub Desktop.

Select an option

Save JoshuaSchlichting/58423fa36dc6c37dff66d02846ad66fb to your computer and use it in GitHub Desktop.
Quickly read the attempted user names, and IP addresses, from /var/log/secure
file_rows = []
with open("/var/log/secure", 'r') as file:
for line in file.readlines():
file_rows.append(line)
filtered_rows = []
for row in file_rows:
if "Failed password for" in row:
filtered_rows.append(row)
date_stamp = row[0:15]
list_of_words = row[38:].replace('\n', '').split(" ")
#print("User Attempted: " + list_of_words[5])
print(str(len(filtered_rows)) + " entries detected!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment