下面是一款 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 "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 "alert('注意:请不要提交非法请求!');history.back(-1) script>"
response.end
end if
next
next
end if
%>
在时就进行函数调用
防注入就是过滤特殊字符和sql命令哦如下
防跨站的代码我就不提供了.
sub f_sql()
dim q_post,q_get,q_in,q_inf,i
'q_in = "'|and|exec|insert|select|delete|update|count|*|chr|mid|master|truncate|char|declare" '定义不能通过的字符,
q_in = "'|exec|insert|select|delete|update|*|chr|truncate|declare|'"
q_inf = split(q_in , "|")