主頁(yè) > 知識(shí)庫(kù) > asp 獲取參數(shù)值與sql安全過(guò)濾參數(shù)函數(shù)代碼

asp 獲取參數(shù)值與sql安全過(guò)濾參數(shù)函數(shù)代碼

熱門標(biāo)簽:阿里云 電子圍欄 Linux服務(wù)器 Mysql連接數(shù)設(shè)置 團(tuán)購(gòu)網(wǎng)站 銀行業(yè)務(wù) 服務(wù)器配置 科大訊飛語(yǔ)音識(shí)別系統(tǒng)
復(fù)制代碼 代碼如下:

'獲取參數(shù)值
Function getForm(element,ftype)
Select case ftype
case "get"
getForm=trim(request.QueryString(element))
case "post"
getForm=trim(request.Form(element))
case "both"
if isNul(request.QueryString(element)) then getForm=trim(request.Form(element)) else getForm=trim(request.QueryString(element))
End Select
getForm=replace(getForm,CHR(34),"quot;")
getForm=replace(getForm,CHR(39),"apos;")
End Function
'主要功能就是獲取參數(shù)值,比直接用request("element")要安全很多


'過(guò)濾參數(shù)
Function filterPara(byVal Para)
filterPara=preventSqlin(Checkxss(Para))
End Function

Function preventSqlin(content)
dim sqlStr,sqlArray,i,speStr
sqlStr="|>|%|%27|'|''|;|*|and|exec|dbcc|alter|drop|insert|select|update|delete|count|master|truncate|char|declare|where|set|declare|mid|chr"
if isNul(content) then Exit Function
sqlArray=split(sqlStr,"|")
for i=lbound(sqlArray) to ubound(sqlArray)
if instr(lcase(content),sqlArray(i))>0 then
select case sqlArray(i)
case "":speStr="lt;"
case ">":speStr="gt;"
case "'","""":speStr="quot;"
'case ";":speStr=";"
case else:speStr=""
end select
content=replace(content,sqlArray(i),speStr,1,-1,1)
end if
next
preventSqlin=content
End Function
'上面的參數(shù)過(guò)濾函主要是防止sql注入,加強(qiáng)的防護(hù)。

標(biāo)簽:萍鄉(xiāng) 蚌埠 衡水 棗莊 衢州 廣元 大理 江蘇

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp 獲取參數(shù)值與sql安全過(guò)濾參數(shù)函數(shù)代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266