def verify(file): volume = container.Container.openURNtoContainer(rdfvalue.URN.FromFileName(file)) printVolumeInfo(file, volume) printCaseInfo(volume) resolver = volume.resolver if type(volume) == container.PhysicalImageContainer: image = volume.image listener = VerificationListener() validator = block_hasher.Validator(listener) print("Verifying AFF4 File: %s" % file) validator.validateContainer(rdfvalue.URN.FromFileName(file)) for result in listener.results: print("\t%s" % result) elif type(volume) == container.LogicalImageContainer: #print ("\tLogical Images:") hasher = linear_hasher.LinearHasher2(resolver, LinearVerificationListener()) for image in volume.images(): print ("\t%s <%s>" % (image.name(), trimVolume(volume.urn, image.urn))) hasher.hash(image)
def verify(file, password): with container.Container.openURNtoContainer( rdfvalue.URN.FromFileName(file)) as volume: if password != None: assert not issubclass(volume.__class__, container.PhysicalImageContainer) volume.setPassword(password[0]) childVolume = volume.getChildContainer() printVolumeInfo(file, childVolume) printCaseInfo(childVolume) resolver = childVolume.resolver hasher = linear_hasher.LinearHasher2(resolver, LinearVerificationListener()) for image in childVolume.images(): print("\t%s <%s>" % (image.name(), trimVolume(childVolume.urn, image.urn))) hasher.hash(image) else: printVolumeInfo(file, volume) printCaseInfo(volume) resolver = volume.resolver if type(volume) == container.PhysicalImageContainer: image = volume.image listener = VerificationListener() validator = block_hasher.Validator(listener) print("Verifying AFF4 File: %s" % file) validator.validateContainer(rdfvalue.URN.FromFileName(file)) for result in listener.results: print("\t%s" % result) elif type(volume) == container.LogicalImageContainer: #print ("\tLogical Images:") hasher = linear_hasher.LinearHasher2( resolver, LinearVerificationListener()) for image in volume.images(): print("\t%s <%s>" % (image.name(), trimVolume(volume.urn, image.urn))) hasher.hash(image)
def testBlockHashPreStdPartialAllocatedImage(self): validator = block_hasher.Validator() validator.validateContainer(self.preStdAllocatedURN)
def testBlockHashPreStdLinearImage(self): validator = block_hasher.Validator() validator.validateContainer(self.preStdLinearURN)
def testBlockHashStdLinearAllHashesImage(self): validator = block_hasher.Validator() validator.validateContainer(self.stdLinearAllHashesURN)
def testBlockHashStdContainerPartialAllocated(self): validator = block_hasher.Validator() validator.validateContainer(self.stdAllocatedURN)
def testBlockHashStdLinearStriped(self): validator = block_hasher.Validator() validator.validateContainerMultiPart(self.stripedLinearBURN, self.stripedLinearAURN)
def testBlockHashStdLinearReadError(self): validator = block_hasher.Validator() validator.validateContainer(self.stdLinearReadErrorURN)