(attack_dict)
| 627 | retVal.close() |
| 628 | |
| 629 | def storeHashesToFile(attack_dict): |
| 630 | if not attack_dict: |
| 631 | return |
| 632 | |
| 633 | items = OrderedSet() |
| 634 | |
| 635 | for user, hashes in attack_dict.items(): |
| 636 | for hash_ in hashes: |
| 637 | hash_ = hash_.split()[0] if hash_ and hash_.strip() else hash_ |
| 638 | if hash_ and hash_ != NULL and hashRecognition(hash_): |
| 639 | item = None |
| 640 | if user and not user.startswith(DUMMY_USER_PREFIX): |
| 641 | item = "%s:%s\n" % (user, hash_) |
| 642 | else: |
| 643 | item = "%s\n" % hash_ |
| 644 | |
| 645 | if item and item not in items: |
| 646 | items.add(item) |
| 647 | |
| 648 | if kb.choices.storeHashes is None: |
| 649 | message = "do you want to store hashes to a temporary file " |
| 650 | message += "for eventual further processing with other tools [y/N] " |
| 651 | |
| 652 | kb.choices.storeHashes = readInput(message, default='N', boolean=True) |
| 653 | |
| 654 | if items and kb.choices.storeHashes: |
| 655 | handle, filename = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.HASHES, suffix=".txt") |
| 656 | os.close(handle) |
| 657 | |
| 658 | infoMsg = "writing hashes to a temporary file '%s' " % filename |
| 659 | logger.info(infoMsg) |
| 660 | |
| 661 | with openFile(filename, "w+") as f: |
| 662 | for item in items: |
| 663 | try: |
| 664 | f.write(item) |
| 665 | except (UnicodeError, TypeError): |
| 666 | pass |
| 667 | |
| 668 | def attackCachedUsersPasswords(): |
| 669 | if kb.data.cachedUsersPasswords: |
no test coverage detected
searching dependent graphs…