HongCMS 审计学习

概述:

刚入手学习代码审计、试着练习和读懂代码,慢慢的一点点的接触审计相关的知识,通过“国家信息安全漏洞库”或许部分漏洞标题和内容信息试着着手学习。

HongCMS是一套开源的轻量级内容管理系统(CMS)。

相关信息:

版本:HongCMS_v3.0.0

CNNVD链接地址:http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-201806-1362

工具:notepad++ 、Seay源代码审计系统

0x01:

通过目录大致了解目录结构、其中相关功能:前台(controllers)、install(安装)、public(公共文件)、system(核心相关加载)、includes(功能)。

0x02:

入口文件: /index.php

跟进文件:/includes/core.php

 第8行:

@include(ROOT . 'config/config.php');  加载数据库配置文件

  

第11-17行:主要加载相关的模板文件

function __autoload($class){
	if($class{0} === "S"){
		$file = ROOT . "system/plugins/$class.class.php"; //自动加载系统扩展类
	}else{
		//自动加载模型, 模型类名: name, 文件名必须小写, 文件路径如: ./models/name.php
		$file ="./models/$class.php";
	}
	
	require_once($file);
}

  

第22-23行:

require(ROOT . 'config/settings.php');
require(ROOT . 'system/APP.php');     //加载核心文件

  

跟进文件:/system/APP.php

第134~170行:关键run方法部分

	public static function run(){
		$splitFlag = preg_quote(self::$splitFlag,"/");
		$path_array = array();

		$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
		if(!empty($path)){
			if($path[0]=="/") $path=strtolower(substr($path,1));
			$path_array = preg_split("/[$splitFlag\/]/",$path,-1);
		}

		$controller	= !empty($path_array[0]) ? $path_array[0] : self::$defaultController ;
		$action	= !empty($path_array[1]) ? $path_array[1] : self::$defaultAction ;

		$app_file = self::$appDir . "controllers/" . $controller . ".php";
		if(!is_file($app_file)){
			self::debug("file[$app_file] does not exists.", $controller);
			return false;
		}else{
			require_once(realpath($app_file));
		}

		$classname = 'c_' . $controller;
		if(!class_exists($classname, false)){
			self::debug("class[$classname] does not exists.", $controller);
			return false;
		}

		$path_array[0] = $controller;
		$path_array[1] = $action;
		$classInstance = new $classname($path_array);
		if(!method_exists($classInstance,$action)){
			self::debug("method[$action] does not exists in class[$classname].", $controller);
			return false;
		}

		return call_user_func(array(&$classInstance,$action),$path_array);
	}

  

其中加载的是前台公共、相关news、product 前台新闻文章展示。

0x03:

这套系统前台相关功能不存相关的利用漏洞、这里记录下自己阅读的过程。

$_GET['id'] 进入以后首先通过构造函数__construct 首先处理 -->ForceIntFrom()函数 跟进:

第178~187行:/includes/functions.global.php

function ForceIntFrom($VariableName, $DefaultValue = 0) {
	if (isset($_GET[$VariableName])) {
		return ForceInt($_GET[$VariableName], $DefaultValue);
	} elseif (isset($_POST[$VariableName])) {
		return ForceInt($_POST[$VariableName], $DefaultValue);
	} else {
		return $DefaultValue;
	}

}

  

该函数的主要用途是鉴别函数传进来是以$_GET、$_POST,继续跟进ForceInt。

第147~150行:

function ForceInt($InValue, $DefaultValue = 0) {
	$iReturn = intval($InValue);
	return ($iReturn == 0) ? $DefaultValue : $iReturn;
}

  

该函数主要作用是对$_GET、$_POST传进来的$InValue做一个intval整数值处理。

通过以上阅读和学习、前台仅有的相关功能文件只有唯一的$_GET['id']一个变量、而且做了数字型的相关处理,不存在漏洞(自己还是比较菜所有没有审计出其他问题)

猜你喜欢

转载自www.cnblogs.com/xsr7yer/p/9293105.html