当前位置:首页 > 网络编程 > WEB编程 > ASP > 关于SQL注入防御函数

关于SQL注入防御函数

点击次数:18 次 发布日期:2008-11-26 18:09:31 作者:源代码网
源代码网推荐

刚刚在最爱白菜那里看到了一个SQL注入防御的函数,突然想起以前看到这些文章时的一直有个问题想不通的,我对于SQL注入的防御很简单,就以下两个函数:

"####
"##
"## SQL注入攻击预防装置[字符型]
"##
"## @ data  ->处理的数据
"## @ length ->长度限制
"##
"## 例: strSql("SQL字符型数据",50)
"##
function strSql(data,length)
"########################################################################
 if length<>0 then data=left(data,length)
 strSql="""&replace(data,""","""")&"""
end function

"####
"##
"## SQL注入攻击预防装置[数字型]
"##
"## @ numeric ->数字
"##
"## 例: intSql(50)
"##
"## 2004/03/04,改良版,原因:IsNumeric检测MSSQL数据类型时会误判。
"##
function intSql(Numeric)
"########################################################################
 dim MM_intTemp
 On Error Resume Next
 if Numeric="" then Numeric=0
 MM_intTemp=csng(Numeric)
 if err=0 then
  intSql=Numeric
 else
  intSql=0
 end if
end function

strSQL的length不在防御SQL注入的范围中,是我为了防止插入字符超过字段长度而出错作的一个小小的防御。
我在网上看到各式各样的SQL注入防御函数,所以很好奇,这样的函数不能防御注入吗?谁知道这两个函数的漏洞请告诉我。


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华