Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef33729

Browse files
committed
Writing only unique hashes to an output file (for eventual cracking with 3rd party tools)
1 parent b9f6fc5 commit ef33729

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/utils/hash.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,23 @@ def storeHashesToFile(attack_dict):
312312
warnMsg += "for eventual further processing with other tools"
313313
logger.warn(warnMsg)
314314

315+
items = set()
316+
315317
with open(filename, "w+") as f:
316318
for user, hashes in attack_dict.items():
317319
for hash_ in hashes:
318320
if not hash_ or hash_ == NULL or not hashRecognition(hash_):
319321
continue
322+
323+
item = None
320324
if user and not user.startswith(DUMMY_USER_PREFIX):
321-
f.write("%s:%s\n" % (user.encode(UNICODE_ENCODING), hash_.encode(UNICODE_ENCODING)))
325+
item = "%s:%s\n" % (user.encode(UNICODE_ENCODING), hash_.encode(UNICODE_ENCODING))
322326
else:
323-
f.write("%s\n" % hash_.encode(UNICODE_ENCODING))
327+
item = "%s\n" % hash_.encode(UNICODE_ENCODING)
328+
329+
if item and item not in items:
330+
f.write(item)
331+
items.add(item)
324332

325333
def attackCachedUsersPasswords():
326334
if kb.data.cachedUsersPasswords:

0 commit comments

Comments
 (0)