ssrf访问内网及url地址过滤绕过
<?php
/*//设置open_basedir
ini_set("open_basedir", "/home/shawn/www/index/");
*/
if (isset($_GET['file'])) {
$file = trim($_GET['file']);
} else {
$file = "main.html";
}
// disallow ip
if (preg_match('/^(http:\/\/)+([^\/]+)/i', $file, $domain)) {
$domain = $domain[2];
if (stripos($domain, ".") !== false) {
die("Hacker");
}
}
if( @file_get_contents($file)!=''){
echo file_get_contents($file);
}else{
$str=<<<EOF
如上引用了XDCTF的一道题目的源码,此题需要get提交file变量,并且正则匹配file变量中的ip地址,点号被过滤。
第一种绕过方式:
file=php://filter/resource=http://127.0.0.1/(这是针对这道题的正则匹配来绕过,观察正则表达式,是从file变量开始匹配,如此构造payload匹配不到ip地址巧妙绕过)
第二种绕过方式:
转ip地址为整型或者十六进制
第三种绕过方式:
因为https://i.cnblogs.com@127.0.0.1与http://127.0.0.1的请求是一样的。那么便可构造payload绕过。
这道题读取/etc/hosts 或者 /proc/net/arp
然后在内网的一台服务器主页可以找到flag 比较坑的是页面内容是404 但是响应码是200 长度又和别的ip的404页面一模一样。
更多关于ssrf可以到http://bobao.360.cn/learning/detail/240.html学习。

浙公网安备 33010602011771号