asp 防止SQL注入代码

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了asp 防止SQL注入代码脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
把下面代码复制到每个文件头部就可以SQL注入了,写程序安全最重要 :)

<%
Dim&nbsp;Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx
'---定义部份 头------
Fy_Cl = 1    '处理方式:1=提示信息,2=转向页面,3=先提示再转向
Fy_Zx = "Error.Asp"  '出错时转向的页面
'---定义部份 尾------

On Error Resume Next
Fy_Url=Request.ServerVARiables("QUERY_STRING")
Fy_a=splIT(Fy_Url,"&amp;")
redim Fy_Cs(ubound(Fy_a))
On Error Resume Next
for Fy_x=0 to ubound(Fy_a)
Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1)
Next
For Fy_x=0 to ubound(Fy_Cs)
If Fy_Cs(Fy_x)<>"" Then
If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"and")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"select")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"update")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20From")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0 Or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then
Select Case Fy_Cl
 Case "1"
Response.Write "<Script Language=JavaScript>alert(' 出现错误!参数 "&Fy_Cs(Fy_x)&" 的值中包含非法字符串!\n\n 请不要在参数中出现:;,and,select,update,insert,delete,chr 等非法字符!\n\n你想干吗!不要做无聊的事情!谢谢!');window.close();</Script>"
 Case "2"
Response.Write "<Script Language=JavaScript>location.href='"&Fy_Zx&"'</Script>"
 Case "3"
Response.Write "<Script Language=JavaScript>alert(' 出现错误!参数 "&Fy_Cs(Fy_x)&"的值中包含非法字符串!\n\n 请不要在参数中出现:;,and,select,update,insert,delete,chr 等非法字符!\n\n你想干吗!不要做无聊的事情!谢谢!');location.href='"&Fy_Zx&"';</Script>"
End Select
Response.End
End If
End If
Next
%>

脚本宝典总结

以上是脚本宝典为你收集整理的asp 防止SQL注入代码全部内容,希望文章能够帮你解决asp 防止SQL注入代码所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:asp