当前位置:网站首页>xctf攻防世界 Web高手进阶区 unserialize3
xctf攻防世界 Web高手进阶区 unserialize3
2022-07-28 02:52:00 【l8947943】
0x01. 进入环境
显示一段源代码:
class xctf{
public $flag = '111';
public function __wakeup(){
exit('bad requests');
}
?code=
0x02. 问题分析
0x02_1. 代码审计
首先,定义一个“xctf”类,这个类有两个成员属性,分别是 flag 和__wakeup。接下来是 __wakeup方法的实现,再就是最后一行变量 code 没有写完,估计就是想让我们传参进去完成它了。
这里的 __wakeup 函数是一个所谓的“魔术方法”,它在反序列化时会先于其他函数被调用,执行它的语句。
这就意味着,如果我们直接构造一个字符串,那么这个 __wakeup_ 会先一步执行,并直接 exit,这可不是我们想要的结果。
也就是说,我们构造的code的参数传入后,先被__wakeup方法首先调用。因此我们想办法绕过该函数即可。
0x02_2. 进行尝试
阅相关大神WP后才知道,一个漏洞(CVE-2016-7124)可以通过 使序列化字符串中表示对象属性个数的值大于真实的属性个数,以此跳过__wakeup 的执行。
首先,序列化字符串的标准格式:O:<类名的长度>:"<类名>":<成员属性的个数>:{S:<成员属性名的长度>:"<成员属性名>";......} 这道题的话,如果要对 xctf 类进行正确的序列化,那么它的字符串应该是:O:4:"xctf":1:{S:4:"flag";S:3:"111";}
在线测试地址:https://www.dooccn.com/php/,使用如下代码即可验证。
<?php
class xctf{
public $flag = '111';
public function __wakeup(){
exit('bad requests');
}
}
$a = new xctf();
print(serialize($a));
?>
0x02_3. 跳过__wakeup()函数
将序列化的字符串进行修改,修改序列化字符串中的属性个数,并完成字符串的拼接,以get方法传出,地址拼接如下:
http://61.147.171.105:56068/?code=O:4:“xctf”:2:{s:4:“flag”;s:3:“111”;}
得到最终答案,答案为:cyberpeace{d0e766c698b67400e771051e6b8301aa}
参考:
边栏推荐
猜你喜欢

exness:日本物价上涨收入下降,英镑/日元突破 165

stm32F407-------DSP学习

Exness: Japanese prices rose and incomes fell, with the pound / yen breaking 165

CAD creation group is not combined?

Redis内存回收

IronOCR for .NET 2022.8

在线问题反馈模块实战(十六):实现查详情功能
![[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method](/img/4f/56033956739971d821637ae54be1bd.png)
[2022 Niuke Game 2 J question link with arithmetic progress] three part set three part / three part extreme value / linear equation fitting least square method

Design of the multi live architecture in different places of the king glory mall

MySQL事务的ACID特性及并发问题实例分析
随机推荐
VMware虚拟机网络设置
20 soul chicken soup beautiful sentences, sentence by sentence warm heart!
【R语言】环境指定删除 rm函数
Four methods of closing forms in C #
What is a virtual function?
Softek Barcode Reader 9.1.5
关于权重衰退和丢弃法
嵌入式数据库--SQLite
exness:日本物价上涨收入下降,英镑/日元突破 165
【2022牛客多校2 K Link with Bracket Sequence I】括号线性dp
When QML uses layout layout, a large number of < unknown file >: QML qquicklayoutattached: binding loop detected for property circular binding warnings appear
酒店vr全景展示拍摄提供更多合作和洽谈的机会
Original title of Blue Bridge Cup
Shell:资源监控脚本和高负载报警
max_pool2d(): argument ‘input‘ (position 1) must be Tensor, not NoneType
蓝桥杯:第九届—“彩灯控制器”
将Helm编写的Chart推送到Harbor仓库
Scheme sharing | experts gather to jointly explore accent AI speech recognition
Stm32f407 ------- FPU learning
Alibaba cloud international email service package purchase process