Created
March 5, 2019 13:48
-
-
Save acosonic/18fcc234a324c858d50d0a96d5748ab4 to your computer and use it in GitHub Desktop.
Protecting ubuntu 14.04 server virtualmin websites against wordpress login attack bots
This file contains 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
#!/bin/bash | |
# this script will install fail2ban and enable apache-wp-login rule | |
# you will notice once it's done that fail2ban-client status shows apache-wp-login rule as active | |
apt install fail2ban | |
JAIL='' | |
JAIL="${JAIL}\n" | |
JAIL="${JAIL}[apache-wp-login]\n" | |
JAIL="${JAIL}enabled = true\n" | |
JAIL="${JAIL}port = http,https\n" | |
JAIL="${JAIL}filter = apache-wp-login\n" | |
JAIL="${JAIL}logpath = /var/log/virtualmin/*access_log\n" | |
JAIL="${JAIL}maxretry = 1\n" | |
JAIL="${JAIL}findtime = 36000\n" | |
JAIL="${JAIL}bantime = 36000" | |
printf "%b" "$JAIL" >> /etc/fail2ban/jail.conf | |
RULE='' | |
RULE="${RULE}\n" | |
RULE="${RULE}[Definition]\n" | |
RULE="${RULE}failregex = ^<HOST>.*/wp-login.php.*\n" | |
RULE="${RULE}ignoreregex =" | |
printf "%b" "$RULE" >> /etc/fail2ban/filter.d/apache-wp-login.conf | |
fail2ban-client reload | |
fail2ban-client status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this script...
curl -o- https://gist.githubusercontent.com/acosonic/18fcc234a324c858d50d0a96d5748ab4/raw/ae7d0beaa64a33736220128ba92f11772045bee5/fail2ban_wp.sh | bash
or
wget -qO- https://gist.githubusercontent.com/acosonic/18fcc234a324c858d50d0a96d5748ab4/raw/ae7d0beaa64a33736220128ba92f11772045bee5/fail2ban_wp.sh | bash