Skip to content

Instantly share code, notes, and snippets.

@R41D3NN
Created August 30, 2015 02:38
Show Gist options
  • Save R41D3NN/e318a43e2301cb10340f to your computer and use it in GitHub Desktop.
Save R41D3NN/e318a43e2301cb10340f to your computer and use it in GitHub Desktop.
auth.log Unauthorized Login Attempt Logger
#!/bin/bash
AUTH_LOG=/var/log/auth.log
LOG_FILE=/var/log/unauthorized-login-attempts.txt
IP_ADDR_REGEX='[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\s'
cat $AUTH_LOG | grep 'authentication failure' | grep -o $IP_ADDR_REGEX | sort | uniq >> $LOG_FILE
cat $LOG_FILE | sort | uniq > $LOG_FILE.tmp
mv -f $LOG_FILE.tmp $LOG_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment