WordPress站点可能正遭遇“作者枚举”攻击。这类攻击旨在通过逐个查询网站上的作者ID,从而收集网站上所有作者的用户名。这可能会为后续的暴力破解攻击提供信息。

解决方法
- 禁用作者归档页面:
通过修改.htaccess文件或添加代码到主题的functions.php文件,可以禁用作者归档页面。
在 .htaccess 文件中添加以下代码:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/author/(.*)
RewriteRule ^(.*)$ /? [R=301,L]
或者在 functions.php 文件中添加以下代码:
add_action('template_redirect', 'disable_author_archives');
function disable_author_archives() {
if (is_author()) {
wp_redirect(home_url());
exit;
}
}
-
限制访问尝试:
使用插件如 Wordfence 或 Sucuri 增强网站的安全性,这些插件可以帮助你检测和阻止类似的恶意行为。 -
修改用户权限:
确保没有使用“admin”作为用户名,并且强制所有用户使用强密码。可以考虑使用插件如 Force Strong Passwords 来强制实施。 -
隐藏用户信息:
通过以下代码隐藏用户的登录名,可以防止暴力破解和作者枚举攻击。
在 functions.php 文件中添加以下代码:
// Remove the author pages
add_action('template_redirect', 'block_author_page');
function block_author_page() {
if (is_author()) {
wp_redirect(home_url());
exit;
}
}
// Remove the author query from REST API responses
add_filter('rest_endpoints', function($endpoints) {
if (isset($endpoints['/wp/v2/users'])) {
unset($endpoints['/wp/v2/users']);
}
return $endpoints;
});
通过上述措施,你可以有效地防止作者枚举攻击,保护你的WordPress站点安全。
当前文章价值1.21元,扫一扫支付后添加微信提供帮助!(如不能解决您的问题,可以申请退款)

评论已关闭!