动网论坛(DVBBS) admin_recycle.asp与recycle.asp页面存在SQL注入


添加时间:
2005-09-07

系统编号:
WAVDB-00660

影响版本:
DVBBS 7.1

程序介绍:

动网论坛做为动网主要服务产品之一,自2001年投入推广并运营以来,得到了国内外广大互联网用户的广泛好评和支持。做为国内第一的互联网论坛服务品牌,占据了国内论坛服务市场的70%以上的用户,动网论坛服务在一些如电影、下载、网游等热门网站的占有率甚至高达80%以上,是中国论坛服务领域事实上的标准。

漏洞分析:

admin_recycle.asp
 /--------------------------------------------------------------------------
 ...
 topicid=request( topicid )
 if request( action )<> 清空回收站  then
     if topicid=   or isnull(topicid) then
         Errmsg=Errmsg+ <li> + 请选择相关帖子后进行操作。 
         Founderr=true
     end if
 end if
 if request( tablename )= topic  then
     tablename= topic 
 elseif instr(request( tablename ), bbs )>0 then
     tablename=request( tablename )
 else
     Errmsg=Errmsg+ <li> + 错误的系统参数! 
     Founderr=true
 end if
 if not master then
     Errmsg=Errmsg+ <li> + 您不是系统管理员或者您还没有登陆。 
     Founderr=true
 end if
 ...
 
还原回收站内容
 sub redel()
 dim tempnum,todaynum
 if instr(tablename, bbs )>0 then
     sql= update  &tablename&  set locktopic=0 where Announceid in ( &TopicID& ) 
     conn.execute(sql)
 ...
 /--------------------------------------------------------------------------
 看了代码应该清楚了很多,当初页面是没有采用SESSION认证的,而且topicid并没有做过滤,还有喔页面仅要求tablename包含bbs而不采取其他任何过滤,导致了admin_recycle.asp页面存在注入的主要原因.而recycle.asp页面的漏洞,我们也可以看看代码就知道了!大家会觉得又点相似!
 代码如下: 
 If Request( reaction )= manage  Then
 dim topicid
 Dim trs,UpdateBoardID
 Dim fixid
 Manage_Main()
 ElseIf Request( reaction )= view  Then
 View()
 Else
 Main()
 End If
 Call Dvbbs.activeonline()
 call Dvbbs.footer()
 看看调用的Manage_Main函数和View函数,就会发现如下代码:
 If request( tablename )= dv_topic  Then
 tablename= dv_topic 
  ElseIf InStr(request( tablename ), bbs )>0 Then
 tablename=Trim(request( tablename ))
 If Len(tablename)>8 Then
  Response.redirect  showerr.asp?ErrCodes=<li>错误的系统参数!&action=OtherErr 
  End If
 Else
 Response.redirect  showerr.asp?ErrCodes=<li>错误的系统参数!&action=OtherErr 
  End If
 程序已经对tablename过滤了,又因If Len(tablename)>8 Then做了长度的限制了,如果我们提交的action为空,那么程序就会执行main函数,而这个函数调用的是AnnounceList1.
 Sub AnnounceList1()
 /------------------------------------------------------------------
 If instr(lcase(request( tablename )), bbs )>0 then
                      SQL= select AnnounceID,boardID,UserName,Topic,body,DateAndTime from  &replace(request( tablename ), 
 ,  )&  where boardid=444 and not parentid=0 order by announceid desc 

 

                     tablename=request( tablename )

              Else

                    SQL= select topicID,boardID,PostUserName,Title,title as body,DateAndTime from dv_topic where boardid=444 order by topicid desc 
                      tablename= dv_topic 
        End If
        set rs=server.createobject( adodb.recordset )
        If Not IsObject(Conn) Then ConnectionDatabase
        rs.open SQL,conn,1,1
        if rs.bof and rs.eof then
               
论坛无内容
               call showEmptyBoard1()
        else
               rs.PageSize = cint(Dvbbs.Forum_Setting(11))
               rs.AbsolutePage=currentpage
               page_count=0
                  totalrec=rs.recordcount
               call showPageList1()
        end if
 End sub
 ------------------------------------------------------------------/
 从代码的分析我们可以得知没有对tablename限制长度,但只能够实现查询,不能够修改数据库内容,所以我们可以利用union查询把dv_log中记录的后台管理账号和密码一次性查询出来



解决方案:
厂商补丁:
动网论坛
--------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://www.dvbbs.net/