手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp 防止SQL注入代码
asp 防止SQL注入代码
摘要:把下面代码复制到每个文件头部就可以防止SQL注入了,写程序安全最重要:)

把下面代码复制到每个文件头部就可以防止SQL注入了,写程序安全最重要:)

<%

DimFy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx

'---定义部份头------

Fy_Cl=1'处理方式:1=提示信息,2=转向页面,3=先提示再转向

Fy_Zx="Error.Asp"'出错时转向的页面

'---定义部份尾------

OnErrorResumeNext

Fy_Url=Request.ServerVariables("QUERY_STRING")

Fy_a=split(Fy_Url,"&")

redimFy_Cs(ubound(Fy_a))

OnErrorResumeNext

forFy_x=0toubound(Fy_a)

Fy_Cs(Fy_x)=left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1)

Next

ForFy_x=0toubound(Fy_Cs)

IfFy_Cs(Fy_x)<>""Then

IfInstr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"and")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"select")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"update")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"chr")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),";")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0orInstr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0OrInstr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0Then

SelectCaseFy_Cl

Case"1"

Response.Write"<ScriptLanguage=JavaScript>alert('出现错误!参数"&Fy_Cs(Fy_x)&"的值中包含非法字符串!nn请不要在参数中出现:;,and,select,update,insert,delete,chr等非法字符!nn你想干吗!不要做无聊的事情!谢谢!');window.close();</Script>"

Case"2"

Response.Write"<ScriptLanguage=JavaScript>location.href='"&Fy_Zx&"'</Script>"

Case"3"

Response.Write"<ScriptLanguage=JavaScript>alert('出现错误!参数"&Fy_Cs(Fy_x)&"的值中包含非法字符串!nn请不要在参数中出现:;,and,select,update,insert,delete,chr等非法字符!nn你想干吗!不要做无聊的事情!谢谢!');location.href='"&Fy_Zx&"';</Script>"

EndSelect

Response.End

EndIf

EndIf

Next

%>

【asp 防止SQL注入代码】相关文章:

asp中创建多级目录的两段代码

asp查询记录

asp html转换字符程序

asp 获取地址栏参数代码

Mssql高级注入笔记II

asp中"无限流"分页程序代码

ASP辅助代码

asp 之上传漏洞终结篇

asp完整登陆代码

asp文件上传:文件上传 源代码

精品推荐
分类导航