mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
65 lines
3.2 KiB
Markdown
65 lines
3.2 KiB
Markdown
# PHP SSRF
|
||
|
||
{{#include ../../../banners/hacktricks-training.md}}
|
||
|
||
### SSRF PHP functions
|
||
|
||
Ορισμένες συναρτήσεις όπως οι **file_get_contents(), fopen(), file(), md5_file()** δέχονται URLs ως είσοδο που θα ακολουθήσουν, κάνοντάς τις **πιθανές ευπάθειες SSRF** αν ο χρήστης μπορεί να ελέγξει τα δεδομένα:
|
||
```php
|
||
file_get_contents("http://127.0.0.1:8081");
|
||
fopen("http://127.0.0.1:8081", "r");
|
||
file("http://127.0.0.1:8081");
|
||
md5_file("http://127.0.0.1:8081");
|
||
```
|
||
### Wordpress SSRF μέσω DNS Rebinding
|
||
|
||
Όπως [**εξηγείται σε αυτή την ανάρτηση του blog**](https://patchstack.com/articles/exploring-the-unpatched-wordpress-ssrf), ακόμη και η λειτουργία Wordpress **`wp_safe_remote_get`** είναι ευάλωτη σε DNS rebinding, καθιστώντας την δυνητικά ευάλωτη σε επιθέσεις SSRF. Η κύρια επικύρωση που καλεί είναι **wp_http_validate_url**, η οποία ελέγχει ότι το πρωτόκολλο είναι `http://` ή `https://` και ότι η θύρα είναι μία από τις **80**, **443**, και **8080**, αλλά είναι **ευάλωτη σε DNS rebinding**.
|
||
|
||
Άλλες ευάλωτες λειτουργίες σύμφωνα με την ανάρτηση είναι:
|
||
|
||
- `wp_safe_remote_request()`
|
||
- `wp_safe_remote_post()`
|
||
- `wp_safe_remote_head()`
|
||
- `WP_REST_URL_Details_Controller::get_remote_url()`
|
||
- `download_url()`
|
||
- `wp_remote_fopen()`
|
||
- `WP_oEmbed::discover()`
|
||
|
||
### CRLF
|
||
|
||
Επιπλέον, σε ορισμένες περιπτώσεις μπορεί να είναι ακόμη δυνατό να σταλούν αυθαίρετοι headers μέσω "ευπαθειών" CRLF στις προηγούμενες λειτουργίες:
|
||
```php
|
||
# The following will create a header called from with value Hi and
|
||
# an extra header "Injected: I HAVE IT"
|
||
ini_set("from", "Hi\r\nInjected: I HAVE IT");
|
||
file_get_contents("http://127.0.0.1:8081");
|
||
|
||
GET / HTTP/1.1
|
||
From: Hi
|
||
Injected: I HAVE IT
|
||
Host: 127.0.0.1:8081
|
||
Connection: close
|
||
|
||
# Any of the previously mentioned functions will send those headers
|
||
```
|
||
> [!WARNING]
|
||
> Για περισσότερες πληροφορίες σχετικά με αυτήν την ευπάθεια CRLF, ελέγξτε αυτό το σφάλμα [https://bugs.php.net/bug.php?id=81680\&edit=1](https://bugs.php.net/bug.php?id=81680&edit=1)
|
||
|
||
Σημειώστε ότι αυτές οι συναρτήσεις μπορεί να έχουν άλλες μεθόδους για να ορίσουν αυθαίρετους κεφαλίδες σε αιτήματα, όπως:
|
||
```php
|
||
$url = "";
|
||
|
||
$options = array(
|
||
'http'=>array(
|
||
'method'=>"GET",
|
||
'header'=>"Accept-language: en\r\n" .
|
||
"Cookie: foo=bar\r\n" . // check function.stream-context-create on php.net
|
||
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" // i.e. An iPad
|
||
)
|
||
);
|
||
|
||
$context = stream_context_create($options);
|
||
$file = file_get_contents($url, false, $context);
|
||
```
|
||
{{#include ../../../banners/hacktricks-training.md}}
|