Writing only unique hashes to an output file (for eventual cracking with 3rd party tools)

This commit is contained in:
Miroslav Stampar 2012-12-12 09:59:24 +01:00
parent b9f6fc5f4e
commit ef33729381

View File

@ -312,15 +312,23 @@ def storeHashesToFile(attack_dict):
warnMsg += "for eventual further processing with other tools" warnMsg += "for eventual further processing with other tools"
logger.warn(warnMsg) logger.warn(warnMsg)
items = set()
with open(filename, "w+") as f: with open(filename, "w+") as f:
for user, hashes in attack_dict.items(): for user, hashes in attack_dict.items():
for hash_ in hashes: for hash_ in hashes:
if not hash_ or hash_ == NULL or not hashRecognition(hash_): if not hash_ or hash_ == NULL or not hashRecognition(hash_):
continue continue
item = None
if user and not user.startswith(DUMMY_USER_PREFIX): if user and not user.startswith(DUMMY_USER_PREFIX):
f.write("%s:%s\n" % (user.encode(UNICODE_ENCODING), hash_.encode(UNICODE_ENCODING))) item = "%s:%s\n" % (user.encode(UNICODE_ENCODING), hash_.encode(UNICODE_ENCODING))
else: else:
f.write("%s\n" % hash_.encode(UNICODE_ENCODING)) item = "%s\n" % hash_.encode(UNICODE_ENCODING)
if item and item not in items:
f.write(item)
items.add(item)
def attackCachedUsersPasswords(): def attackCachedUsersPasswords():
if kb.data.cachedUsersPasswords: if kb.data.cachedUsersPasswords: