Wordpress Failed Login Frequency Setting?
Posted: 29 Nov 2021, 18:50
The /usr/local/csf/bin/regex.custom.pm file allows you to set up blocking for failed Wordpress login attempts, for example:
if (($globlogs{CUSTOM2_LOG}{$lgfile}) and ($line =~ /(\S+).*] "\w*(?:GET) \/wp-login\.php.*" /)) {
return ("Failed WordPress GET",$1,"WPLOGINGET","5","80,443,21,25,22,23","1");
}
if (($globlogs{CUSTOM2_LOG}{$lgfile}) and ($line =~ /(\S+).*] "\w*(?:POST) \/wp-login\.php.*" /)) {
return ("Failed WordPress POST",$1,"WPLOGINPOST","5","80,443,21,25,22,23","1");
}
However, the parameter ("5" in the above example) is the number of lines in the log that match the REGEX expression to trigger the block. I looked at the domain log (in dom logs where CUSTOM2_LOG points to) and for the domain in question, there appear to be about 27 days of data in the log. This means that if a user from the same IP address made a typo in their login 5 times in 27 days, they get blocked.
How do I make in so it's only triggered if there are 5 attempts in 24 hours, not for the entire log spanning 27 days?
if (($globlogs{CUSTOM2_LOG}{$lgfile}) and ($line =~ /(\S+).*] "\w*(?:GET) \/wp-login\.php.*" /)) {
return ("Failed WordPress GET",$1,"WPLOGINGET","5","80,443,21,25,22,23","1");
}
if (($globlogs{CUSTOM2_LOG}{$lgfile}) and ($line =~ /(\S+).*] "\w*(?:POST) \/wp-login\.php.*" /)) {
return ("Failed WordPress POST",$1,"WPLOGINPOST","5","80,443,21,25,22,23","1");
}
However, the parameter ("5" in the above example) is the number of lines in the log that match the REGEX expression to trigger the block. I looked at the domain log (in dom logs where CUSTOM2_LOG points to) and for the domain in question, there appear to be about 27 days of data in the log. This means that if a user from the same IP address made a typo in their login 5 times in 27 days, they get blocked.
How do I make in so it's only triggered if there are 5 attempts in 24 hours, not for the entire log spanning 27 days?