当前位置:网站首页>BUUCTF web WarmUp
BUUCTF web WarmUp
2022-07-17 05:06:00 【dafeng2773】
访问题目链接,看到好大一张滑稽脸

先看一下f12,有提示Sourc.php
访问Sourc.php

包含source.php和hint.php,访问hint.php

猜测flag在ffffllllaaaagggg中
观察Sourc.php中代码和emoji的链接,猜测是考代码审计以及目录穿越

代码审计
<?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); //url对$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\" />";
}
?>
先看代码的主要部分,对file参数进行3次判断:1.是否非空2.是否是字符串3.是否能通过checkFile函数的校验。3次判断都通过后,才能包含。
checkFile函数:
1.先设置了白名单,只包含source.php和hint.php
2.对$page进行判断,判断page?前面的参数是否在白名单中
3.考录到url编码,进行了一次解码,再校验
尝试构造payload:
file=source.php?../../../../../ffffllllaaaagggg出错了,有一个URL编码问题
将?改成%3F
构造payload:
file=source.php%3F../../../../../ffffllllaaaagggg成功得到flag

这题比较坑代码审计的题目就是要先读懂代码,然后构造对应的payload.
参考链接:
边栏推荐
- 关于New_Online_Judge_1081_哥德巴赫猜想的思考
- H5如何获取内网IP和公网IP
- 小程序云开发表单提交并在页面中获取数据
- 02 Bar _ Recommandation de film (basée sur le contenu) Portrait de l'utilisateur
- Wechat applet obtains the week, morning, noon and evening of month, year and day
- Internship project 1 - personalized homepage configuration
- [2022 10th Teddy Cup Challenge] Title A: complete version of pest identification (general idea. Detailed process and code and results CSV in compressed package)
- 学习C语言的第五天
- 【C语言—零基础第十一课】旋转大转盘之指针
- How to upload qiniu cloud
猜你喜欢
随机推荐
computed和watch的区别
Submit the uniapp form (input, radio, picker) to get the parameter value
【C语言—零基础第八课】循环结构与break continue
Infinite classification
Cesium 绑定鼠标事件和移除鼠标事件
Cesium 获取鼠标点击处经纬度的三种方法
机器学习之特征提取(类别特征进行数值化、离散化、文本特征进行数值化)
父组件加scoped有时也会影响子组件
读论文《SNUNet-CD: A Densely Connected Siamese Network for Change Detection of VHR Images》
这么6的刷题网站你不会没听说过吧?你已经out 了?
es6新增-字符串部分
Base64 and file conversion
【Es6】forEach,for... in ,for... Of column, which allows you to quickly distinguish the usage and differences of various for statements through project cases (full version). There are detailed notes ins
C语言练习2
Word2Vec原理及应用与文章相似度(推荐系统方法)
IDL 6S查找表
es6新增-Symbol数据类型
Database training 7 [index and creation of data integrity constraints]
Three high concurrency methods to realize I++
实习项目1-个性化主页配置








