PHP SSRF
Reading time: 4 minutes
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
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");
Wordpress SSRF via DNS Rebinding
このブログ記事で説明されているように、Wordpressの関数 wp_safe_remote_get
もDNSリバインディングに対して脆弱であり、SSRF攻撃に対して潜在的に脆弱です。呼び出される主な検証は wp_http_validate_url で、プロトコルが http://
または https://
であり、ポートが 80、443、および 8080 のいずれかであることを確認しますが、DNSリバインディングに対して脆弱です。
投稿によると、他の脆弱な関数は次のとおりです:
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
さらに、場合によっては、前述の関数における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
warning
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);
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。