CMS在处理浏览器提交的数据时使用filterPara函数过滤,这个函数接着调用了PreventSqlin和Checkxss两个函数进行字符过滤,PreventSqlin用来过滤SQL注入语句,而Checkxss是用来过滤跨站输入。
关键就是在PreventSqlin函数
`/inc/AspCms_CommonFun.asp`
函数内容如下:
```
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” ‘这是函数要过滤的SQL关键词
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 ‘如果出现了 < > ‘ “ ; 则将其HTML转义
content=replace(content,sqlArray(i),speStr,1,-1,1) ‘如果出现关键字则将其替换为空。
end if
next
preventSqlin=content
End Function
```
该函数乍看的确是安全的,但是还有一种情况就是用户提交的是类似于SELECT的但是包含过滤字符,当多余的字符被过滤掉之后反而形成一个SELECT关键字,这个基本同于ASPCMS的SQL注入漏洞问题,实际上应该用循环匹配替换。
暂无评论