用于阻止 WordPress / joomla 管理员登录的 modsecurity 规则 - 其他

用于阻止 WordPress / joomla 管理员登录的 modsecurity 规则 - 其他

我有一个 ModSecurity 1.x 的旧规则来阻止管理员暴力攻击,并且只允许它们出现在内部网络中。

当我迁移到 2.x 时,它停止工作。另外,网络 ipmatch 规则也让我抓狂,因为它们不允许 /8,只适用于 /16 或更高版本。

我尝试使规则适应 modsecurity 2,结果是:

SecRule REMOTE_HOST "!^10." "chain,id:'1',phase:2,t:none,block,nolog"
SecRule REQUEST_METHOD "@streq POST" "chain"
SecRule REQUEST_FILENAME "@pm /wp-login.php /wp-admin/ /administrator/ /admin/" "chain"
SecRule ARGS:log "@streq admin"

但是它不起作用。来自在 modsecurity 方面更有经验的人的一些建议?

答案1

你为什么不使用.htaccess?它应该可以保护您免受暴力攻击,并且易于配置。

我们确实使用类似这样的文件,该.htaccess文件位于网站的根目录中,包含以下内容:

## Hardening wp - doublelogin
AuthUserFile /path/to/your/.htpasswd
AuthName "Double Login antibot"
AuthType Basic
<Files "wp-login.php">
  require valid-user
</Files>

和一个.htpasswd文件,位于本地驱动器上您想要的任何位置。您只需.htpasswd使用指令指定文件的完整路径即可AuthUserFile。选择您认为适合密码文件的任何位置。只需确保 Apache 对其具有读取权限即可。

其中.htpasswd包含凭据。您可以通过运行以下命令来配置用户名和密码:

## if it is the first user use -c param (it create new file / or wipe it if exists)
htpasswd -c /path/to/your/.htpasswd username
## if you want to add more users omit the -c param

此外,我们还添加了以下规则.htaccess来拒绝访问wp-config.php(其中包含敏感信息,例如:WordPress 安全密钥和 WP 数据库连接详细信息)

<files wp-config.php>
  order deny,allow
  deny from all
  allow from 192.168.1.1/24 #(replace with your IP address)
</files>

以及以下一项,阻止 WPxmlrpc.php请求,这是利用的最常见原因之一。 (读这里了解更多信息)

<Files xmlrpc.php>
  order deny,allow
  deny from all
  allow from 192.168.1.1/24 #(replace with your LAN info)
</Files>

抱歉,我无法直接帮助您解决问题,如果以上内容不是您想要的,我希望此链接可以为您提供一些帮助:http://artefact.io/brute-force-protection-modsecurity/

相关内容