[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

相关推荐
小冯的编程学习之路1 天前
【软件测试】:推荐一些接口与自动化测试学习练习网站(API测试与自动化学习全攻略)
c++·selenium·测试工具·jmeter·自动化·测试用例·postman
傻小胖2 天前
三种常见接口测试工具(Apipost、Apifox、Postman)
测试工具·postman
辛普森Mmmm2 天前
Postman接口测试
测试工具·postman
悟能不能悟6 天前
如何在postman使用时间戳
测试工具·postman
s甜甜的学习之旅9 天前
浏览器开发者工具Network面板中复制请求的相关信息(结合PostMan)
测试工具·postman
IT小白农民工14 天前
如何用postman进行批量操作
测试工具·postman·sap
Kairo_0116 天前
在 API 模拟阶段:Apipost vs. Faker.js vs. Postman —— 为什么 Apipost 是最优选择
开发语言·javascript·postman
Hy行者勇哥17 天前
用Postman验证IAM Token的实际操作
测试工具·postman
樱花树下的猫老师19 天前
Postman加Cookie的方式
测试工具·postman
喝养乐多长不高19 天前
详细PostMan的安装和基本使用方法
java·服务器·前端·网络协议·测试工具·https·postman