<?php /** * Created by runner.han * There is nothing new under the sun */ $SELF_PAGE = substr($_SERVER['PHP_SELF'],strrpos($_SERVER['PHP_SELF'],'/')+1); if ($SELF_PAGE = "unser.php"){ $ACTIVE = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','active open','','active','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',''); } $PIKA_ROOT_DIR = "../../"; include_once $PIKA_ROOT_DIR.'header.php'; class S{ var $test = "pikachu"; function __construct(){ echo $this->test; } } //O:1:"S":1:{s:4:"test";s:29:"<script>alert('xss')</script>";} $html=''; if(isset($_POST['o'])){ $s = $_POST['o']; if(!@$unser = unserialize($s)){ $html.="<p>大兄弟,来点劲爆点儿的!</p>"; }else{ $html.="<p>{$unser->test}</p>"; } } ?> <div class="main-content"> <div class="main-content-inner"> <div class="breadcrumbs ace-save-state" id="breadcrumbs"> <ul class="breadcrumb"> <li> <i class="ace-icon fa fa-home home-icon"></i> <a href="unserilization.php">PHP反序列化</a> </li> <li class="active">概述</li> </ul> <a href="#" style="float:right" data-container="body" data-toggle="popover" data-placement="bottom" title="tips(再点一下关闭)" data-content="先把PHP序列化和反序列化搞懂了在来玩"> 点一下提示~ </a> </div> <div class="page-content"> <form method="post"> <p>这是一个接受序列化数据的api: <input type="text" name="o" /> <input type="submit" value="提交"> </form> <?php echo $html;?> </div><!-- /.page-content --> </div> </div><!-- /.main-content --> <?php include_once $PIKA_ROOT_DIR . 'footer.php'; ?>
时间: 2023-06-01 10:07:39 浏览: 674
这段代码是一段 PHP 代码,通过对 $_SERVER['PHP_SELF'] 进行字符串截取后判断当前页面是否为 "unser.php",然后根据判断结果来设定一个 $ACTIVE 数组中的某些值,接着定义了一个 S 类,有一个成员变量 $test 值为 "pikachu",并有一个构造函数输出该成员变量的值。在 $html 变量中进行 $_POST['o'] 的反序列化,若失败则输出提示信息,否则输出反序列化后对象的 $test 值。最后通过 include_once 引入 header.php 文件。
阅读全文