PHP SSRF

htARTE (HackTricks AWS Red Team 전문가)로부터 AWS 해킹을 처음부터 전문가까지 배우세요!

다른 방법으로 HackTricks를 지원하는 방법:

Try Hard Security Group


SSRF PHP 함수

일부 함수인 **file_get_contents(), fopen(), file(), md5_file()**은 입력으로 URL을 허용하며, 사용자가 데이터를 제어할 수 있다면 가능한 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);

Try Hard Security Group

htARTE (HackTricks AWS Red Team Expert)를 통해 제로부터 영웅이 되는 AWS 해킹을 배우세요

HackTricks를 지원하는 다른 방법:

Last updated