buuctf-web
极客大挑战 easy sql 1
post表单,先输入用户名密码看看有无sql报错


出现sql报错,推测为单引号闭合
猜字段


输入4

字段为3
联合查询查数据库

直接爆出flag
HCTF 2018 warm up 1

打开页面,一个滑稽映入眼帘....
看看源码,注释里有个source.php

访问试试

这里看到除了source.php外还有个hint.php
访问试试

emmmm......不太懂
回到source.php
各行代码的作用
<?php
highlight_file(__FILE__);
class emmm
{
//$page前面加&代表引用,这里是引用传递
public static function checkFile(&$page)
{
//定义whitelist数组
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
//如果page变量未声明或为null,或者不是字符串,则进入if
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
//如果page的值在$whitelist数组里则进入if
if (in_array($page, $whitelist)) {
return true;
}
//截取从0到?首次出现的位置的字符串
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?') //点在php中用来连接两个字符串或变量,此代码意思为拼接page和?的值,并返回?字符首次出现的位置
);
//如果_page的值在$whitelist数组里则进入if
if (in_array($_page, $whitelist)) {
return true;
}
//对page解码
$_page = urldecode($page);
//截取从0到?首次出现的位置的字符串
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
//如果_page的值在$whitelist数组里则进入if
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
//如果file变量为空 且 是字符串 且 通过checkFile 校验,则进入if
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\" />";
}
?>
可以看到最后的include语句没有任何的过滤,因此这里考虑本地文件包含漏洞
本地文件包含漏洞的一般格式为file=../../../xx xx代表flag的文件名
这里前面的hint就有了解释
猜测存放flag的文件名为 ../ffffllllaaaagggg
知道了这一点后,剩下的工作就是绕过代码中的过滤函数
可以设置payload为?file=source.php?../ffffllllaaaagggg
这样经过mb_str过滤后的字符串为source.php,而source.php在whitelist中,程序返回true
逐个添加../测试,得到flag
![]()
../代表上层目录
极客大挑战 2019 havefun 1
打开页面,一张动态猫猫图
看下源码
有个get参数cat,传个参试试
![]()
出了.....
actf 2020 新生赛 include 1
访问靶机,看到后面的file传参猜测文件包含

这里用php://filter读取base64形式的源码

解码即得flag


浙公网安备 33010602011771号