4.6 KiB
PHP SSRF
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the 💬 Discord group or the telegram group or follow us on Twitter 🐦 @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
Funzioni PHP SSRF
Alcune funzioni come file_get_contents(), fopen(), file(), md5_file() accettano URL come input che seguiranno, rendendo possibili vulnerabilità SSRF se l'utente può controllare i dati:
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 tramite DNS Rebinding
Come spiegato in questo post del blog, anche la funzione di Wordpress wp_safe_remote_get
è vulnerabile al DNS rebinding, rendendola potenzialmente vulnerabile ad attacchi SSRF. La principale validazione che chiama è wp_http_validate_url, che controlla che il protocollo sia http://
o https://
e che la porta sia una delle 80, 443 e 8080, ma è vulnerabile al DNS rebinding.
Altre funzioni vulnerabili secondo il post sono:
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
Inoltre, in alcuni casi potrebbe essere persino possibile inviare intestazioni arbitrarie tramite "vulnerabilità" CRLF nelle funzioni precedenti:
# 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
{% hint style="warning" %} Per ulteriori informazioni su quella vulnerabilità CRLF, controlla questo bug https://bugs.php.net/bug.php?id=81680&edit=1 {% endhint %}
Nota che queste funzioni potrebbero avere altri metodi per impostare intestazioni arbitrarie nelle richieste, come:
$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);
{% hint style="success" %}
Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE)
Supporta HackTricks
- Controlla i piani di abbonamento!
- Unisciti al 💬 gruppo Discord o al gruppo telegram o seguici su Twitter 🐦 @hacktricks_live.
- Condividi trucchi di hacking inviando PR ai HackTricks e HackTricks Cloud repos su github.