<%
'--------定义部分------------------
Dim FangZhuPost,FangZhuGet,FangZhuIn,FangZhuInf,FangZhuXh
'注释:自定义需要过滤的字串,用“|”分隔,如果读者发现有什么遗漏可以加上去
FangZhuIn = "'|;|and|(|)|exec|insert|select|union|delete|update|count
|*|%|chr|mid|master|truncate|char|declare"
FangZhuInf = split(FangZhuIn,"|") '注释:把非法字符串用“|”分割出来
'--------POST部分------------------
If Request.Form<>"" Then
For Each FangZhuPost In Request.Form '注释:循环取得提交的参数
For FangZhuXh=0 To Ubound(FangZhuInf) '注释:全部转换成大写
If Instr(LCase(Request.Form(FangZhuPost)),FangZhuInf(FangZhuXh))<>0 Then
'注释:如果在数据里有非法字符串
Response.Write "<Script Language=JavaScript>alert('请不要在参数中包
含非法字符尝试注入!');</Script>"
Response.End
End If
Next
Next
End If
'----------------------------------
'--------GET部分-------------------
If Request.QueryString<>"" Then
For Each FangZhuGet In Request.QueryString
For FangZhuXh=0 To Ubound(FangZhuInf)
If Instr(LCase(Request.QueryString(FangZhuGet)),FangZhuInf(FangZhuXh))<>0 Then
Response.Write "<Script Language=JavaScript>alert('请不要在参数中包
含非法字符尝试注入!');</Script>"