Skip to content

Commit

Permalink
Mimikatz: Fix duplication of mimikatz credentials
Browse files Browse the repository at this point in the history
Issue: #3168
PR: #3292
  • Loading branch information
ilija-lazoroski committed May 3, 2023
1 parent 3622ee3 commit fd7405c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def __init__(
def run(self, *, options=None, interrupt=None) -> Sequence[Credentials]:
logger.info("Attempting to collect windows credentials with pypykatz.")
windows_credentials = get_windows_creds()
logger.info(f"Pypykatz gathered {len(windows_credentials)} credentials.")
unique_credentials = list(set(windows_credentials))
logger.info(f"Pypykatz gathered {len(unique_credentials)} unique credentials.")

collected_credentials = self._to_credentials(windows_credentials)
collected_credentials = self._to_credentials(unique_credentials)
self._publish_credentials_stolen_event(collected_credentials)

return collected_credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ def to_dict(self) -> Dict[str, str]:
"ntlm_hash": self.ntlm_hash,
"lm_hash": self.lm_hash,
}

def __eq__(self, other):
if isinstance(other, WindowsCredentials):
return (
self.username == other.username
and self.password == other.password
and self.ntlm_hash == other.ntlm_hash
and self.lm_hash == other.lm_hash
)
return False

def __hash__(self):
return hash((self.username, self.password, self.ntlm_hash, self.lm_hash))
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_pypykatz_result_parsing_duplicates(monkeypatch):
patch_pypykatz(win_creds, monkeypatch)

collected_credentials = collect_credentials()
assert len(collected_credentials) == 2
assert len(collected_credentials) == 1


def test_pypykatz_result_parsing_defaults(monkeypatch):
Expand Down

0 comments on commit fd7405c

Please sign in to comment.