我的ASP老是给人注入,怎么防,高手指点!!

来源:百度知道 编辑:UC知道 时间:2024/05/06 02:25:21
这是我的connn
<!--#include file="sqlincopyurl.asp"-->
<!-- #include file="md5.asp"-->
<%
dbPath = "cadasydasuydy#.aspx" '可以自己修改数据库存放路径和文件名
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(dbPath)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
'response.Write err.description
Err.clear
Set conn = NoThing

Response.Write "数据库连接出错!"
Response.End
End If
'*********************************
'*********************************
function message1(message)
response.Write("<script>alert('"&message&"');history.back();</script>")
response.End()
end function

%>

---------------在connn 的开头调用<!--#include file="SF_Sql.asp"-->
SF_Sql.asp内容为下,粘贴复制即可!
<%
Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstr
'自定义需要过滤的字串,用 "防" 分隔
websql="update|count|and|exec|insert|chr|mid|master|delete|truncate|declare|char|script|request|’"
Fy_In = replace(websql,"’","'")
'----------------------------------
Fy_Inf = split(Fy_In,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each Fy_Post In Request.Form

For Fy_Xh=0 To Ubound(Fy_Inf)
If Instr(LCase(Request.Form(Fy_Post)),Fy_Inf(Fy_Xh))<>0 Then
response.write"<script>alert('操作错误,下面是产生错误的可能原因:\n\n·在您提交的资料中含有敏感字符');history.go(-1);</script>"
response.end
End If
Next

Next
End If
'--------GET部份-------------------
If Request.QueryString<