Created
April 1, 2019 17:40
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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