您现在的位置是:网站首页> 编程资料编程资料
asp 获取参数值与sql安全过滤参数函数代码_应用技巧_
2023-05-25
337人已围观
简介 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注入,加强的防护。
相关内容
- ASP中Server.Execute和Execute实现动态包含(include)脚本的区别_应用技巧_
- ASP上传漏洞之利用CHR(0)绕过扩展名检测脚本_应用技巧_
- Asp限制IP访问 阻止某一个IP段禁止访问本站的代码_应用技巧_
- 一个改进的ASP生成SQL命令字符串类的代码[已测]_应用技巧_
- asp在服务器把 XML 转换为 XHTML的实现代码_应用技巧_
- asp提示Server 对象 错误 ASP 0178 : 80070005_应用技巧_
- ASP:ActiveX不能创建Scripting.FileSystemObject对象解决办法_应用技巧_
- asp目录读写权限检测脚本 TestFolder_应用技巧_
- 防ASP注入终极防范_应用技巧_
- 较为全面的asp防CC攻击代码分享_应用技巧_
