- 介绍
PHP 5.6.25之前版本和7.0.10之前版本的7.x中的xt/standard/va unserializer.c错误地处理了某些无效对象,这使得远程攻击者能够通过精心编制的序列化数据导致(1) 析构函数调用或(2)magic方法调用,造成拒绝服务或可能具有未指明的其他影响。
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-7124
2.序列化格式
Public属性序列化后格式:成员名
Private属性序列化后格式:%00类名%00成员名
Protected属性序列化后的格式:%00*%00成员名
O:4:"home":3:{s:2:"F1";s:1:"1";s:8:"homeF2";s:1:"2";s:5:"*F3";s:1:"3";}
O:4:"home":3:{s:2:"F1";s:1:"1";s:8:"%00home%00F2";s:1:"2";s:5:"%00*%00F3";s:1:"3";}
O:6:"sercet":1:{s:12:"%00sercet%00file";s:8:"flag.php";}
3.考题
<?php
error_reporting(0);
class sercet{
private $file='index.php';
public function __construct($file){
echo "_construct执行<br>";
$this->file=$file;
}
function __destruct(){
echo " __destruct执行<br>";
// echo show_source($this->file,true);
echo @highlight_file($this->file, true);
}
function __wakeup(){
echo "__wakeup执行<br>";
$this->file='index.php';
}
}
unserialize($_GET['val']);