thinkphp日志泄漏漏洞_ThinkPHP5 远程命令执行漏洞分析

前言

ThinkPHP官方最近修复了一个严重的远程代码执行漏洞。这个主要漏洞原因是由于框架对控制器名没有进行足够的校验导致在没有开启强制路由的情况下可以构造恶意语句执行远程命令,受影响的版本包括5.0和5.1版本。

测试环境:

ThinkPHP 5.1 beta+ win10 64bit + wamp

漏洞分析

网上已经有些分析文章了,我就正向分析下这次漏洞过程。不同版本的ThinkPHP调用过程和代码会稍有差异,本文分析的是ThinkPHP 5.1 beta的代码,其他版本的可以类似的分析。

首先会加载thinkphp/library/think/App.php ,运行run函数

public function run()

{

// 初始化应用

$this->initialize();

try {

if (defined('BIND_MODULE')) {

// 模块/控制器绑定

BIND_MODULE && $this->route->bindTo(BIND_MODULE);

} elseif ($this->config('app.auto_bind_module')) {

// 入口自动绑定

$name = pathinfo($this->request->baseFile(), PATHINFO_FILENAME);

if ($name && 'index' != $name && is_dir($this->appPath . $name)) {

$this->route->bindTo($name);

}

}

$this->request->filter($this->config('app.default_filter'));

// 读取默认语言

$this->lang->range($this->config('app.default_lang'));

if ($this->config('app.lang_switch_on')) {

// 开启多语言机制 检测当前语言

$this->lang->detect();

}

$this->request->langset($this->lang->range());

// 加载系统语言包

$this->lang->load([

$this->thinkPath . 'lang/' . $this->request->langset() . '.php',

$this->appPath . 'lang/' . $this->request->langset() . '.php',

]);

// 获取应用调度信息

$dispatch = $this->dispatch;

if (empty($dispatch)) {

// 进行URL路由检测

$dispatch = $this->routeCheck($this->request);

}

// 记录当前调度信息

$this->request->dispatch($dispatch);

// 记录路由和请求信息

if ($this->debug) {

$this->log('[ ROUTE ] ' . var_export($this->request->routeinfo(), true));

$this->log('[ HEADER ] ' . var_export($this->request->header(), true));

$this->log('[ PARAM ] ' . var_export($this->request->param(), true));

}

// 监听app_begin

$this->hook->listen('app_begin', $dispatch);

// 请求缓存检查

$this->request->cache(

$this->config('app.request_cache'),

$this->config('app.request_cache_expire'),

$this->config('app.request_cache_except')

);

// 执行调度

$data = $dispatch->run();

} catch (HttpResponseException $exception) {

$data = $exception->ge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值