[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

再覆盖覆盖handsome变量

handsome=flag,得到handsome=flag

?handsome=flag&flag=handsome

可以得到flag

相关推荐
Joyce_xiaobaibai2 天前
windows+Postman Newman+接口巡检
postman
Tinyfacture7 天前
postman抓取登录鉴权码token及设置全局变量
测试工具·postman
川石课堂软件测试7 天前
涨薪技术|Prometheus之HTTP API中使用PromQL
网络协议·测试工具·jmeter·http·单元测试·postman·prometheus
x10n98 天前
Postman 汉化完整指南
测试工具·lua·postman
AI情绪识别开源12 天前
检信 Allemotion 认知功能障碍矫正软件· 数据方案
人工智能·postman
程序员杰哥16 天前
如何做接口测试?
自动化测试·python·测试工具·职场和发展·测试用例·接口测试·postman
测试老哥19 天前
Postman获取token并设置token依赖步骤
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
2601_9621819620 天前
Redis Redis介绍、安装 - Redis客户端
数据库·redis·postman
redfred21 天前
hoppscotch 使用教程:开源 API 调试工具 Postman 免费替代 Web/桌面/Docker 部署详解
开源·postman·graphql
测试秃头怪21 天前
Postman中变量的使用
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman