- Apr 20, 2016
- 104
- 307
Xuefeng Qian, Hikvision's head of R&D is on the mission to use as many crypto, hashing, and CRC algorithms as his team can possibly fit in firmware.
So far we have:
All this obfuscation mess has no cryptographic value because the keys are easily recoverable, but nothing can stop Mr. Xuefeng. He has a vision and he proudly autographs firmware images as "sunxuefeng3":
I recently got a few R6 4MP cameras with 5.3.8 firmware and I was very annoyed by psh. I can now decrypt R6 digicap.dav and here is the info that should save a lot of time for some of you:
Most of the crypto code appears to be inappropriately borrowed from the mbed tls library.
Oh, and it is possible to turn US cameras into CN and vice versa.
So far we have:
- md5
- sha1
- dumb add crc
- XOR with rotating key
- XOR with computed key
- crc32
- 3des
- aes256
All this obfuscation mess has no cryptographic value because the keys are easily recoverable, but nothing can stop Mr. Xuefeng. He has a vision and he proudly autographs firmware images as "sunxuefeng3":
Code:
00000000 30 33 4B 48 │ 7F CA 31 C7 │ 80 0B 00 00 │ 2A 00 00 00 03KH. 1ǀ ...*...
00000010 01 00 00 00 │ 02 00 00 00 │ 01 00 00 00 │ 00 03 F1 07 .............. .
00000020 3B 61 90 66 │ F6 7B 8C 01 │ B8 4E 02 00 │ 08 00 03 05 ;a f { . N......
00000030 00 00 00 00 │ B0 DA 3B 65 │ CE 69 87 3C │ 00 00 00 00 .... ;e i <....
00000040 73 75 6E 78 │ 75 65 66 65 │ 6E 67 33 00 │ EA 4A 3D 92 sunxuefeng3. J=
I recently got a few R6 4MP cameras with 5.3.8 firmware and I was very annoyed by psh. I can now decrypt R6 digicap.dav and here is the info that should save a lot of time for some of you:
- The digicap.dav header (HK20) is XOR-ed using the the same standard rotating 16-byte key.
- The HK20 header is very similar to HKWS and it contains a list of files (only one file in the 5.3.8 fw).
- File "names" start with "120", which is 0x78, which is the device id, which is important.
- The file inside has a HK30 header, of which 16 bytes are xored (same key) and the rest is AES256-encrypted.
- Figuring out the key will let you decrypt and dump about 40 files.
- There are actually four static AES256 keys, and they are en-xored with a dynamic sequence that depends on the language ID (1 for US, 2 for CN) and device ID (0x78 for R6 cameras). Two of the keys encrypt the header and two of the keys encrypt files.
- The language ID is read from sysflags (256-byte block, starts with "SFLG") that is stored in NAND and returned by one of the /dev/hikio IOCTL calls
- boorparams block is also AES-encrypted. The key is in the kernel.
Most of the crypto code appears to be inappropriately borrowed from the mbed tls library.
Oh, and it is possible to turn US cameras into CN and vice versa.
Last edited by a moderator: