diff --git a/impacket/examples/secretsdump.py b/impacket/examples/secretsdump.py index 46dbe6c77..7d5b11b55 100644 --- a/impacket/examples/secretsdump.py +++ b/impacket/examples/secretsdump.py @@ -1888,8 +1888,21 @@ def __getPek(self): decryptedPekList = self.PEKLIST_PLAIN( self.__cryptoCommon.decryptAES(self.__bootKey, encryptedPekList['EncryptedPek'], encryptedPekList['KeyMaterial'])) - self.__PEK.append(decryptedPekList['DecryptedPek'][4:][:16]) - LOG.info("PEK # 0 found and decrypted: %s", hexlify(decryptedPekList['DecryptedPek'][4:][:16]).decode('utf-8')) + + # PEK list entries take the form: + # index (4 byte LE int), PEK (16 byte key) + # the entries are in ascending order, and the list is terminated + # by an entry with a non-sequential index (08080808 observed) + pos, cur_index = 0, 0 + while True: + pek_entry = decryptedPekList['DecryptedPek'][pos:pos+20] + if len(pek_entry) < 20: break # if list truncated, should not happen + index, pek = unpack('