首页 > 解决方案 > 如何在 wordpress 中阻止恶意 GET 请求

问题描述

WordPress-5.2.2 Nginx - 1.14.0

wordpress 网站被恶意软件感染,似乎是 xmlrpc.php 攻击,恶意编码文件很少,我使用 wordfence 扫描并清理它们,但仍然有恶意 GET 请求对创建 url 的网站,其中一些返回 404 ,一些返回 200 状态码,返回 200 的那些重定向到我当前的主页,没有重定向。但在 google 中,不需要的 url 被编入索引。请有人帮助如何阻止这种情况。

207.46.13.225 - - [30/Aug/2019:09:38:12 +0000] "GET /?mailboat-914902346%2Fnonpareil_la HTTP/1.1" 200 289904 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X)AppleWebKit/537.51.1(KHTML,如 Gecko)版本/7.0 Mobile/11A465 Safari/9537.53(兼容;bingbot/2.​​0;+ http://www.bing.com/bingbot.htm)"

46.229.168.136 - - [30/Aug/2019:09:38:13 +0000] "GET /?frizette%2F1028035242%2Fpersevering.racing HTTP/1.1" 301 5 "-" "Mozilla/5.0(兼容;SemrushBot/6 ~bl; + http://www.semrush.com/bot.html )"

46.229.168.146 - - [30/Aug/2019:09:38:15 +0000]“GET /?frizette%2F1028035242%2Fpersevering_racing HTTP/1.1”200 290444“-”“Mozilla/5.0(兼容;SemrushBot/6~bl ; + http://www.semrush.com/bot.html )"

标签: wordpressnginx

解决方案


您可以将以下几项添加到您的 wordpress 配置文件中,以停止锁定您的网站,并附上一些关于每项功能的评论。

//  Disable pingback.ping xmlrpc method to prevent Wordpress from participating in DDoS attacks
if ( !defined( 'WP_CLI' ) ) {
    // remove x-pingback HTTP header
    add_filter('wp_headers', function($headers) {
        unset($headers['X-Pingback']);
        return $headers;
    });
    // disable pingbacks
    add_filter( 'xmlrpc_methods', function( $methods ) {
            unset( $methods['pingback.ping'] );
            return $methods;
    });
    add_filter( 'auto_update_translation', '__return_false' );
}

//Automatic Database Repair - http://example.com/wp-admin/maint/repair.php
define('WP_ALLOW_REPAIR', true);

//Foce SSL on Admin Panel
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

//Disable Theme File Editor
define('DISALLOW_FILE_EDIT', true);

//Disallow Users to Install Plugins/Themes or doing updates
define('DISALLOW_FILE_MODS',true);

//Forcing use of FTP for all uploads, upgrades and plugin installation
define('FS_METHOD', 'ftpext');

//If FTPS is supported then add the following line to the config file
define('FTP_SSL', true);

您需要禁用 FTP 模式和 disallow_file_ 功能才能安装插件或更改基本代码,但除此之外它应该让您的网站更加安全。

另外,要直接回答您的问题,您可以查看这样的插件来过滤掉错误的 URL 请求。

https://wordpress.org/plugins/block-bad-queries/

祝你好运!


推荐阅读