Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Last active November 20, 2015 07:16
Show Gist options
  • Save forestbaker/9b3b30f18793f924748a to your computer and use it in GitHub Desktop.
Save forestbaker/9b3b30f18793f924748a to your computer and use it in GitHub Desktop.
display IP's that unsuccessfully attempted to login 5 or more times,
# original - this is all bad logins - ever!
lastb -i | grep -Po '\b(?!255)(?:\d{1,3}\.){3}(?!255)\d{1,3}\b' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
# early prototype - this works - but returns words
lastb -i | awk '{ print $3 }' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
# ah ha! this filters out the blank line and date/time stamp that was causing the words to appear
lastb -i | egrep -v '^$|btmp' | awk '{ print $3 }' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
# same as above, but only IP addresses from today
lastb -i | grep "$(date '+%a %b %d')" | awk '{ print $3 }' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment