PHP SSRF
Reading time: 3 minutes
tip
Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Angalia mpango wa usajili!
- Jiunge na 💬 kikundi cha Discord au kikundi cha telegram au tufuatilie kwenye Twitter 🐦 @hacktricks_live.
- Shiriki mbinu za udukuzi kwa kuwasilisha PRs kwa HackTricks na HackTricks Cloud repos za github.
SSRF PHP functions
Baadhi ya kazi kama file_get_contents(), fopen(), file(), md5_file() zinakubali URLs kama pembejeo ambazo zitafuatwa, hivyo kufanya uwezekano wa udhaifu wa SSRF ikiwa mtumiaji anaweza kudhibiti data:
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 kupitia DNS Rebinding
Kama ilivyoelezwa katika chapisho hili la blog, hata kazi ya Wordpress wp_safe_remote_get
ina udhaifu wa DNS rebinding, hivyo kufanya iweze kuwa hatarini kwa mashambulizi ya SSRF. Uthibitisho mkuu inayoita ni wp_http_validate_url, ambayo inakagua kwamba protokali ni http://
au https://
na kwamba bandari ni moja ya 80, 443, na 8080, lakini ina udhaifu wa DNS rebinding.
Kazi nyingine zenye udhaifu kulingana na chapisho ni:
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
Zaidi ya hayo, katika baadhi ya matukio inaweza kuwa hata inawezekana kutuma vichwa vya habari vya kiholela kupitia CRLF "udhaifu" katika kazi zilizopita:
# 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
Kwa maelezo zaidi kuhusu hiyo CRLF vuln, angalia hii bug https://bugs.php.net/bug.php?id=81680&edit=1
Kumbuka kwamba hizi kazi zinaweza kuwa na njia nyingine za kuweka vichwa vya habari vya kiholela katika maombi, kama:
$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);
tip
Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Angalia mpango wa usajili!
- Jiunge na 💬 kikundi cha Discord au kikundi cha telegram au tufuatilie kwenye Twitter 🐦 @hacktricks_live.
- Shiriki mbinu za udukuzi kwa kuwasilisha PRs kwa HackTricks na HackTricks Cloud repos za github.