mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-23 05:03:35 +00:00
136 lines
7.1 KiB
Markdown
136 lines
7.1 KiB
Markdown
# Proxy / WAF Beskermingsomleiding
|
|
|
|
<details>
|
|
|
|
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
|
|
|
Ander maniere om HackTricks te ondersteun:
|
|
|
|
* As jy wil sien dat jou **maatskappy geadverteer word in HackTricks** of **HackTricks aflaai in PDF-formaat** Kontroleer die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
|
|
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
|
* Ontdek [**Die PEASS-familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFT's**](https://opensea.io/collection/the-peass-family)
|
|
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
|
|
|
|
</details>
|
|
|
|
<figure><img src="/.gitbook/assets/WebSec_1500x400_10fps_21sn_lightoptimized_v2.gif" alt=""><figcaption></figcaption></figure>
|
|
|
|
{% embed url="https://websec.nl/" %}
|
|
|
|
## Bypass Nginx ACL-reëls met Padnaammanipulasie <a href="#heading-pathname-manipulation-bypassing-reverse-proxies-and-load-balancers-security-rules" id="heading-pathname-manipulation-bypassing-reverse-proxies-and-load-balancers-security-rules"></a>
|
|
|
|
Tegnieke [van hierdie navorsing](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies).
|
|
|
|
Nginx-reëlvoorbeeld:
|
|
```plaintext
|
|
location = /admin {
|
|
deny all;
|
|
}
|
|
|
|
location = /admin/ {
|
|
deny all;
|
|
}
|
|
```
|
|
### **NodeJS - Express**
|
|
|
|
| Nginx Weergawe | **Node.js Omgang Karakters** |
|
|
| ------------- | ----------------------------- |
|
|
| 1.22.0 | `\xA0` |
|
|
| 1.21.6 | `\xA0` |
|
|
| 1.20.2 | `\xA0`, `\x09`, `\x0C` |
|
|
| 1.18.0 | `\xA0`, `\x09`, `\x0C` |
|
|
| 1.16.1 | `\xA0`, `\x09`, `\x0C` |
|
|
|
|
### **Flask**
|
|
|
|
| Nginx Weergawe | **Flask Omgang Karakters** |
|
|
| ------------- | -------------------------------------------------------------- |
|
|
| 1.22.0 | `\x85`, `\xA0` |
|
|
| 1.21.6 | `\x85`, `\xA0` |
|
|
| 1.20.2 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
|
|
| 1.18.0 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
|
|
| 1.16.1 | `\x85`, `\xA0`, `\x1F`, `\x1E`, `\x1D`, `\x1C`, `\x0C`, `\x0B` |
|
|
|
|
### **Spring Boot**
|
|
|
|
| Nginx Weergawe | **Spring Boot Omgang Karakters** |
|
|
| ------------- | --------------------------------- |
|
|
| 1.22.0 | `;` |
|
|
| 1.21.6 | `;` |
|
|
| 1.20.2 | `\x09`, `;` |
|
|
| 1.18.0 | `\x09`, `;` |
|
|
| 1.16.1 | `\x09`, `;` |
|
|
|
|
### **PHP-FPM**
|
|
|
|
Nginx FPM konfigurasie:
|
|
```plaintext
|
|
location = /admin.php {
|
|
deny all;
|
|
}
|
|
|
|
location ~ \.php$ {
|
|
include snippets/fastcgi-php.conf;
|
|
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
|
|
}
|
|
```
|
|
Nginx is ingestel om toegang tot `/admin.php` te blokkeer, maar dit is moontlik om dit te omseil deur toegang tot `/admin.php/index.php` te verkry.
|
|
|
|
### Hoe om te voorkom
|
|
```plaintext
|
|
location ~* ^/admin {
|
|
deny all;
|
|
}
|
|
```
|
|
## Bypass Mod Security Reëls <a href="#heading-bypassing-aws-waf-acl" id="heading-bypassing-aws-waf-acl"></a>
|
|
|
|
### Pad Verwarring
|
|
|
|
[**In hierdie pos**](https://blog.sicuranext.com/modsecurity-path-confusion-bugs-bypass/) word verduidelik dat ModSecurity v3 (tot 3.0.12), **die `REQUEST_FILENAME`** veranderlike onvanpaste geïmplementeer het wat veronderstel was om die benaderde pad te bevat (tot by die begin van die parameters). Dit het 'n URL-dekodeer uitgevoer om die pad te kry.\
|
|
Daarom sal 'n versoek soos `http://example.com/foo%3f';alert(1);foo=` in mod security aanneem dat die pad net `/foo` is omdat `%3f` in `?` omskep word wat die URL-pad beëindig, maar eintlik sal die pad wat 'n bediener ontvang `/foo%3f';alert(1);foo=` wees.
|
|
|
|
Die veranderlikes `REQUEST_BASENAME` en `PATH_INFO` was ook deur hierdie fout geraak.
|
|
|
|
Iets soortgelyks het in weergawe 2 van Mod Security gebeur wat dit moontlik gemaak het om 'n beskerming te omseil wat voorkom dat 'n gebruiker lêers met spesifieke uitbreidings wat verband hou met rugsteunlêers (soos `.bak`) toegang kry deur eenvoudig die punt URL-gekodeer in `%2e` te stuur, byvoorbeeld: `https://example.com/backup%2ebak`.
|
|
|
|
## Bypass AWS WAF ACL <a href="#heading-bypassing-aws-waf-acl" id="heading-bypassing-aws-waf-acl"></a>
|
|
|
|
### Misvormde Kopteks
|
|
|
|
[Hierdie navorsing](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies) noem dat dit moontlik was om AWS WAF-reëls wat oor HTTP-koptekste toegepas is, te omseil deur 'n "misvormde" kopteks te stuur wat nie behoorlik deur AWS gepars is nie, maar wel deur die agterste bediener.
|
|
|
|
Byvoorbeeld, deur die volgende versoek met 'n SQL-inspuiting in die kopteks X-Query te stuur:
|
|
```http
|
|
GET / HTTP/1.1\r\n
|
|
Host: target.com\r\n
|
|
X-Query: Value\r\n
|
|
\t' or '1'='1' -- \r\n
|
|
Connection: close\r\n
|
|
\r\n
|
|
```
|
|
Dit was moontlik om AWS WAF te omseil omdat dit nie sou verstaan dat die volgende lyn deel is van die waarde van die kopstuk nie terwyl die NODEJS-bediener dit wel gedoen het (dit is reggestel).
|
|
|
|
## Verwysings
|
|
|
|
* [https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies)
|
|
* [https://blog.sicuranext.com/modsecurity-path-confusion-bugs-bypass/](https://blog.sicuranext.com/modsecurity-path-confusion-bugs-bypass/)
|
|
|
|
|
|
<figure><img src="/.gitbook/assets/WebSec_1500x400_10fps_21sn_lightoptimized_v2.gif" alt=""><figcaption></figcaption></figure>
|
|
|
|
{% embed url="https://websec.nl/" %}
|
|
|
|
<details>
|
|
|
|
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
|
|
|
Ander maniere om HackTricks te ondersteun:
|
|
|
|
* As jy wil sien dat jou **maatskappy geadverteer word in HackTricks** of **HackTricks aflaai in PDF-formaat** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
|
|
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
|
* Ontdek [**Die PEASS-familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFT's**](https://opensea.io/collection/the-peass-family)
|
|
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
|
|
|
|
</details>
|