[NewStarCTF 公开赛赛道]IncludeOne
<?php
highlight_file(__FILE__);
error_reporting(0);
include("seed.php");
//mt_srand(*********);
echo "Hint: ".mt_rand()."<br>";
if(isset($_POST['guess']) && md5($_POST['guess']) === md5(mt_rand())){
if(!preg_match("/base|\.\./i",$_GET['file']) && preg_match("/NewStar/i",$_GET['file']) && isset($_GET['file'])){
//flag in `flag.php`
include($_GET['file']);
}else{
echo "Baby Hacker?";
}
}else{
echo "No Hacker!";
} Hint: 1219893521
No Hacker!
判断post传入的guess值md5和随机数md5是否一样。
通过php_mt_seed 工具暴力破解
从给的链接下载后,编译下
执行之后,得到种子
选择其中一个,进行执行,得到随机数
这里我尝试到第二个成功。
第二层判断,get 传参file. 不能出现base和. 必须存在NewStar,
flag存在flag.php
那就很简单了。filter伪协议,用其他的加密即可绕过。 关于必须存在NewStar的绕过, php://filter协议在/ 后面可以添加任意字符,不会影响结果的输出,如下
/?file=php://filter/read=string.rot13/NewStar/resource=flag.php
post: guess=1202031004
最后源码注释中得到flag
rot13解密得到flag