mssql数据库被注入js代码

来源:百度知道 编辑:UC知道 时间:2024/09/28 14:59:06
我的网站asp+sql 写的,最近在数据库中发现被注入了js代码。
我已经用update replace了。
请教有什么办法防御再次注入?我的想法是通过判断url中的参数,不过请教这段代码如何写,写在连接数据库文件中吗?
请给出代码谢谢

<%
If EnableStopInjection = True Then
Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstr
Fy_In = "'|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
Fy_Inf = split(Fy_In,"|")
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 Language='JavaScript'>alert('警告:参数非法!');</Script>"
Response.End
End If
Next
Next
End If

If Request.QueryString<>"" Then
For Each Fy_Get In Request.QueryString
For Fy_Xh=0 To Ubound(Fy_Inf)
If Instr(LCase(Request.QueryString(Fy_Get)),Fy_Inf(Fy_Xh))<>0 Then
Response.Write "<Script Language='JavaScript'>alert('警告:参数非法