Okay gentlemen, Hikvision is still using an XOR-based encoder (technically, a coder-decoder). I have been able to derive the first 1024 bytes of the XOR sequence using well-known cryptanalysis techniques. I performed a frequency count on the sequence to see what kind of distribution we are seeing. Sadly, the algorithm driving this key sequence is much more random than the one used on digicap.dav.
If you want to see the first 1024 bytes of the key sequence in action and know C, the byte sequence shown below when XORed byte-by-byte with the 3.3.2 start.sh will reveal the first 1024 bytes of the file.
0x0C, 0xC3, 0x90, 0x88, 0xA6, 0xED, 0xD8, 0xF3, 0xBB, 0xBA, 0xAE, 0xC7, 0x7B, 0x5A, 0x29, 0x87,
0xFC, 0x40, 0x56, 0x60, 0x93, 0xEB, 0x6F, 0xF1, 0xAB, 0x76, 0x75, 0x13, 0xA5, 0xA8, 0xFB, 0xBE,
0xB1, 0xBE, 0xEA, 0xF6, 0x46, 0x51, 0x3E, 0x83, 0x88, 0x45, 0xE4, 0xAE, 0x3B, 0x54, 0x34, 0xFD,
0xAD, 0xE5, 0xDD, 0xB1, 0x61, 0xB7, 0xB7, 0x77, 0x35, 0xD7, 0x02, 0xB7, 0xE0, 0x51, 0x1F, 0x79,
0xFA, 0x4B, 0xB7, 0x7A, 0xBB, 0xA6, 0x0E, 0x75, 0x99, 0x23, 0x56, 0xB5, 0x74, 0x44, 0x84, 0x1D,
0x1C, 0x22, 0x55, 0x36, 0x3F, 0xD0, 0x6A, 0x27, 0xEF, 0x06, 0x80, 0x89, 0x45, 0x3D, 0x13, 0x3B,
0x0B, 0xE7, 0x5F, 0x5C, 0x2C, 0x3D, 0x9A, 0x8F, 0x7F, 0x2B, 0xD2, 0x2A, 0xA0, 0x6F, 0x78, 0x66,
0x6F, 0x68, 0xD7, 0xAA, 0xC8, 0x3E, 0x78, 0xCC, 0x5C, 0x76, 0x55, 0xAF, 0x4C, 0xAF, 0x56, 0xF3,
0xAC, 0x75, 0xD3, 0xAE, 0x6E, 0x44, 0xCD, 0x9B, 0x93, 0x9B, 0x9D, 0x7C, 0xA4, 0xA0, 0xAC, 0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27, 0x44, 0x8F, 0x25, 0xD8, 0x8D, 0xC8, 0xA6, 0x9D, 0xDE,
0x7E, 0x1C, 0x9F, 0xE1, 0x82, 0x9A, 0xF7, 0x8A, 0x94, 0xC3, 0xCB, 0xA5, 0x45, 0xD9, 0x64, 0x5C,
0x93, 0x49, 0x4E, 0x36, 0x70, 0xFE, 0x0A, 0xEE, 0x60, 0x3C, 0x43, 0x2B, 0x6C, 0x71, 0x17, 0xE1,
0x36, 0x45, 0xA4, 0x61, 0xB2, 0xD8, 0x0E, 0x79, 0x3E, 0x16, 0xA2, 0xBF, 0x99, 0xC9, 0xD5, 0x97,
0xFB, 0x22, 0x54, 0xF9, 0x13, 0xDE, 0x4B, 0x2F, 0xD7, 0x0F, 0x17, 0x60, 0x36, 0xFE, 0x09, 0xEA,
0x23, 0x52, 0x02, 0x73, 0x7F, 0x69, 0x6F, 0xA4, 0xB2, 0x1C, 0x1A, 0xC6, 0xE4, 0x89, 0xD6, 0x31,
0x88, 0xB5, 0x30, 0x6E, 0x08, 0xDE, 0xD0, 0xD4, 0xE8, 0x24, 0xF7, 0x07, 0x51, 0x29, 0x6E, 0xA6,
0xD2, 0xB1, 0xD7, 0xEF, 0x70, 0xA2, 0x9A, 0xD6, 0xEF, 0xF6, 0x6C, 0x61, 0xB6, 0x9B, 0xE3, 0x0A,
0x0D, 0x9F, 0xEC, 0xBE, 0x2A, 0x5E, 0x82, 0x11, 0x6B, 0x36, 0xCA, 0xC5, 0x52, 0xC5, 0x2B, 0xFE,
0x17, 0xCD, 0x46, 0x37, 0x06, 0xC1, 0x8A, 0x1B, 0xE6, 0xD4, 0x63, 0xA1, 0x36, 0x96, 0xF2, 0x3A
The sequence will eventually cycle around. However, given the fact that no apparent repeat occurs in 1024 bytes and the uneven distribution of byte values in the sequence means that we are dealing with something that either a) uses a very long key, or b) injects pseudo-randomness into the equation. Hikvision is upping their game, which means that we need to be careful about discussing a solution in the open, that is, if one is found. The digicap.dav solution is one thing. This cipher is more sophisticated. We sure as heck do not want Hikvision to raise the bar. I would prefer to avoid having to disassemble their code. I will do it if there is no other way, but I can think of a million things that I would rather do than wade through C compiler-generated ARM machine code.
Stay tuned...