文章作者:光芒果
信息来源:(应该是黑防吧)
说起来我与BBSXP还算蛮有缘的,因为我第一次建网站用的就是BBSXP3.0,此后又一直用到了4.1,只不过因为种种原因后来不用了(绝非安全因素,那时我对网络安全还是一窍不通,呵呵)。近日看到了许多文章都是讲BBSXP的漏洞的,从最早的“编辑贴子”处的Cookies欺骗到最新的搜索页面的注入攻击,BBSXP可谓是千疮百孔。于是我又想起了我的老朋友--BBSXP。在yuzi的授权下我于大年三十夜在访网站对最新的BBSXP做了一次安全检测。
现在官方用的是BBSXP5.15,而公布出来的程序最新的似乎是5.13,估计是5.15还在测试中的版本吧。但既然是yuzi授权的,问一个5.15的程序自然也非难事。拿到5.15的程序后,我 就翻看了几个已知漏洞的文件代码,好像都补上了,我只好从其他地方入手了。翻到blog.asp这个文时,我发现了如下代码:
<!-- #include file="setup.asp" --><%
username=HTMLEncode(Request("username"))
id=HTMLEncode(Request("id"))
top
if id<>"" then
sql="select * from [calendar] where id="&id&" order by id Desc"
else
sql="select * from [calendar] where (hide=0 or username='"&Request.Cookies("username")&"') and username='"&username&"' order by id Desc"
end if
rs.Open sql,Conn,1
if rs.eof then error("<li>该用户暂时没有任何日志")
%>
<table class="a2" cellSpacing="1" cellPadding="4" width="97%" align="center" border="0">
<tr class="a3">
<td colSpan="2">
<table cellSpacing="0" cellPadding="0" width="100%" border="0" id="table2">
<tr>
<td height="18"> <img src="images/Forum_nav.gif"> <%ClubTree%> → <a href="calendar.asp">社区日志</a> → <span id=title><a href="blog.asp">网络日志</a></span></td>
<td align="right" height="18">
<img src="images/jt.gif"> <a href=calendar.asp?menu=newcalendar>发表日志</a></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table border="0" width="97%" align="center">
<tr>
<td align="center">
<table class="a2" style="WIDTH:100%" height="100%" cellspacing="1" cellpadding="3" border="0" id="table5">
<tr>
<td class="a1" align="middle" height="25"><b>网络日志</b></td>
</tr>
<tr align="middle">
<td bgcolor="#ffffff" align="left" height="100">
<%
pagesetup=10 '设定每页的显示数量
rs.pagesize=pagesetup
TotalPage=rs.pagecount '总页数
PageCount = cint(Request.QueryString("ToPage"))
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>0 then rs.absolutepage=PageCount '跳转到指定页数
i=0
Do While Not RS.EOF and i<pagesetup
i=i+1
username=rs("username")
content=rs("content")
if id="" then
content=ReplaceText(content,"<[^>]*>","")
if len(content)>200 then content=left(""&content&"",200)&"..."
end if
%>
<table border="0" width="100%" cellspacing="10">
<tr>
<td>
<b><font size="4"><%=rs("title")%></font></b><br>
<br><%=content%>
<%if rs("hide")=1 then%><br><br>注:<font color="#FF0000">本篇日志为隐藏状态</font><%end if%>
<hr>
<%if id="" then%>
<a href="?id=<%=rs("id")%>">阅读全文</a>
<%else%>
<font color="#C0C0C0">阅读全文</font>
<%end if%>
|
<%if Request.Cookies("username")=username then%>
<a href="calendar.asp?menu=newcalendar&id=<%=rs("id")%>">编辑</a>
<%else%>
<font color="#C0C0C0">编辑</font>
<%end if%>
|
<%if username= Request.Cookies("username") or membercode > 3 then%>
<a href="calendar.asp?menu=del&id=<%=rs("id")%>" onclick="checkclick('您确定要删除此条日志?')">删除</a>
<%else%>
<font color="#C0C0C0">删除</font>
<%end if%>
| <%=rs("addtime")%> by <a href="Profile.asp?username=<%=username%>"><%=username%></a></td>
</tr>
</table>
<%
RS.MoveNext
loop
RS.Close
%>
</td>
</tr>
</table>
<p><b>[<script>ShowPage(<%=TotalPage%>,<%=PageCount%>,"username=<%=username%>")</script>]</b></p>
</td>
<td width="200" align="right" valign="top">
<table class="a2" style="WIDTH:95%" cellspacing="1" cellpadding="3" border="0">
<tr class="a1">
<td align="middle" height="25"><b>档案文件</b></td>
</tr>
<tr align="middle">
<td bgcolor="#ffffff">
<%
sql="select * from [user] where username='"&username&"'"
Set Rs=Conn.Execute(sql)
select case rs("sex")
case "male"
sex="男"
case "female"
sex="女"
end select
if rs("birthday")<>"" then birthyear=year(now)-split(rs("birthday"),"-")(0)
userphoto=rs("userphoto")
UserInfo=split(rs("UserInfo"),"/")
realname=UserInfo(0)
country=UserInfo(1)
province=UserInfo(2)
city=UserInfo(3)
postcode=UserInfo(4)
blood=UserInfo(5)
belief=UserInfo(6)
occupation=UserInfo(7)
marital=UserInfo(8)
education=UserInfo(9)
college=UserInfo(10)
address=UserInfo(11)
phone=UserInfo(12)
character=UserInfo(13)
personal=UserInfo(14)
rs.close
%>
<script>
if("<%=userphoto%>"!=""){
document.write("<a target=_blank href=<%=userphoto%>><img src=<%=userphoto%> border=0 width=150></a>")
}
</script>
<table cellspacing="2" cellpadding="2" width="100%" border="0">
<tr>
<td valign="top">姓名:</td>
<td width="120" ><%=username%></td>
</tr>
<tr>
<td valign="top">年龄:</td>
<td width="120"><%=birthyear%>
</td>
</tr>
<tr>
<td valign="top">性别:</td>
<td width="120"><%=sex%></td>
</tr>
<tr>
<td valign="top">职业:</td>
<td width="120"><%=occupation%></td>
</tr>
<tr>
<td valign="top"><font class="bold">位置:</font></td>
<td width="120"><%=country%><br>
<%=province%><br>
<%=city%></td>
</tr>
<tr>
<td colspan="2"><%=personal%></td>
</tr>
</table>
</td>
</tr>
<tr align="middle">
<td bgcolor="#ffffff" align="right">
<a href="Profile.asp?username=<%=username%>">查看档案文件详细信息</a></td>
</tr>
</table>
<br>
<table class="a2" style="WIDTH:95%" cellspacing="1" cellpadding="3" border="0">
<tr>
<td class="a1" align="middle" height="25"><b>以往公开日志</b></td>
</tr>
<tr bgcolor="#ffffff">
<td>
<%
sql="select top 10 * from [calendar] where hide=0 and username='"&username&"' order by id Desc"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
%><li><a href=?id=<%=rs("id")%>><%=rs("title")%></a> (<%=rs("adddate")%>)</li><%
RS.MoveNext
loop
RS.Close
%>
</td></tr>
</table>
</td>
</tr>
</table>
<script>title.innerHTML='<a href="blog.asp?username=<%=username%>">“<%=username%>”网络日志</a>'</script>
<%
htmlend
%>
好家伙,什么都没过滤啊!我赶紧到官方测试了一下。这个文件是BBSXP中自带的博客(wtf:BBSXP中还有博客?看来功能还挺全。但安全性就……)。随便打开一篇用户的日记,在后边加了个单引号,返回如图1所示页面。然后我又用1=1和1=2测试,分别返回如图2、3所示页面。太好了,可以注入。马上拿出NBSI2,填入注入地址,不一会数据库信息就出来了(图4),可惜只是db_ower权限,没关系,我们来跑用户名和密码吧,于是我就去猜解,但不知为什么,总是提示“发生意外错误”无法猜解(图5),可能是官方配置比较好吧。不管他了,反正是检测而矣,我才懒得用手动去猜呢。
本来到这里已是收获不小了 ,可我还想找出其他漏洞,不过这一行行的代码看下去太头疼,还是自己慢慢用手动来试吧。果然,检测到_blank>http://bbs.yuzi.net/favorites.asp?menu=delweb&id=xx 这个url时,我又发现了一个小小的惊喜.这里虽然不能注入,但似乎可以删除任意用户的收藏,而且页面一直在不停地循环。但后来我把这个洞告诉yuzi时他却说这里虽提s示删除成功其实并没有删除(最搞笑的是我直接把 _blank>http://bbs.yuzi.net/favorites.asp?menu=delweb&id=xx这个url给他时他还真直接去访问这个地址,而没有把xx改为数字,还跟我说这没问题,我晕绝),事实是否如此我也没有去具体看过了,但页面一直循环至少可以dos吧?
好了,再过几个小时就是鸡年了,大过年的,别玩得太过了,给自己和yuzi都休息一下吗,呵。,但大家可要注意了,我做的一切都是经过yuzi授权的,大家可不要自己乱搞,否则进了班房可别怪我。不过话又说回来,我检测完就把漏洞和补救方法告诉了yuzi,这篇文章发出来恐怕也要个把月后了,如果yuzi还没补上也怪不得我了。如果大家还有什么问题就到我朋友的小站_blank>http://www.shouzai.net/bbs讨论吧。
