当前位置:网站首页>thinkphp3.2.3日志包含分析
thinkphp3.2.3日志包含分析
2022-06-22 09:53:00 【Sk1y】
thinkphp3.2.3日志包含分析
入口点修改
入口点在\Application\Home\Controller\IndexController.class.php中

我们将这个初始的index代码进行修改,这里的第6行,如果不是这样的话,会有一点问题,这个之后会详细分析
我刚开始的调试过程中,第6行为 $this->assign('value',$value);,这个会导致一个问题,之后会分析
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index($value=''){
$this->assign($value);
$this->display();
}
}
调用流程图

调试分析
assign
首先查看assign的过程

在第122行,调用了assign函数

ThinkPHP\Library\Think\View.class.php中定义的assign()

到这里就会发现一个问题,这里会创建一个tVar[‘name’]=$value,而这个name的值就是value,就是之后一切数组嵌套的原因,这是因为我的最开始的\Application\Home\Controller\IndexController.class.php中写的有问题

我们将assign的第一个参数删除,那么在assign()函数中,就会满足if条件,进行第38行

然后执行display的时候,tVar中才是一个键值对,而不是value中又有一个键值对

display
从最开始的display开始

然后在ThinkPHP\Library\Think\View.class.php的第125行,进行赋值,将tVar传值给了$params

在ThinkPHP\Library\Think\Hook.class.php的listen函数中,第89行,将$params传入exec函数

然后ThinkPHP\Library\Think\Hook.class.php的exec中,第119行,将params传入run函数

在ThinkPHP\Library\Behavior\ParseTemplateBehavior.class.php的run函数这里,data其实就是params,然后将data[‘var’]传入fetch函数

在ThinkPHP\Library\Think\Template.class.php中,第75行,将上面的传入的data[‘var’]赋值为this->tVar,然后77行,将this->tVar传入load函数

在ThinkPHP\Library\Think\Storage\Driver\File.class.php中第77行进行判断,然后再78行进行extract赋值,但是因为是嵌套数组,所以其实是整了个value数组,但是value没定义,如左边的变量

所以其实这个display(),就是整一个params,然后一路传参,然后利用最后第78行的extract赋值,覆盖_filename,进行文件包含
我的问题在于刚开始的params是个嵌套数组,多嵌套了一层,这就是问题所在!!!
所以将最开始的 $this->assign('value',$value);删除第一个参数即可
poc分析
m参数指定文件夹,c参数指定控制器,a参数指定方法,value参数就是我们的可控参数
首先传参m
index.php?m=--><?=phpinfo();?>

然后在Application\Runtime\Logs\Common\22_06_14.log中有记录

得到日志文件的路径,然后文件包含执行任意命令
index.php?m=Home&c=Index&a=index&value[_filename]=.\Application\Runtime\Logs\Common\22_06_14.log
关于日志文件生成
日志文件有两类,日志以天为单位进行记录
Application\Runtime\Logs\Common\22_06_14.log
Application\Runtime\Logs\Home\22_06_14.log

当调试模式开启

不报错的情况下,在Application\Runtime\Logs\Home\中生成日志
报错的情况下,在Application\Runtime\Logs\Common中生成日志

当调试模式关闭

不报错的情况下,不生成日志
报错的情况下,在Application\Runtime\Logs\Common中生成日志

关于payload
index.php?m=Home&c=Index&a=index&value[_filename]=.\Application\Runtime\Logs\Common\22_06_14.log
三个参数分别是模块,控制器,操作
这里m参数指定文件夹,c参数指定控制器,a参数指定方法,value参数就是我们的可控参数
thinkphp采用单一入口模式访问应用,对应用的所有请求都定向到应用的入口文件,系统会从URL参数中解析当前请求的模块、控制器和操作,下面是一个标准的URL访问格式:
第一种访问方式
http://localhost:/thinkphp/index.php/Home/Index/index 入口文件/模块/控制器/操作
第二种访问方式(传参数)
http://localhost:/thinkphp/index.php?m=Home&c=Index&a=index 传三个参数
参考链接
边栏推荐
- 名词解析:ETL
- SQL编程task04作业-集合运算
- Pytorch实现波阻抗反演
- 抖音实战~个人中心
- 西电AI专业排名超清北,南大蝉联全国第一 | 2022软科中国大学专业排名
- Error in PHP installation of Pagoda: libcares so. 2: cannot open shared object file: No such file or directory
- Summary and Prospect of AI security technology | community essay solicitation
- [Luogu] P2887 Sunscreen G
- 搭建OpenPGP Key server
- 不要再傻傻分不清 hash、 chunkhash 和 contenthash 啦
猜你喜欢

Kali uses the command ifconfig to query the solution that the IP address is always 127.0.0.1

一口气读懂 IT发展史

TikTok 宣布将数据存储于 Oracle 服务器!

M2 芯片解析:似乎是一个增强版的 A15?

Realize multi-user isolated FTP in AD environment

SQL编程task02作业-基础查询与排序

Bloom filter optimization - crimsondb series of papers (I)

office2016+visio2016

【深度学习】不得了!新型Attention让模型提速2-4倍!

Introduction to code audit learning notes
随机推荐
Overview of microservice architecture
使用 Matplotlib 这么久,竟不知道数据可以动起来
扎克伯格最新VR原型机来了,要让人混淆虚拟与现实的那种
Basic knowledge of AI Internet of things | community essay solicitation
7-1 group minimum
命令行下获取公网IP地址汇总
Record a time when Kali encounters vmtools button gray install vmtools
呼叫中心专业术语
The time difference between IIS7 log and system time is 8 hours. Use logparser to solve the problem
6-44 traversal of binary tree
6-43 sum of ordered sparse polynomials
day575: 分糖果
[学习笔记] 回滚莫队
软件工程 大题
Win+sublime Text3 + go 1.9.2 environment setup diagram
PowerDesigner tip 2 trigger template
秋招秘籍C
MySQL skip scan range small function to solve big problems?
呼叫中心CTI系统
【科普】一文弄懂监督式学习、非监督式学习以及强化式学习