asp网站如何防止sql注入,代码怎么写
------解决方案--------------------
对提交过来的表单数据进行敏感词过滤,我举个例子:
- VBScript code
<!--#include file="conn.asp"--> <% aname=request.form("aname") password=request.form("password") if aname ="" or password = "" then response.Write "用户名或密码不能为空!" response.End() else If instr(1,aname,chr(39))<>0 then %> <script language="javascript"> alert("请勿输入非法字符!!!"); window.location.href="login.asp"; </script> <% Else '执行匹配查询
------解决方案--------------------
以下为引用的内容:
dim sql_injdata,SQL_inj,SQL_Get,SQL_Data,Sql_Post
SQL_injdata = "'|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
SQL_inj = split(SQL_Injdata,"|")
If Request.QueryString<>"" Then
For Each SQL_Get In Request.QueryString
For SQL_Data=0 To Ubound(SQL_inj)
if instr(Request.QueryString(SQL_Get),Sql_Inj(Sql_DATA))>0 Then
Response.Write "<Script Language=javascript>alert('注意:请不要提交非法请求!');history.back(-1)</Script>"
Response.end
end if
next
Next .
End If
If Request.Form<>"" Then
For Each Sql_Post In Request.Form
For SQL_Data=0 To Ubound(SQL_inj)
if instr(Request.Form(Sql_Post),Sql_Inj(Sql_DATA))>0 Then
Response.Write "<Script Language=javascript>alert('注意:请不要提交非法请求!');history.back(-1)</Script>"
Response.end
end if
next
next
end if !
------解决方案--------------------
解决这个问题,首先是程序造成的,要把程序写严谨点,防止他们输入sql的一些sql关键字,上面的朋友些的都可以,联系我 我给你一些资料