Skip to content

Instantly share code, notes, and snippets.

@jackygurui
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save jackygurui/bf9587a9db27193f2f64 to your computer and use it in GitHub Desktop.

Select an option

Save jackygurui/bf9587a9db27193f2f64 to your computer and use it in GitHub Desktop.
Block IP that brute forcing wordpress logins in one line. Requres UFW
#!/bin/sh
grep 11/Jul/2015 access_log | grep "POST /wp-login.php" | awk '{ print $1 }' | sort -n | uniq -c | sort -rn | grep "\\([1-9][0-9][0-9][0-9]\\+\\) " | awk '{ print $2 }' | xargs -n 1 ufw insert 1 deny from
# or change the grep criteria to suit your need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment