欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

PHP 反序列化 2(OC 旁路。唤醒旁路)

最编程 2024-10-01 07:01:16
...

考点2:OC绕过、wakeup绕过

<aside> ????

OC绕过

</aside>

例题

if (preg_match('/[oc]:\\d+:/i', $var)) {
        die('stop hacking!');
    } else {

        @unserialize($var);
    }

这⾥的正则匹配的意思是如果在var变量中存在O/C:数字,

(O:数字或者C:数字这样的形式)就die掉,

这⾥匹配的是 O:4 ,直接使⽤+号当做空格即可绕过,

即 O:+4 即可绕过。

<aside> ????

wakeup绕过 (CVE-2016-7124)

</aside>

例题

<?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 f15g_1s_here.php
            $this->file = 'index.php';
        }
    }
}

if (isset($_GET['var'])) {
    $var = base64_decode($_GET['var']);
    if (preg_match('/[oc]:\\d+:/i', $var)) {
        die('stop hacking!');
    } else {

        @unserialize($var);
    }
} else {
    highlight_file("index.php");
}
?>  

• 如果存在wakeup方法,调用unseralize()方法需要先调用_wakeup方法,但是当序列化字符串中表示对象属性个数的值不等于真实的属性个数时会跳过__wakeup的执行。

具体参考漏洞(CVE-2016-7124)