asp 获取参数值与sql安全过滤参数函数代码
代码如下:
'获取参数值 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),""") getForm=replace(getForm,CHR(39),"'") End Function '主要功能就是获取参数值,比直接用request("element")要安全很多 '过滤参数 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="<" case ">":speStr=">" case "'","""":speStr=""" 'case ";":speStr=";" case else:speStr="" end select content=replace(content,sqlArray(i),speStr,1,-1,1) end if next preventSqlin=content End Function '上面的参数过滤函主要是防止sql注入,加强的防护。
相关推荐
wikiwater 2020-10-27
IdeaElements 2020-08-19
Sophiego 2020-08-16
Kakoola 2020-08-01
Kakoola 2020-07-29
ELEMENTS爱乐冬雨 2020-07-18
ELEMENTS爱乐小超 2020-07-04
ELEMENTS爱乐小超 2020-07-04
Kakoola 2020-06-28
Feastaw 2020-06-18
Wmeng0 2020-06-14
ELEMENTS爱乐冬雨 2020-06-14
云之高水之远 2020-06-14
哈喽elements 2020-06-14
Feastaw 2020-06-11