[BJDCTF2020]Mark loves cat1

打开题目

发现这么多链接,以为要一点点去找功能上的漏洞。当你源代码,dirsearch,抓包等等操作之后,发现什么都没有。所以这题又是一道源码泄露题,上GItHack。扫描结果如下

http://63f29a80-e08b-43ae-a6d0-8e70fb02eaa3.node5.buuoj.cn:81/.git

主要代码在index里面

<?php

include 'flag.php';

$yds = "dog";

$is = "cat";

$handsome = 'yds';

foreach(_POST as x => $y){

x = $y; //$flag=1 } foreach($_GET as $x =\> $y){ $$x = $$y; } foreach($_GET as $x =\> $y){ if($_GET\['flag'\] === $x \&\& $x !== 'flag'){ exit($handsome); } } if(!isset($_GET\['flag'\]) \&\& !isset($_POST\['flag'\])){ exit($yds); } if($_POST\['flag'\] === 'flag' \|\| $_GET\['flag'\] === 'flag'){ exit($is); } echo "the flag is: ".$flag; 根据源代码,需要通过get传参达到变量覆盖的目的。 ?yds=flag 覆盖is变量 if($_POST\['flag'\] === 'flag' \|\| $_GET\['flag'\] === 'flag'){ exit($is); } Get或Post传入flag=flag,触发变量覆盖代码 foreach($_POST as $x =\> $y){ $$x = $y; //$flag=1 } foreach($_GET as $x =\> $y){ $$x = $$y; } 输出?is=flag\&flag=flag ![](https://i-blog.csdnimg.cn/direct/dde2afd9e44b45cb928f83d08119feb5.png) 再覆盖覆盖handsome变量 handsome=flag,得到$handsome=$flag ?handsome=flag\&flag=handsome 可以得到flag

相关推荐
聊询QQ:276998853 天前
用蜣螂优化(DBO)算法攻克混合流水车间调度问题
gulp
中年程序员一枚3 天前
python开发接口uvicorn方法启动FastAPI,postman调用接口
python·postman·fastapi
中年程序员一枚3 天前
让postman调用python的开发接口,链接sqlite数据库,让前后联动起来
数据库·python·postman
yuezhilangniao3 天前
Windows 系统变量未完全清楚 - 代理执行一半 导致 pip 和 Postman 连接失败的解决指南
windows·postman·pip
石头wang4 天前
postman如何设置鉴权authorization header(怎么只设置一次,统一管理,不要每个request重复设置)
测试工具·lua·postman
R.lin4 天前
换掉 Postman,我用它Reqable
测试工具·postman
一念一花一世界5 天前
PostIn从基础到实践(5) - 对接口进行快捷调试
postman·postin·api调试·接口管理工具
一点事5 天前
用postman,如何调用webservice接口?
测试工具·postman
咨询QQ688238865 天前
非线性悬架建模与UKF状态估计:Matlab/Simulink源码与详细建模说明
postman