<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if(preg_match('/^http:\/\/ctf\..*show$/i',$url)){echo file_get_contents($url);
}
检测url
- 以
**<font style="color:rgb(64, 64, 64);background-color:rgb(236, 236, 236);">http://ctf.</font>**
开头(不区分大小写,**<font style="color:rgb(64, 64, 64);background-color:rgb(236, 236, 236);">/i</font>**
修饰符)。 - 中间可以是任意字符(
**<font style="color:rgb(64, 64, 64);background-color:rgb(236, 236, 236);">.*</font>**
)。 - 以
**<font style="color:rgb(64, 64, 64);background-color:rgb(236, 236, 236);">show</font>**
结尾。
我本来想找一下可以解析为127.0.0.1的域名中有没有存在ctf.
开头的域名,结果没有。只能另辟蹊径
没想到这道题问deepseek居然可以直接出答案
解法
[<font style="color:#000000;">http://ctf.@127.0.0.1/flag.php?show</font>](http://ctf.@127.0.0.1/flag.php?show)
这里其实涉及一个很古老的url片段,以前的url会在协议后面加上用户名例如
<font style="color:#000000;">schema://username@host:port</font>
,现在因为密码明文运输了其实这种写法很少见了,但是这里正则匹配要求ctf.开头的话就只能使用这种方法了,结尾要show作结尾的话可以让其作为参数结尾反正不影响路径