剛剛在最愛白菜那里看到了一個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注入防御函數,所以很好奇,這樣的函數不能防御注入嗎?誰知道這兩個函數的漏洞請告訴我。

