WordPress 作为一个市场占有量最高的 CMS,其登录页面 wp-login.php 每天经受不少的爆破尝试,以我的博客为例,在短短 24 小时内就被(尝试)爆破了 160 次
要避免这个问题很简单,我主要用了以下两种方式
限制登录次数
有很多插件可以实现限制登录次数,这里以Limit Login Attempts Reloaded这个插件为例
插件分为免费以及付费版,不过免费版够用了
安装并启用插件,转到插件设置页面,可以设置尝试错误密码多少次后拦截
以下是我的设置:
After a specific IP address fails to log in 4 times, a lockout lasting 20 minutes is activated. If additional failed attempts occur within 24 hours and lead to another lockout, once their combined total hits 4, the 20 minutes duration is extended to 24 hours. The lockout will be lifted once 24 hours have passed since the last lockout incident.
添加验证码
常见的验证码有不少,Cloudflare Turnstile, reCAPTCHA, hCaptcha 等等
我比较习惯用老牌的 reCAPTCHA
先创建 reCAPTCHA ,reCAPTCHA 类型可选 V2, V3 其中 V2 需要手动点击,而 V3 为无感验证
创建后会获得网站密钥及密钥,回到网站安装Advanced Google reCAPTCHA插件
启用插件后找到插件设置,填入 Captcha Site Key, Captcha Secret Key,输入后会弹出 Verify Captcha 按钮,验证一次后即可保存设置
找到 Where To Show 菜单,这里可以验证码展示的位置,我选择关闭评论的验证码(因为我会手动筛选评论,而且不希望被 JS 拖慢网站速度)
最后,不要用 admin 这类的弱密码…