def DES(key, data): """ @summary: DES use in microsoft specification @param key: {str} Des key on 56 bits or 7 bytes @param data: {str} data to encrypt """ return pyDes.des(expandDesKey(key)).encrypt(data)
def recvVNCChallenge(self, data): """ @summary: receive challenge in VNC authentication case @param data: Stream that contain well formed packet """ key = (self._password + '\0' * 8)[:8] newkey = [] for ki in range(len(key)): bsrc = ord(key[ki]) btgt = 0 for i in range(8): if bsrc & (1 << i): btgt = btgt | (1 << 7 - i) newkey.append(chr(btgt)) algo = des(newkey) self.send(String(algo.encrypt(data.getvalue()))) self.expect(4, self.recvSecurityResult)
def recvVNCChallenge(self, data): """ @summary: receive challenge in VNC authentication case @param data: Stream that contain well formed packet """ key = (self._password + '\0' * 8)[:8] newkey = [] for ki in range(len(key)): bsrc = ord(key[ki]) btgt = 0 for i in range(8): if bsrc & (1 << i): btgt = btgt | (1 << 7-i) newkey.append(chr(btgt)) algo = des(newkey) self.send(String(algo.encrypt(data.getvalue()))) self.expect(4, self.recvSecurityResult)