Warmup

F12查看源代碼
打開http://111.198.29.45:42736/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\" />";
}
?>
如果引數file符合checkFile函式檢測規則,則包含此檔案,這里我們可以利用url多次編碼繞過第二個檢測,
在source.php時提到hint.php,查看頁面
構造payload,四層目錄
識訓:以字符‘/’分隔(而且不計個數),若是在前面的字串所代表的檔案無法被PHP找到,則PHP會自動包含‘/’后面的檔案——注意是最后一個‘/’

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/205395.html
標籤:其他
下一篇:看精神小伙是如何智斗騙子的
