Agent: Capture username even if no secrets are associated

This commit is contained in:
Mike Salvatore 2022-07-18 08:46:07 -04:00
parent c144ad9e64
commit d5a125d985
2 changed files with 22 additions and 0 deletions

View File

@ -45,4 +45,7 @@ class MimikatzCredentialCollector(ICredentialCollector):
ntlm_hash = NTHash(nt_hash=wc.ntlm_hash)
credentials.append(Credentials(identity, ntlm_hash))
if len(credentials) == 0 and identity is not None:
credentials.append(Credentials(identity, None))
return credentials

View File

@ -91,3 +91,22 @@ def test_pypykatz_result_parsing_no_identities(monkeypatch):
collected_credentials = collect_credentials()
assert len(collected_credentials) == 2
assert collected_credentials == expected_credentials
def test_pypykatz_result_parsing_no_secrets(monkeypatch):
username = "user3"
win_creds = [
WindowsCredentials(
username=username,
password="",
ntlm_hash="",
lm_hash="",
),
]
patch_pypykatz(win_creds, monkeypatch)
expected_credentials = [Credentials(Username(username), None)]
collected_credentials = collect_credentials()
assert len(collected_credentials) == 1
assert collected_credentials == expected_credentials