<?php error_reporting(0); highlight_file(__FILE__); // flag.php 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 functionhahaha(){ 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 functionIPO(){ 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'])); } ?>
代码审计 先看危险点
1 2
echo new $_POST['a']($_POST['b']); 可以利用原生类注入
看到魔法函数 wakeup 在反序列化时自动触发
想办构造pop链 当反序列化时会自动触发wakeup函数 我们需要让:
1 2
if($this->department->hahaha()) 返回true
我们要调动classroom类中的hahaha函数:
1 2
if($this->name != 'one class' or $this->leader->name != 'ing' or $this->leader->rank !='department') 让其返回flase 即可
<?php include 'flag.php'; class pkshow { functionecho_name() { return"Pk very safe^.^"; } }
class acp { protected $cinder; public $neutron; public $nova; function__construct() { $this->cinder = new pkshow; } function__toString() { if (isset($this->cinder)) return$this->cinder->echo_name(); } }
class ace { public $filename; public $openstack; public $docker; functionecho_name() { $this->openstack = unserialize($this->docker); $this->openstack->neutron = $heat; if($this->openstack->neutron === $this->openstack->nova) { $file = "./{$this->filename}"; if (file_get_contents($file)) { return file_get_contents($file); } else { return"keystone lost~"; } } } }