一聚教程网:一个值得你收藏的教程网站

热门教程

关于SQL注入防御函数

时间:2022-06-30 10:30:59 编辑:袖梨 来源:一聚教程网

刚刚在最爱白菜那里看到了一个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注入防御函数,所以很好奇,这样的函数不能防御注入吗?谁知道这两个函数的漏洞请告诉我。

热门栏目