ThinkPHP6.0任意文件创建

安装php 7.1
安装Composer
https://getcomposer.org/Composer-Setup.exe
切换到你的WEB根目录下面并执行下面的命令:

PS C:\xampp\htdocs> composer create-project topthink/think tp60

确保tp60/composer.json中版本是6.0
开启Session(有些API应用不需要Session,默认关闭),编辑 tp60/app/middleware.php 取消 “
\think\middleware\SessionInit::class
“的注释。
去github下载6.0的源码,将压缩包中的framework-6.0.0\src,解压到 tp\vendor\topthink\framework\src
启动应用:

PS C:\xampp\htdocs> cd .\tp60\
PS C:\xampp\htdocs\tp60> php think run –host=0.0.0.0 –port=8080

访问8080端口确认可以访问。

根据网友们的分析和官方文档,需要在自己的应用中调用session函数才会触发session的保存。

这里假如这个应用是要操作Session的。
于是修改app目录下自带的应用,修改app/controller/index.php

<?php
namespace app\controller;

use app\BaseController;

class Index extends BaseController
{
    public function index()
    {
        session('demo', $_GET['c']);
        //return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V6<br/><span style="font-size:30px">13载初心不改 - 你值得信赖的PHP框架</span></p></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="eab4b9f840753f8e7"></think>';
        return 'ThinkPHP V6.0.0';
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }
}
这里的 $_GET['c'] 会作为 $data 参数写入以sessionid为名的文件里:

由于是data是用户输入,因此可以用来写shell.

写入文件:

修改PHPSESSION,可以做到把磁盘写爆。
至于怎么把webshell写到public目录下让我可以访问到,还没想好。

影响版本:
6.0
6.1
参考:
https://mochazz.github.io/2020/01/14/ThinkPHP6.0%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%86%99/?utm_source=tuicool&utm_medium=referral#%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90
https://www.kancloud.cn/manual/thinkphp6_0/1037635

Leave a Reply

Your email address will not be published. Required fields are marked *