我使用的代码从this article,工作完美,但我想阻止整个网站的访问,而不仅仅是一个页面,有任何可用的方法?
使用Ubuntu,php7,mod-security2.
代码:
<Locationmatch "/wp-login.php">
# Setup brute force detection.
# React if block flag has been set.
SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"
# Setup Tracking. On a successful login, a 302 redirect is performed, a 200 indicates login failed.
SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"
SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"
SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"
</Locationmatch>当任何网站用户试图在3分钟内登录10次与错误的凭据mod-security阻止访问此用户(通过IP),只为这个页面(sitename/wp-login.php),但我需要禁止整个网站。有没有办法在没有db/.htaccess和任何其他功能的情况下,通过这个规则和modsec来实现这一点?
谢谢你的帮助。
发布于 2019-01-25 00:05:11
你可以有一个像限制登录尝试这样的插件,它可以跟踪失败的登录,并管理IP的阻塞。但是由于插件只会阻止未来的登录,你可以添加一个基本的功能,利用插件来阻止对前端的访问。
例如,在安装了“限制登录尝试次数”插件的情况下,将以下代码添加到functions.php中-并进行任何您想要的更改。
add_action('template_redirect', 'checkIfLockedOut');
function checkIfLockedOut(){
if(function_exists('is_limit_login_ok')){
$isNotLockedOut = is_limit_login_ok();
if(!$isNotLockedOut){
// you could wp_redirect here,
// or do what you'd like.
die('Sorry, you cannot access the site, you are locked out!');
}
}
}https://stackoverflow.com/questions/54343508
复制相似问题