參考:https://www.phpmianshi.com/?id=102
概況
2018年12月09日thinkphp團隊發佈了版本更新:https://blog.thinkphp.cn/869075 ,其中修復了一處getshell漏洞。
影響範圍
5.1.x < 5.1.315.0.x<= 5.0.23
實戰演練
比如5.0.7漏洞利用方法:
https://www.phpmianshi.com/?s=index/\think\app/invokefunction&function=phpinfo&vars[0]=1
可以看到phpinfo信息
修復方法
5.0.x版本修復:新增紅色代碼:
// 獲取控制器名
vi thinkphp/library/think/App.php
$controller = strip_tags($result[1] ?: $config['default_controller']);
if (!preg_match('/^[A-Za-z][\w\.]*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
$controller = $convert ? strtolower($controller) : $controller;
修復後看不到phpinfo信息
5.1.x版本修復:
vi thinkphp/library/think/route/dispatch/Module.php
找到 // 獲取控制器名
// 獲取控制器名
$controller = strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));
if (!preg_match('/^[A-Za-z][\w\.]*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
官方現已推出補丁 建議開發者進行修復,但是下面這2個補丁不支持分層控制器,最好用我上面的或者升級最新版本
Thinkphp v5.0.x補丁地址: https://github.com/top-think/framework/commit/b797d72352e6b4eb0e11b6bc2a2ef25907b7756f
Thinkphp v5.1.x補丁地址: https://github.com/top-think/framework/commit/802f284bec821a608e7543d91126abc5901b2815