剛剛在最愛(ài)白菜那里看到了一個(gè)SQL注入防御的函數(shù),突然想起以前看到這些文章時(shí)的一直有個(gè)問(wèn)題想不通的,我對(duì)于SQL注入的防御很簡(jiǎn)單,就以下兩個(gè)函數(shù):
'#### '## '## SQL注入攻擊預(yù)防裝置[字符型] '## '## @ data ->處理的數(shù)據(jù) '## @ length ->長(zhǎng)度限制 '## '## 例: strSql("SQL字符型數(shù)據(jù)",50) '## function strSql(data,length) '######################################################################## if length<>0 then data=left(data,length) strSql="'"&replace(data,"'","''")&"'" end function
'#### '## '## SQL注入攻擊預(yù)防裝置[數(shù)字型] '## '## @ numeric ->數(shù)字 '## '## 例: intSql(50) '## '## 2004/03/04,改良版,原因:IsNumeric檢測(cè)MSSQL數(shù)據(jù)類型時(shí)會(huì)誤判。 '## 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注入的范圍中,是我為了防止插入字符超過(guò)字段長(zhǎng)度而出錯(cuò)作的一個(gè)小小的防御。 我在網(wǎng)上看到各式各樣的SQL注入防御函數(shù),所以很好奇,這樣的函數(shù)不能防御注入嗎?誰(shuí)知道這兩個(gè)函數(shù)的漏洞請(qǐng)告訴我。
|
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!