|
引用了“孤独冷雨”版主的防SQL注入的代码,后台的文本编辑器是eWebSoft,从WORD或者是从别的网上复制出来的文章粘贴入去,只要不清除格式,,就会被这段防SQL代码给阻隔提交,知道是因为这样的复制会有好多特殊字符出现,,但习惯性客户的操作都是喜欢直接这样粘贴的,,,能有什么好的办法可以防得了注入又可以不限制自己的输入。。
程序代码:
<%
Function CheckSql() '防止SQL注入
Dim sql_injdata
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('请不要在参数中包含非法字符!');}</Script>"
Response.Write "本站有服务不到位的地方,请多提建议!如果你糊来小心我掐死你↓<br><br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br><br>"
Response.Write "操作时间:"&Now&"<br><br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br><br>"
Response.Write "提交方式:Get<br><br>"
Response.Write "提交参数:"&SQL_Get&"<br><br>"
Response.Write "提交数据:"&Request.QueryString(SQL_Get)
response.Write "<meta http-equiv='refresh' content='3;url=/'>"
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('请不要在参数中包含非法字符!');</Script>"
Response.Write "本站有服务不到位的地方,请多提建议!如果你糊来小心我掐死你↓<br><br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br><br>"
Response.Write "操作时间:"&Now&"<br><br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br><br>"
Response.Write "提交方式:Post<br><br>"
Response.Write "提交参数:"&SQL_Get&"<br><br>"
Response.Write "提交数据:"&Request.Form(SQL_post)
Response.end
end if
next
next
end if
End Function
'以上为SQL防注入
%> |
|