安大互联
财经热点 > Asp编程 > ASP通用防注入代码.杜绝SQL注入隐患.提升网站安全
ASP通用防注入代码.杜绝SQL注入隐患.提升网站安全
浏览次数:【427】  发布日期:2009-8-13 12:09:22    文章分类:Asp编程   
专题:】 【
 
<%
''''''''''''''''''''''''''''''''''''''''''''''''
'ASP通用防注入代码
'您可以把该代码COPY到头文件中.也可以单独作
'为一个文件存在,每次调用使用
'作者:y3gu - 2005-7-29
''''''''''''''''''''''''''''''''''''''''''''''''
Dim GetFlag Rem(提交方式)
Dim ErrorSql Rem(非法字符)
Dim RequestKey Rem(提交数据)
Dim ForI Rem(循环标记)
ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每个敏感字符或词语请使用半角 "~" 格开)
ErrorSql = split(ErrorSql,"~")
If Request.ServerVariables("REQUEST_METHOD")="GET" Then
GetFlag=True
Else
GetFlag=False
End If
If GetFlag Then
For Each RequestKey In Request.QueryString
For ForI=0 To Ubound(ErrorSql)
If Instr(LCase(Request.QueryString(RequestKey)),ErrorSql(ForI))<>0 Then
response.write "<script>alert(""警告:\n请勿使用敏感字符"");location.href=""Sql.asp"";</script>"
Response.End
End If
Next
Next
Else
For Each RequestKey In Request.Form
For ForI=0 To Ubound(ErrorSql)
If Instr(LCase(Request.Form(RequestKey)),ErrorSql(ForI))<>0 Then
response.write "<script>alert(""警告:\n请勿使用敏感字符"");location.href=""Sql.asp"";</script>"
Response.End
End If
Next
Next
End If
%>
手机扫码浏览该文章
 ● 相关资讯专题
  • 网络建设业务咨询

   TEl:13626712526